aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-08-22 16:27:32 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-31 15:37:09 +0100
commit27110ac506f071ad0c5925ef74de1321514c23c8 (patch)
tree61699c019d14a0b6abf4db20734b93f7c09d6093 /db
parentb43813d8f3c5bae07f0c7b9fe120bff32611d8bb (diff)
Remove hardcoded states from Problem model.
We keep the internal states hardcoded, plus the core open (confirmed) and closed ones, but the remainder are moved to the database.
Diffstat (limited to 'db')
-rw-r--r--db/fixture.sql (renamed from db/alert_types.sql)10
-rw-r--r--db/schema.sql2
-rw-r--r--db/schema_0054-add-state-table.sql12
3 files changed, 22 insertions, 2 deletions
diff --git a/db/alert_types.sql b/db/fixture.sql
index 84f446f2c..840906223 100644
--- a/db/alert_types.sql
+++ b/db/fixture.sql
@@ -1,3 +1,13 @@
+INSERT INTO state (label, type, name) VALUES ('investigating', 'open', 'Investigating');
+INSERT INTO state (label, type, name) VALUES ('in progress', 'open', 'In progress');
+INSERT INTO state (label, type, name) VALUES ('planned', 'open', 'Planned');
+INSERT INTO state (label, type, name) VALUES ('action scheduled', 'open', 'Action scheduled');
+INSERT INTO state (label, type, name) VALUES ('unable to fix', 'closed', 'No further action');
+INSERT INTO state (label, type, name) VALUES ('not responsible', 'closed', 'Not responsible');
+INSERT INTO state (label, type, name) VALUES ('duplicate', 'closed', 'Duplicate');
+INSERT INTO state (label, type, name) VALUES ('internal referral', 'closed', 'Internal referral');
+INSERT INTO state (label, type, name) VALUES ('fixed', 'fixed', 'Fixed');
+
-- New updates on a particular problem report
insert into alert_type
(ref, head_sql_query, head_table,
diff --git a/db/schema.sql b/db/schema.sql
index 12e66b53a..fedab2b9d 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -519,6 +519,6 @@ CREATE TABLE report_extra_fields (
CREATE TABLE state (
id serial not null primary key,
label text not null unique,
- type text not null check (type = 'open' OR type = 'closed'),
+ type text not null check (type = 'open' OR type = 'closed' OR type = 'fixed'),
name text not null unique
);
diff --git a/db/schema_0054-add-state-table.sql b/db/schema_0054-add-state-table.sql
index c052f145a..c4be36015 100644
--- a/db/schema_0054-add-state-table.sql
+++ b/db/schema_0054-add-state-table.sql
@@ -3,10 +3,20 @@ BEGIN;
CREATE TABLE state (
id serial not null primary key,
label text not null unique,
- type text not null check (type = 'open' OR type = 'closed'),
+ type text not null check (type = 'open' OR type = 'closed' OR type = 'fixed'),
name text not null unique
);
+INSERT INTO state (label, type, name) VALUES ('investigating', 'open', 'Investigating');
+INSERT INTO state (label, type, name) VALUES ('in progress', 'open', 'In progress');
+INSERT INTO state (label, type, name) VALUES ('planned', 'open', 'Planned');
+INSERT INTO state (label, type, name) VALUES ('action scheduled', 'open', 'Action scheduled');
+INSERT INTO state (label, type, name) VALUES ('unable to fix', 'closed', 'No further action');
+INSERT INTO state (label, type, name) VALUES ('not responsible', 'closed', 'Not responsible');
+INSERT INTO state (label, type, name) VALUES ('duplicate', 'closed', 'Duplicate');
+INSERT INTO state (label, type, name) VALUES ('internal referral', 'closed', 'Internal referral');
+INSERT INTO state (label, type, name) VALUES ('fixed', 'fixed', 'Fixed');
+
ALTER TABLE problem DROP CONSTRAINT problem_state_check;
ALTER TABLE comment DROP CONSTRAINT comment_problem_state_check;