aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate/20140528110536_update_track_things_index.rb
blob: 209beecce7090bc3db64fcbeea0e7f7013e773c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- encoding : utf-8 -*-
class UpdateTrackThingsIndex < ActiveRecord::Migration

  def up
      if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
          execute "ALTER TABLE track_things_sent_emails DROP CONSTRAINT fk_track_request_public_body"
          execute "ALTER TABLE track_things_sent_emails ADD CONSTRAINT fk_track_request_public_body FOREIGN KEY (public_body_id) REFERENCES public_bodies(id)"
      end
  end

  def down
      if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
          execute "ALTER TABLE track_things_sent_emails DROP CONSTRAINT fk_track_request_public_body"
          execute "ALTER TABLE track_things_sent_emails ADD CONSTRAINT fk_track_request_public_body FOREIGN KEY (user_id) REFERENCES users(id)"
      end
  end

end