# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2018-03-17 12:29 from __future__ import unicode_literals from django.db import migrations SQL_POLY = """CREATE OR REPLACE VIEW chimere_aggregated_polygons (id, subcategory_id, status, polygon) AS SELECT row_number() OVER ( ORDER BY "chimere_polygon_categories"."subcategory_id", "chimere_polygon"."status"), "chimere_polygon_categories"."subcategory_id", "chimere_polygon"."status", ST_Multi(ST_Collect("chimere_polygon"."polygon")) FROM "chimere_polygon" LEFT OUTER JOIN "chimere_polygon_categories" ON ( "chimere_polygon"."id" = "chimere_polygon_categories"."polygon_id") WHERE ("chimere_polygon"."start_date" IS NULL OR ("chimere_polygon"."start_date" <= CURRENT_DATE AND "chimere_polygon"."start_date" >= CURRENT_DATE) OR ("chimere_polygon"."start_date" <= CURRENT_DATE AND "chimere_polygon"."end_date" >= CURRENT_DATE)) GROUP BY "chimere_polygon_categories"."subcategory_id", "chimere_polygon"."status"; """ SQL_ROUTE = """CREATE OR REPLACE VIEW chimere_aggregated_routes (id, subcategory_id, status, route) AS SELECT row_number() OVER ( ORDER BY "chimere_route_categories"."subcategory_id", "chimere_route"."status"), "chimere_route_categories"."subcategory_id", "chimere_route"."status", ST_Multi(ST_Collect("chimere_route"."route")) FROM "chimere_route" LEFT OUTER JOIN "chimere_route_categories" ON ( "chimere_route"."id" = "chimere_route_categories"."route_id") WHERE ("chimere_route"."start_date" IS NULL OR ("chimere_route"."start_date" <= CURRENT_DATE AND "chimere_route"."start_date" >= CURRENT_DATE) OR ("chimere_route"."start_date" <= CURRENT_DATE AND "chimere_route"."end_date" >= CURRENT_DATE)) GROUP BY "chimere_route_categories"."subcategory_id", "chimere_route"."status"; """ class Migration(migrations.Migration): dependencies = [ ('chimere', '0014_auto_20180313_1033'), ] operations = [ migrations.RunSQL(SQL_POLY), migrations.RunSQL(SQL_ROUTE), ]