]> git.openstreetmap.org Git - rails.git/blob - db/migrate/20161002153425_add_join_table_between_users_and_diary_entries.rb
Refactor client application pages to use bootstrap forms
[rails.git] / db / migrate / 20161002153425_add_join_table_between_users_and_diary_entries.rb
1 require "migrate"
2
3 class AddJoinTableBetweenUsersAndDiaryEntries < ActiveRecord::Migration[4.2]
4   def self.up
5     create_table :diary_entry_subscriptions, :id => false do |t|
6       t.column :user_id, :bigint, :null => false
7       t.column :diary_entry_id, :bigint, :null => false
8     end
9
10     add_primary_key :diary_entry_subscriptions, [:user_id, :diary_entry_id]
11     add_index :diary_entry_subscriptions, [:diary_entry_id]
12     add_foreign_key :diary_entry_subscriptions, :diary_entries, :name => "diary_entry_subscriptions_diary_entry_id_fkey"
13     add_foreign_key :diary_entry_subscriptions, :users, :name => "diary_entry_subscriptions_user_id_fkey"
14   end
15
16   def self.down
17     drop_table :diary_entry_subscriptions
18   end
19 end