aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-07-15 17:02:56 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-08-09 14:44:07 +0100
commit0c31945416238d7eb06543c107214adfd4b83734 (patch)
tree1365a012bb5e2bd19e84d827afd2878ae16f7433 /db
parent0cecc6857351bfe9a80240a8c0910debd9f8dbe9 (diff)
Remove check constraint on user body permissions.
We'll soon be adding more new permission types.
Diffstat (limited to 'db')
-rw-r--r--db/downgrade_0041---0040.sql9
-rw-r--r--db/schema.sql6
-rw-r--r--db/schema_0041-remove-permission-types-check.sql4
3 files changed, 14 insertions, 5 deletions
diff --git a/db/downgrade_0041---0040.sql b/db/downgrade_0041---0040.sql
new file mode 100644
index 000000000..13bf083e8
--- /dev/null
+++ b/db/downgrade_0041---0040.sql
@@ -0,0 +1,9 @@
+begin;
+ALTER TABLE user_body_permissions
+ADD CONSTRAINT user_body_permissions_permission_type_check
+CHECK (
+ permission_type='moderate' or
+ -- for future expansion --
+ permission_type='admin'
+);
+commit;
diff --git a/db/schema.sql b/db/schema.sql
index 3f73d2325..f285922ac 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -454,11 +454,7 @@ create table user_body_permissions (
id serial not null primary key,
user_id int references users(id) not null,
body_id int references body(id) not null,
- permission_type text not null check(
- permission_type='moderate' or
- -- for future expansion --
- permission_type='admin'
- ),
+ permission_type text not null,
unique(user_id, body_id, permission_type)
);
diff --git a/db/schema_0041-remove-permission-types-check.sql b/db/schema_0041-remove-permission-types-check.sql
new file mode 100644
index 000000000..2e4c21050
--- /dev/null
+++ b/db/schema_0041-remove-permission-types-check.sql
@@ -0,0 +1,4 @@
+BEGIN;
+ALTER TABLE user_body_permissions
+DROP CONSTRAINT user_body_permissions_permission_type_check;
+COMMIT;