-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix linting issues by creating new indexes
rubocop/rubocop-rails#197 introduced a new cop to rubocop-rails that checks for unique validation on an index if it's present in the model. This caused a number of failures when upgrading to 2.5.0 that this fixes.
- Loading branch information
1 parent
910f0d2
commit 48c0c6d
Showing
2 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class IndexCreation < ActiveRecord::Migration[5.1] | ||
def change | ||
remove_index :about_pages, :name if index_exists?(:about_pages, :name) | ||
add_index :about_pages, :name, unique: true | ||
|
||
remove_index :classifications, :name if index_exists?(:classifications, :name) | ||
add_index :classifications, :name, unique: true | ||
|
||
remove_index :classification_relations, :classification_id if index_exists?(:classification_relations, :classification_id) | ||
add_index :classification_relations, :classification_id, uniqueness: { scope: :related_classification_id } | ||
|
||
remove_index :document_collection_groups, :heading if index_exists?(:document_collection_groups, :heading) | ||
add_index :document_collection_groups, :heading, uniqueness: { scope: :document_collection_id } | ||
|
||
remove_index :edition_relations, :document_id if index_exists?(:edition_relations, :document_id) | ||
add_index :edition_relations, :document_id, uniqueness: { scope: :edition_id } | ||
|
||
remove_index :operational_fields, :name if index_exists?(:operational_fields, :name) | ||
add_index :operational_fields, :name, unique: true | ||
|
||
remove_index :related_mainstreams, :content_id if index_exists?(:related_mainstreams, :content_id) | ||
add_index :related_mainstreams, :content_id, uniqueness: { scope: :edition_id } | ||
|
||
remove_index :social_media_services, :name if index_exists?(:social_media_services, :name) | ||
add_index :social_media_services, :name, unique: true | ||
|
||
remove_index :specialist_sectors, :topic_content_id if index_exists?(:specialist_sectors, :topic_content_id) | ||
add_index :specialist_sectors, :topic_content_id, uniqueness: { scope: :edition_id } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters