]> git.openstreetmap.org Git - rails.git/blob - db/migrate/20140519141742_add_join_table_between_users_and_changesets.rb
Avoid relying on the order in which emails are sent
[rails.git] / db / migrate / 20140519141742_add_join_table_between_users_and_changesets.rb
1 require "migrate"
2
3 class AddJoinTableBetweenUsersAndChangesets < ActiveRecord::Migration
4   def change
5     create_table :changesets_subscribers, :id => false do |t|
6       t.column :subscriber_id, :bigint, :null => false
7       t.column :changeset_id, :bigint, :null => false
8     end
9
10     add_foreign_key :changesets_subscribers, :users, :column => :subscriber_id, :name => "changesets_subscribers_subscriber_id_fkey"
11     add_foreign_key :changesets_subscribers, :changesets, :name => "changesets_subscribers_changeset_id_fkey"
12
13     add_index :changesets_subscribers, [:subscriber_id, :changeset_id], :unique => true
14     add_index :changesets_subscribers, [:changeset_id]
15   end
16 end