diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-08-28 10:45:20 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-08-28 10:45:20 +0100 |
commit | ee723d9e6645bc7987cb2b7cc9cd320950536201 (patch) | |
tree | f5beec1ffc37c9530485c0cd5be15c56210ae2da /db | |
parent | e98bfd6e9ed7e6bb151d0eb5c216cad0fed6a40c (diff) | |
parent | 5c1a88c88ba69cec3924ec8a1d69d8784acaef3c (diff) |
Merge branch 'release/0.6.4'0.6.4
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/113_add_external_fields_to_info_requests.rb | 1 | ||||
-rw-r--r-- | db/migrate/20120822145640_correct_external_request_constraint.rb | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/db/migrate/113_add_external_fields_to_info_requests.rb b/db/migrate/113_add_external_fields_to_info_requests.rb index 3aea57766..1ad7634ff 100644 --- a/db/migrate/113_add_external_fields_to_info_requests.rb +++ b/db/migrate/113_add_external_fields_to_info_requests.rb @@ -4,6 +4,7 @@ class AddExternalFieldsToInfoRequests < ActiveRecord::Migration add_column :info_requests, :external_user_name, :string, :null => true add_column :info_requests, :external_url, :string, :null => true + # NB This is corrected in 20120822145640 if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" execute "ALTER TABLE info_requests ADD CONSTRAINT info_requests_external_ck CHECK ( (user_id is null) = (external_url is not null) and (external_user_name is not null or external_url is null) )" end diff --git a/db/migrate/20120822145640_correct_external_request_constraint.rb b/db/migrate/20120822145640_correct_external_request_constraint.rb new file mode 100644 index 000000000..6902f3cb2 --- /dev/null +++ b/db/migrate/20120822145640_correct_external_request_constraint.rb @@ -0,0 +1,15 @@ +class CorrectExternalRequestConstraint < ActiveRecord::Migration + def self.up + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + execute "ALTER TABLE info_requests DROP CONSTRAINT info_requests_external_ck" + execute "ALTER TABLE info_requests ADD CONSTRAINT info_requests_external_ck CHECK ( (user_id is null) = (external_url is not null) and (external_url is not null or external_user_name is null) )" + end + end + + def self.down + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + execute "ALTER TABLE info_requests DROP CONSTRAINT info_requests_external_ck" + execute "ALTER TABLE info_requests ADD CONSTRAINT info_requests_external_ck CHECK ( (user_id is null) = (external_url is not null) and (external_user_name is not null or external_url is null) )" + end + end +end |