diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/downgrade_0064---0063.sql | 7 | ||||
-rw-r--r-- | db/downgrade_0065---0064.sql | 14 | ||||
-rw-r--r-- | db/schema.sql | 4 | ||||
-rw-r--r-- | db/schema_0064-allow-multiple-moderations.sql | 8 | ||||
-rw-r--r-- | db/schema_0065-add-moderation-admin-log.sql | 13 |
5 files changed, 45 insertions, 1 deletions
diff --git a/db/downgrade_0064---0063.sql b/db/downgrade_0064---0063.sql new file mode 100644 index 000000000..7cce67680 --- /dev/null +++ b/db/downgrade_0064---0063.sql @@ -0,0 +1,7 @@ +BEGIN; + +DROP INDEX moderation_original_data_problem_id_comment_id_idx; +ALTER TABLE moderation_original_data + ADD CONSTRAINT moderation_original_data_comment_id_key UNIQUE (comment_id); + +COMMIT; diff --git a/db/downgrade_0065---0064.sql b/db/downgrade_0065---0064.sql new file mode 100644 index 000000000..455627b77 --- /dev/null +++ b/db/downgrade_0065---0064.sql @@ -0,0 +1,14 @@ +BEGIN; + +DELETE FROM admin_log WHERE object_type = 'moderation'; + +ALTER TABLE admin_log DROP CONSTRAINT admin_log_object_type_check; + +ALTER TABLE admin_log ADD CONSTRAINT admin_log_object_type_check CHECK ( + object_type = 'problem' + OR object_type = 'update' + OR object_type = 'user' +); + +COMMIT; + diff --git a/db/schema.sql b/db/schema.sql index a448e05fa..c97e8d585 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -427,6 +427,7 @@ create table admin_log ( object_type = 'problem' or object_type = 'update' or object_type = 'user' + or object_type = 'moderation' ), object_id integer not null, action text not null, @@ -441,7 +442,7 @@ create table moderation_original_data ( -- Problem details problem_id int references problem(id) ON DELETE CASCADE not null, - comment_id int references comment(id) ON DELETE CASCADE unique, + comment_id int references comment(id) ON DELETE CASCADE, title text null, detail text null, -- or text for comment @@ -456,6 +457,7 @@ create table moderation_original_data ( latitude double precision, longitude double precision ); +create index moderation_original_data_problem_id_comment_id_idx on moderation_original_data(problem_id, comment_id); create table user_body_permissions ( id serial not null primary key, diff --git a/db/schema_0064-allow-multiple-moderations.sql b/db/schema_0064-allow-multiple-moderations.sql new file mode 100644 index 000000000..5fee96282 --- /dev/null +++ b/db/schema_0064-allow-multiple-moderations.sql @@ -0,0 +1,8 @@ +BEGIN; + +ALTER TABLE moderation_original_data + DROP CONSTRAINT moderation_original_data_comment_id_key; +CREATE INDEX moderation_original_data_problem_id_comment_id_idx + ON moderation_original_data(problem_id, comment_id); + +COMMIT; diff --git a/db/schema_0065-add-moderation-admin-log.sql b/db/schema_0065-add-moderation-admin-log.sql new file mode 100644 index 000000000..9a5385db7 --- /dev/null +++ b/db/schema_0065-add-moderation-admin-log.sql @@ -0,0 +1,13 @@ +BEGIN; + +ALTER TABLE admin_log DROP CONSTRAINT admin_log_object_type_check; + +ALTER TABLE admin_log ADD CONSTRAINT admin_log_object_type_check CHECK ( + object_type = 'problem' + OR object_type = 'update' + OR object_type = 'user' + OR object_type = 'moderation' +); + +COMMIT; + |