summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_treatments.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-09 14:58:08 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-09 14:58:08 +0100
commit8e4d2ca13b65f48534ad0b36b1850b2ce8a20949 (patch)
treef68914a98937e74fa55db08dccea25671b11900b /archaeological_finds/models_treatments.py
parenta9304b80e3b4a69312ba1c988f1c9f170f332f43 (diff)
downloadIshtar-8e4d2ca13b65f48534ad0b36b1850b2ce8a20949.tar.bz2
Ishtar-8e4d2ca13b65f48534ad0b36b1850b2ce8a20949.zip
Fix finds migrations (error on views)
Diffstat (limited to 'archaeological_finds/models_treatments.py')
-rw-r--r--archaeological_finds/models_treatments.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 5e763085c..8fcda37c0 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -285,7 +285,7 @@ class AbsFindTreatments(models.Model):
class FindUpstreamTreatments(AbsFindTreatments):
- """
+ CREATE_SQL = """
CREATE VIEW find_uptreatments_tree AS
WITH RECURSIVE rel_tree AS (
SELECT id AS find_id, upstream_treatment_id, downstream_treatment_id,
@@ -316,6 +316,10 @@ class FindUpstreamTreatments(AbsFindTreatments):
CREATE RULE find_uptreatments_del AS ON DELETE TO find_uptreatments
DO INSTEAD DELETE FROM archaeological_finds_find where id=NULL;
"""
+ DELETE_SQL = """
+ DROP VIEW find_uptreatments;
+ DROP VIEW find_uptreatments_tree;
+ """
TABLE_COLS = ['treatment__treatment_type',
'treatment__upstream',
'treatment__start_date', 'treatment__end_date',
@@ -333,7 +337,7 @@ class FindUpstreamTreatments(AbsFindTreatments):
class FindDownstreamTreatments(AbsFindTreatments):
- """
+ CREATE_SQL = """
CREATE VIEW find_downtreatments_tree AS
WITH RECURSIVE rel_tree AS (
SELECT id AS find_id, downstream_treatment_id, upstream_treatment_id,
@@ -364,6 +368,10 @@ class FindDownstreamTreatments(AbsFindTreatments):
CREATE RULE find_downtreatments_del AS ON DELETE TO find_downtreatments
DO INSTEAD DELETE FROM archaeological_finds_find where id=NULL;
"""
+ DELETE_SQL = """
+ DROP VIEW find_downtreatments;
+ DROP VIEW find_downtreatments_tree;
+ """
TABLE_COLS = ['treatment__treatment_type',
'treatment__downstream',
'treatment__start_date', 'treatment__end_date',
@@ -381,7 +389,7 @@ class FindDownstreamTreatments(AbsFindTreatments):
class FindTreatments(AbsFindTreatments):
- """
+ CREATE_SQL = """
CREATE VIEW find_treatments AS
SELECT find_id, treatment_id, treatment_nb, TRUE as upstream
FROM find_uptreatments
@@ -394,6 +402,9 @@ class FindTreatments(AbsFindTreatments):
CREATE RULE find_treatments_del AS ON DELETE TO find_treatments
DO INSTEAD DELETE FROM archaeological_finds_find where id=NULL;
"""
+ DELETE_SQL = """
+ DROP VIEW find_treatments;
+ """
upstream = models.BooleanField(_(u"Is upstream"))
class Meta: