Browse Source

Fix migrace s vysledkovkami views

remotes/origin/feincms
Tomas Gavenciak 10 years ago
parent
commit
e9d4af35f6
  1. 16
      seminar/migrations/0002_add_body_views.py

16
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):

Loading…
Cancel
Save