aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-08-23 17:28:11 +0100
committerDave Arter <davea@mysociety.org>2016-09-08 09:45:58 +0100
commit1444841970096122c9aeb5e86c82bede01b1bee6 (patch)
tree79b96fda21ce35037d05065644a1043077bf1717 /db
parent80a01c11f656f19d6df4c2e4294f613db14689b1 (diff)
Extend response templates to work across all cobrands
This builds on the response templates in the Zürich cobrand: - Allow response templates to be assigned to categories - Also adds a auto_response flag, which will be used to automatically create updates when reports are made. - Include response templates select box on update form For mysociety/fixmystreetforcouncils#31
Diffstat (limited to 'db')
-rw-r--r--db/downgrade_0044---0043.sql7
-rw-r--r--db/schema.sql7
-rw-r--r--db/schema_0044-contact_response_templates.sql12
3 files changed, 26 insertions, 0 deletions
diff --git a/db/downgrade_0044---0043.sql b/db/downgrade_0044---0043.sql
new file mode 100644
index 000000000..d3a7642ad
--- /dev/null
+++ b/db/downgrade_0044---0043.sql
@@ -0,0 +1,7 @@
+BEGIN;
+
+ALTER TABLE response_templates DROP COLUMN auto_response;
+
+DROP TABLE contact_response_templates;
+
+COMMIT;
diff --git a/db/schema.sql b/db/schema.sql
index b11bb30b7..c96059fb1 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -473,5 +473,12 @@ create table response_templates (
title text not null,
text text not null,
created timestamp not null default current_timestamp,
+ auto_response boolean NOT NULL DEFAULT 'f',
unique(body_id, title)
);
+
+CREATE TABLE contact_response_templates (
+ id serial NOT NULL PRIMARY KEY,
+ contact_id int REFERENCES contacts(id) NOT NULL,
+ response_template_id int REFERENCES response_templates(id) NOT NULL
+);
diff --git a/db/schema_0044-contact_response_templates.sql b/db/schema_0044-contact_response_templates.sql
new file mode 100644
index 000000000..e85d99fb8
--- /dev/null
+++ b/db/schema_0044-contact_response_templates.sql
@@ -0,0 +1,12 @@
+BEGIN;
+
+CREATE TABLE contact_response_templates (
+ id serial NOT NULL PRIMARY KEY,
+ contact_id int REFERENCES contacts(id) NOT NULL,
+ response_template_id int REFERENCES response_templates(id) NOT NULL
+);
+
+ALTER TABLE response_templates
+ ADD COLUMN auto_response boolean NOT NULL DEFAULT 'f';
+
+COMMIT;