diff --git a/lib/generators/rating/templates/db/migrate/create_rate_table.rb b/lib/generators/rating/templates/db/migrate/create_rate_table.rb index ae8336f..7d5dcc8 100644 --- a/lib/generators/rating/templates/db/migrate/create_rate_table.rb +++ b/lib/generators/rating/templates/db/migrate/create_rate_table.rb @@ -7,11 +7,15 @@ class CreateRateTable < ActiveRecord::Migration[5.0] t.references :author, 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 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], name: :index_rating_rates_on_author_and_resource_and_scopeable, unique: true diff --git a/lib/generators/rating/templates/db/migrate/create_rating_table.rb b/lib/generators/rating/templates/db/migrate/create_rating_table.rb index d927dd4..9afe1b0 100644 --- a/lib/generators/rating/templates/db/migrate/create_rating_table.rb +++ b/lib/generators/rating/templates/db/migrate/create_rating_table.rb @@ -14,6 +14,9 @@ class CreateRatingTable < ActiveRecord::Migration[5.0] t.timestamps null: false 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], name: :index_rating_rating_on_resource_and_scopeable, unique: true