2023-10-19 16:37:34 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-04-19 09:10:31 -07:00
|
|
|
class CreateCommentSmiles < ActiveRecord::Migration[4.2]
|
2015-05-03 18:39:41 -07:00
|
|
|
def change
|
|
|
|
create_table :comment_smiles do |t|
|
|
|
|
t.integer :user_id
|
|
|
|
t.integer :comment_id
|
|
|
|
|
|
|
|
t.timestamps null: false
|
|
|
|
end
|
|
|
|
|
|
|
|
add_index :comment_smiles, :user_id
|
|
|
|
add_index :comment_smiles, :comment_id
|
2023-10-19 16:37:34 -07:00
|
|
|
add_index :comment_smiles, %i[user_id comment_id], unique: true
|
2015-05-03 18:39:41 -07:00
|
|
|
|
|
|
|
add_column :users, :comment_smiled_count, :integer, default: 0, null: false
|
|
|
|
add_column :comments, :smile_count, :integer, default: 0, null: false
|
|
|
|
end
|
|
|
|
end
|