aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/downgrade_0063---0062.sql8
-rw-r--r--db/downgrade_0064---0063.sql7
-rw-r--r--db/downgrade_0065---0064.sql14
-rw-r--r--db/downgrade_0066---0065.sql8
-rwxr-xr-xdb/rerun_dbic_loader.pl2
-rw-r--r--db/schema.sql13
-rw-r--r--db/schema_0063-add-extra-to-moderation.sql9
-rw-r--r--db/schema_0064-allow-multiple-moderations.sql8
-rw-r--r--db/schema_0065-add-moderation-admin-log.sql13
-rw-r--r--db/schema_0066-user-area-ids.sql7
10 files changed, 85 insertions, 4 deletions
diff --git a/db/downgrade_0063---0062.sql b/db/downgrade_0063---0062.sql
new file mode 100644
index 000000000..0f875e3e4
--- /dev/null
+++ b/db/downgrade_0063---0062.sql
@@ -0,0 +1,8 @@
+BEGIN;
+
+ALTER TABLE moderation_original_data DROP extra;
+ALTER TABLE moderation_original_data DROP latitude;
+ALTER TABLE moderation_original_data DROP longitude;
+ALTER TABLE moderation_original_data DROP category;
+
+COMMIT;
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/downgrade_0066---0065.sql b/db/downgrade_0066---0065.sql
new file mode 100644
index 000000000..7c2b14660
--- /dev/null
+++ b/db/downgrade_0066---0065.sql
@@ -0,0 +1,8 @@
+BEGIN;
+
+ALTER TABLE users ADD COLUMN area_id integer;
+UPDATE users SET area_id = area_ids[1];
+ALTER TABLE users DROP COLUMN area_ids;
+
+COMMIT;
+
diff --git a/db/rerun_dbic_loader.pl b/db/rerun_dbic_loader.pl
index cf6e89ab2..1eff12d9e 100755
--- a/db/rerun_dbic_loader.pl
+++ b/db/rerun_dbic_loader.pl
@@ -38,7 +38,7 @@ make_schema_at(
resultset_namespace => '+FixMyStreet::DB::ResultSet',
# add in some extra components
- components => [ 'FilterColumn', 'InflateColumn::DateTime', 'EncodedColumn' ],
+ components => [ 'FilterColumn', 'FixMyStreet::InflateColumn::DateTime', 'FixMyStreet::EncodedColumn' ],
},
[ FixMyStreet->dbic_connect_info ],
diff --git a/db/schema.sql b/db/schema.sql
index 30f5d3a30..98005028c 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -35,7 +35,7 @@ create table users (
title text,
twitter_id bigint unique,
facebook_id bigint unique,
- area_id integer,
+ area_ids integer ARRAY,
extra text
);
CREATE UNIQUE INDEX users_email_verified_unique ON users (email) WHERE email_verified;
@@ -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
@@ -449,8 +450,14 @@ create table moderation_original_data (
anonymous bool not null,
-- Metadata
- created timestamp not null default current_timestamp
+ created timestamp not null default current_timestamp,
+
+ extra text,
+ category text,
+ 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_0063-add-extra-to-moderation.sql b/db/schema_0063-add-extra-to-moderation.sql
new file mode 100644
index 000000000..9d003f895
--- /dev/null
+++ b/db/schema_0063-add-extra-to-moderation.sql
@@ -0,0 +1,9 @@
+BEGIN;
+
+ALTER TABLE moderation_original_data ADD extra text;
+ALTER TABLE moderation_original_data ADD category text;
+ALTER TABLE moderation_original_data ADD latitude double precision;
+ALTER TABLE moderation_original_data ADD longitude double precision;
+
+COMMIT;
+
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;
+
diff --git a/db/schema_0066-user-area-ids.sql b/db/schema_0066-user-area-ids.sql
new file mode 100644
index 000000000..53ffc31f0
--- /dev/null
+++ b/db/schema_0066-user-area-ids.sql
@@ -0,0 +1,7 @@
+BEGIN;
+
+ALTER TABLE users ADD COLUMN area_ids integer ARRAY;
+UPDATE users SET area_ids = ARRAY[area_id] WHERE area_id IS NOT NULL;
+ALTER TABLE users DROP COLUMN area_id;
+
+COMMIT;