Skip to content

Instantly share code, notes, and snippets.

@RNDcpp
Last active January 24, 2020 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RNDcpp/ca037ed4309098b0561f98ca877d7b55 to your computer and use it in GitHub Desktop.
Save RNDcpp/ca037ed4309098b0561f98ca877d7b55 to your computer and use it in GitHub Desktop.
class CreateRecommendations < ActiveRecord::Migration[5.2]
def change
- create_table :recommendations do |t|
+ create_table :recommendations, id: false do |t| # idの代わりにuidを使う
- t.bigint :uid
+ t.bigint :uid, null: false, unique: true
- t.blob :recommended_id_list
+ t.blob :recommended_id_list, null: false
- t.timestamps
+ t.datetime :updated_at, null: false # created_atは不要
end
end
- add_index :recommendations, :uid
+ add_index :recommendations, :uid, unique: true
+ add_index :recommendations, :updated_at, unique: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment