From 12983299ece16498a9a979b49d75286b454ffeb5 Mon Sep 17 00:00:00 2001 From: indigane Date: Mon, 9 Sep 2024 13:55:35 +0300 Subject: [PATCH] Add postgresql view for external reports into apartments table --- .../migrations/0016_external_report_view.py | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 backend/hitas/migrations/0016_external_report_view.py diff --git a/backend/hitas/migrations/0016_external_report_view.py b/backend/hitas/migrations/0016_external_report_view.py new file mode 100644 index 000000000..085072a7b --- /dev/null +++ b/backend/hitas/migrations/0016_external_report_view.py @@ -0,0 +1,49 @@ +# Generated by Django 4.2.4 on 2024-09-09 07:22 + +from django.db import migrations + +CREATE_SQL = """ +CREATE VIEW hitas_apartment_external_report_view AS + SELECT + id, + deleted, + deleted_by_cascade, + uuid, + share_number_start, + share_number_end, + completion_date, + street_address, + stair, + apartment_number, + floor, + surface_area, + rooms, + catalog_purchase_price, + catalog_primary_loan_amount, + additional_work_during_construction, + loans_during_construction, + interest_during_construction_mpi, + interest_during_construction_cpi, + debt_free_purchase_price_during_construction, + apartment_type_id, + building_id, + updated_acquisition_price + FROM hitas_apartment; +COMMENT ON VIEW hitas_apartment_external_report_view IS + 'hitas_apartment view for external report usage, excluding the notes column because notes may contain sensitive information.'; +""" # noqa: E501 + +DROP_SQL = "DROP VIEW IF EXISTS hitas_apartment_external_report_view;" + + +class Migration(migrations.Migration): + dependencies = [ + ("hitas", "0015_housingcompanydocument_aparmentdocument"), + ] + + operations = [ + migrations.RunSQL( + sql=CREATE_SQL, + reverse_sql=DROP_SQL, + ), + ]