-
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 27755e2
Showing
2 changed files
with
40 additions
and
1 deletion.
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, %i(classification_id related_classification_id) if index_exists?(:classification_relations, %i(classification_id related_classification_id)) | ||
add_index :classification_relations, %i(classification_id related_classification_id), unique: true, name: "index_classification_relations_on_id_and_related_id" | ||
|
||
remove_index :document_collection_groups, %i(heading document_collection_id) if index_exists?(:document_collection_groups, %i(heading document_collection_id)) | ||
add_index :document_collection_groups, %i(heading document_collection_id), unique: true, name: "index_doc_collection_groups_on_heading_and_doc_collection_id" | ||
|
||
remove_index :edition_relations, %i(document_id edition_id) if index_exists?(:edition_relations, %i(document_id edition_id)) | ||
add_index :edition_relations, %i(document_id edition_id), unique: true | ||
|
||
remove_index :operational_fields, :name if index_exists?(:operational_fields, :name) | ||
add_index :operational_fields, :name, unique: true | ||
|
||
remove_index :related_mainstreams, %i(content_id edition_id) if index_exists?(:related_mainstreams, %i(content_id edition_id)) | ||
add_index :related_mainstreams, %i(content_id edition_id), unique: true | ||
|
||
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, %i(topic_content_id edition_id) if index_exists?(:specialist_sectors, %i(topic_content_id edition_id)) | ||
add_index :specialist_sectors, %i(topic_content_id edition_id), unique: true | ||
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