From 361990d4409ccda79e9f0cf166a505eefeac4495 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 20 May 2015 10:25:16 +0100 Subject: Allow underscore in cobrand name/data in database. --- db/schema.sql | 12 ++++++------ db/schema_0032-moderation.sql | 4 ++++ db/schema_0036-add-underscore-to-cobrand.sql | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 db/schema_0036-add-underscore-to-cobrand.sql (limited to 'db') 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; -- cgit v1.2.3