aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-05-20 10:25:16 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-09-29 16:46:53 +0100
commit361990d4409ccda79e9f0cf166a505eefeac4495 (patch)
tree6fea825e1ce4e43b314d5b8b83c73d4c052116bd /db
parent1dd68c2f6fed08b90fdaea8efd8c6bcf0399b8d8 (diff)
Allow underscore in cobrand name/data in database.
Diffstat (limited to 'db')
-rw-r--r--db/schema.sql12
-rw-r--r--db/schema_0032-moderation.sql4
-rw-r--r--db/schema_0036-add-underscore-to-cobrand.sql17
3 files changed, 27 insertions, 6 deletions
diff --git a/db/schema.sql b/db/schema.sql
index ea2698b0e..2db89bddb 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -173,8 +173,8 @@ create table problem (
),
lang text not null default 'en-gb',
service text not null default '',
- cobrand text not null default '' check (cobrand ~* '^[a-z0-9]*$'),
- cobrand_data text not null default '' check (cobrand_data ~* '^[a-z0-9]*$'), -- Extra data used in cobranded versions of the site
+ cobrand text not null default '' check (cobrand ~* '^[a-z0-9_]*$'),
+ cobrand_data text not null default '' check (cobrand_data ~* '^[a-z0-9_]*$'), -- Extra data used in cobranded versions of the site
lastupdate timestamp not null default current_timestamp,
whensent timestamp,
send_questionnaire boolean not null default 't',
@@ -297,9 +297,9 @@ create table comment (
or state = 'confirmed'
or state = 'hidden'
),
- cobrand text not null default '' check (cobrand ~* '^[a-z0-9]*$'),
+ cobrand text not null default '' check (cobrand ~* '^[a-z0-9_]*$'),
lang text not null default 'en-gb',
- cobrand_data text not null default '' check (cobrand_data ~* '^[a-z0-9]*$'), -- Extra data used in cobranded versions of the site
+ cobrand_data text not null default '' check (cobrand_data ~* '^[a-z0-9_]*$'), -- Extra data used in cobranded versions of the site
mark_fixed boolean not null,
mark_open boolean not null default 'f',
problem_state text check (
@@ -366,8 +366,8 @@ create table alert (
user_id int references users(id) not null,
confirmed integer not null default 0,
lang text not null default 'en-gb',
- cobrand text not null default '' check (cobrand ~* '^[a-z0-9]*$'),
- cobrand_data text not null default '' check (cobrand_data ~* '^[a-z0-9]*$'), -- Extra data used in cobranded versions of the site
+ cobrand text not null default '' check (cobrand ~* '^[a-z0-9_]*$'),
+ cobrand_data text not null default '' check (cobrand_data ~* '^[a-z0-9_]*$'), -- Extra data used in cobranded versions of the site
whensubscribed timestamp not null default current_timestamp,
whendisabled timestamp default null
);
diff --git a/db/schema_0032-moderation.sql b/db/schema_0032-moderation.sql
index b3caded1e..79be3a4c9 100644
--- a/db/schema_0032-moderation.sql
+++ b/db/schema_0032-moderation.sql
@@ -1,6 +1,8 @@
-- was created in previous versions of this branch
DROP TABLE IF EXISTS moderation_log;
+BEGIN;
+
alter table admin_log add column
user_id int references users(id) null;
@@ -34,3 +36,5 @@ create table user_body_permissions (
),
unique(user_id, body_id, permission_type)
);
+
+COMMIT;
diff --git a/db/schema_0036-add-underscore-to-cobrand.sql b/db/schema_0036-add-underscore-to-cobrand.sql
new file mode 100644
index 000000000..7bc381e8e
--- /dev/null
+++ b/db/schema_0036-add-underscore-to-cobrand.sql
@@ -0,0 +1,17 @@
+BEGIN;
+
+ALTER TABLE problem DROP CONSTRAINT problem_cobrand_check;
+ALTER TABLE problem DROP CONSTRAINT problem_cobrand_data_check;
+ALTER TABLE comment DROP CONSTRAINT comment_cobrand_check;
+ALTER TABLE comment DROP CONSTRAINT comment_cobrand_data_check;
+ALTER TABLE alert DROP CONSTRAINT alert_cobrand_check;
+ALTER TABLE alert DROP CONSTRAINT alert_cobrand_data_check;
+
+ALTER TABLE problem ADD CONSTRAINT problem_cobrand_check CHECK (cobrand ~* '^[a-z0-9_]*$');
+ALTER TABLE problem ADD CONSTRAINT problem_cobrand_data_check CHECK (cobrand_data ~* '^[a-z0-9_]*$');
+ALTER TABLE comment ADD CONSTRAINT comment_cobrand_check CHECK (cobrand ~* '^[a-z0-9_]*$');
+ALTER TABLE comment ADD CONSTRAINT comment_cobrand_data_check CHECK (cobrand_data ~* '^[a-z0-9_]*$');
+ALTER TABLE alert ADD CONSTRAINT alert_cobrand_check CHECK (cobrand ~* '^[a-z0-9_]*$');
+ALTER TABLE alert ADD CONSTRAINT alert_cobrand_data_check CHECK (cobrand_data ~* '^[a-z0-9_]*$');
+
+COMMIT;