up: makes polymorphic column type smaller

main
Washington Botelho 2018-03-27 18:00:56 -03:00
parent 99c1a1fff6
commit f2f31a5f49
No known key found for this signature in database
GPG Key ID: 5DE4F42A8F073617
2 changed files with 8 additions and 1 deletions

View File

@ -7,11 +7,15 @@ class CreateRateTable < ActiveRecord::Migration[5.0]
t.references :author, index: true, null: false, polymorphic: true t.references :author, index: true, null: false, polymorphic: true
t.references :resource, index: true, null: false, polymorphic: true t.references :resource, index: true, null: false, polymorphic: true
t.references :scopeable, index: true, null: true, polymorphic: true t.references :scopeable, index: true, null: true, polymorphic: true
t.timestamps null: false t.timestamps null: false
end end
change_column :rating_rates, :author_type, :string, limit: 10
change_column :rating_rates, :resource_type, :string, limit: 10
change_column :rating_rates, :scopeable_type, :string, limit: 10
add_index :rating_rates, %i[author_type author_id resource_type resource_id scopeable_type scopeable_id], add_index :rating_rates, %i[author_type author_id resource_type resource_id scopeable_type scopeable_id],
name: :index_rating_rates_on_author_and_resource_and_scopeable, name: :index_rating_rates_on_author_and_resource_and_scopeable,
unique: true unique: true

View File

@ -14,6 +14,9 @@ class CreateRatingTable < ActiveRecord::Migration[5.0]
t.timestamps null: false t.timestamps null: false
end end
change_column :rating_ratings, :resource_type, :string, limit: 10
change_column :rating_ratings, :scopeable_type, :string, limit: 10
add_index :rating_ratings, %i[resource_type resource_id scopeable_type scopeable_id], add_index :rating_ratings, %i[resource_type resource_id scopeable_type scopeable_id],
name: :index_rating_rating_on_resource_and_scopeable, name: :index_rating_rating_on_resource_and_scopeable,
unique: true unique: true