diff options
| author | Gareth Rees <gareth@mysociety.org> | 2014-05-28 11:09:56 +0100 |
|---|---|---|
| committer | Gareth Rees <gareth@mysociety.org> | 2014-05-28 11:34:29 +0100 |
| commit | d31e0ffe49ea20a5bffc73751e9539fd0b431e95 (patch) | |
| tree | 76a3b21cba85ec37f99a2e11a9d2ae9f8d5ee6c0 /db | |
| parent | e7e777aa044ed210578863fb7329644750820c37 (diff) | |
Define track things constraint correctly
> The constraint fk_track_request_public_body on
> track_things_sent_emails is defined incorrectly, referring to user_id
> rather than public_body_id.
Via Robin Houston
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/20140528110536_update_track_things_index.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20140528110536_update_track_things_index.rb b/db/migrate/20140528110536_update_track_things_index.rb new file mode 100644 index 000000000..55ee0b70b --- /dev/null +++ b/db/migrate/20140528110536_update_track_things_index.rb @@ -0,0 +1,17 @@ +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 |
