From c306e395133893f67fe15e84cd69280cdd62b81d Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Tue, 27 Mar 2018 17:47:48 -0300 Subject: [PATCH] up: uses index in the same order as rails query --- lib/generators/rating/templates/db/migrate/create_rate_table.rb | 2 +- .../rating/templates/db/migrate/create_rating_table.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 d98a5da..ae8336f 100644 --- a/lib/generators/rating/templates/db/migrate/create_rate_table.rb +++ b/lib/generators/rating/templates/db/migrate/create_rate_table.rb @@ -12,7 +12,7 @@ class CreateRateTable < ActiveRecord::Migration[5.0] t.timestamps null: false end - add_index :rating_rates, %i[author_id author_type resource_id resource_type scopeable_id scopeable_type], + 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 end 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 a1d34b3..d927dd4 100644 --- a/lib/generators/rating/templates/db/migrate/create_rating_table.rb +++ b/lib/generators/rating/templates/db/migrate/create_rating_table.rb @@ -14,7 +14,7 @@ class CreateRatingTable < ActiveRecord::Migration[5.0] t.timestamps null: false end - add_index :rating_ratings, %i[resource_id resource_type scopeable_id scopeable_type], + add_index :rating_ratings, %i[resource_type resource_id scopeable_type scopeable_id], name: :index_rating_rating_on_resource_and_scopeable, unique: true end