diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-08-22 16:07:11 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-08-22 16:07:11 +0100 |
commit | 1bc3f27ec2142e32be28e42545b19e540929f741 (patch) | |
tree | a6cc8d89dcaf1a88a1772c7401a5217e3ab23b20 | |
parent | 5671f2b85100e6abf99772a02f0dc9385b345ced (diff) | |
parent | 1fc5f2fd6208cb8009e46840601798c79aa7d90f (diff) |
Merge branch 'develop' of github.com:sebbacon/alaveteli into develop
-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 |