]> git.openstreetmap.org Git - rails.git/blob - db/migrate/20161002153425_add_join_table_between_users_and_diary_entries.rb
Merge pull request #5060 from tomhughes/rake-expiry
[rails.git] / db / migrate / 20161002153425_add_join_table_between_users_and_diary_entries.rb
1 class AddJoinTableBetweenUsersAndDiaryEntries < ActiveRecord::Migration[4.2]
2   def self.up
3     create_table :diary_entry_subscriptions, :id => false do |t|
4       t.column :user_id, :bigint, :null => false
5       t.column :diary_entry_id, :bigint, :null => false
6     end
7
8     add_primary_key :diary_entry_subscriptions, [:user_id, :diary_entry_id]
9     add_index :diary_entry_subscriptions, [:diary_entry_id]
10     add_foreign_key :diary_entry_subscriptions, :diary_entries, :name => "diary_entry_subscriptions_diary_entry_id_fkey"
11     add_foreign_key :diary_entry_subscriptions, :users, :name => "diary_entry_subscriptions_user_id_fkey"
12   end
13
14   def self.down
15     drop_table :diary_entry_subscriptions
16   end
17 end