]> git.openstreetmap.org Git - rails.git/blob - db/migrate/20140519141742_add_join_table_between_users_and_changesets.rb
Merge branch 'master' into overpass
[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, [:subscriber_id], :users, [:id]
11     add_foreign_key :changesets_subscribers, [:changeset_id], :changesets, [:id]
12
13     add_index :changesets_subscribers, [:subscriber_id, :changeset_id], :unique => true
14     add_index :changesets_subscribers, [:changeset_id]
15   end
16 end