4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/generators/rating/templates/db/migrate/create_rating_table.rb', line 4
def change
create_table :rating_ratings do |t|
t.decimal :average, default: 0, null: false, precision: 12, scale: 8
t.decimal :estimate, default: 0, null: false, precision: 12, scale: 8
t.integer :sum, default: 0, null: false
t.integer :total, default: 0, null: false
t.references :resource, index: true, null: false, polymorphic: true
t.references :scopeable, index: true, null: true, polymorphic: true
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
end
|