# Generated by Django 2.2.18 on 2021-04-08 16:30

from django.db import migrations

UPDATE_GWELLS_WELLS_VIEW_SQL = """
    DROP VIEW postgis_ftw.gwells_well_view;
    CREATE VIEW postgis_ftw.gwells_well_view AS
        SELECT
            well_tag_number,
            aquifer_id,
            artesian_conditions AS artesian,
            street_address,
            identification_plate_number,
            observation_well_number,
            obs_well_status_code AS observation_well_status_code,
            ems,
            well_publication_status_code = 'Published' AS is_published,
            geom
        FROM well
        WHERE geom IS NOT NULL;
        GRANT SELECT ON postgis_ftw.gwells_well_view TO ftw_reader;
"""


class Migration(migrations.Migration):

    dependencies = [
        ('wells', '0131_remove_surface_seal_length_col_water_1687'),
    ]

    operations = [
        migrations.RunSQL(UPDATE_GWELLS_WELLS_VIEW_SQL)
    ]
