From e9d4af35f610cc07f9798e8098774700e53bac05 Mon Sep 17 00:00:00 2001 From: Tomas Gavenciak Date: Fri, 15 May 2015 00:48:31 +0200 Subject: [PATCH] Fix migrace s vysledkovkami views --- seminar/migrations/0002_add_body_views.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/seminar/migrations/0002_add_body_views.py b/seminar/migrations/0002_add_body_views.py index d146419d..3d128ab9 100644 --- a/seminar/migrations/0002_add_body_views.py +++ b/seminar/migrations/0002_add_body_views.py @@ -10,7 +10,7 @@ from django.conf import settings CREATE_VIEWS=""" create view seminar_body_za_cislo as select - sr.cislo_body_id || "-" || sr.resitel_id as id, + sr.cislo_body_id || '-' || sr.resitel_id as id, sr.cislo_body_id as cislo_id, sr.resitel_id as resitel_id, sum(sr.body) as body @@ -20,22 +20,22 @@ create view seminar_body_za_cislo as create view seminar_body_k_cislu as select - akt_c.id || "-" || min_bzc.resitel_id as id, + akt_c.id || '-' || min_bzc.resitel_id as id, akt_c.id as cislo_id, min_bzc.resitel_id as resitel_id, - akt_bzc.body as body, + max(akt_bzc.body) as body, sum(min_bzc.body) as body_celkem from ((seminar_cisla as akt_c - inner join seminar_cisla as min_c on min_c.rocnik_id == akt_c.rocnik_id and akt_c.cislo >= min_c.cislo) - inner join seminar_body_za_cislo as min_bzc on min_c.id == min_bzc.cislo_id) - left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id == akt_c.id and akt_bzc.resitel_id == min_bzc.resitel_id - group by akt_c.id, min_bzc.resitel_id + inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo) + inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id) + left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id + group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id order by body_celkem desc; """ DROP_VIEWS=""" +drop view seminar_body_k_cislu; drop view seminar_body_za_cislo; -drop view seminar_body_do_cisla; """ class Migration(migrations.Migration):