changeSet

This commit is contained in:
Фоат Саляхов 2025-04-23 11:22:08 +03:00
parent 920284a506
commit f888cc9934
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet id="0001" author="saliakhov">
<comment>CREATE VIEW</comment>
<sql>
CREATE OR REPLACE VIEW actualization.view_app_reason
AS SELECT app_reason.app_reason_id,
COALESCE(round(app_reason.count_place_of_stay::numeric * 100::numeric / NULLIF((app_reason.count_place_of_stay + app_reason.count_work + app_reason.count_place_of_study + app_reason.count_family_status + app_reason.count_education+count_education + app_reason.count_renaming)::numeric, 0::numeric)), 0::numeric) AS percent_place_of_stay,
COALESCE(round(app_reason.count_work::numeric * 100::numeric / NULLIF((app_reason.count_place_of_stay + app_reason.count_work + app_reason.count_place_of_study + app_reason.count_family_status + app_reason.count_education+count_education + app_reason.count_renaming)::numeric, 0::numeric)), 0::numeric) AS percent_work,
COALESCE(round(app_reason.count_place_of_study::numeric * 100::numeric / NULLIF((app_reason.count_place_of_stay + app_reason.count_work + app_reason.count_place_of_study + app_reason.count_family_status + app_reason.count_education+count_education + app_reason.count_renaming)::numeric, 0::numeric)), 0::numeric) AS percent_place_of_study,
COALESCE(round(app_reason.count_family_status::numeric * 100::numeric / NULLIF((app_reason.count_place_of_stay + app_reason.count_work + app_reason.count_place_of_study + app_reason.count_family_status + app_reason.count_education+count_education + app_reason.count_renaming)::numeric, 0::numeric)), 0::numeric) AS percent_family_status,
COALESCE(round(app_reason.count_education::numeric * 100::numeric / NULLIF((app_reason.count_place_of_stay + app_reason.count_work + app_reason.count_place_of_study + app_reason.count_family_status + app_reason.count_education+count_education + app_reason.count_renaming)::numeric, 0::numeric)), 0::numeric) AS percent_education,
COALESCE(round(app_reason.count_renaming::numeric * 100::numeric / NULLIF((app_reason.count_place_of_stay + app_reason.count_work + app_reason.count_place_of_study + app_reason.count_family_status + app_reason.count_education+count_education + app_reason.count_renaming)::numeric, 0::numeric)), 0::numeric) AS percent_renaming
FROM actualization.app_reason;
</sql>
</changeSet>
</databaseChangeLog>

View file

@ -27,5 +27,7 @@
<include file="20250327-db_changes.xml" relativeToChangelogFile="true"/>
<include file="20250402-db_changes.xml" relativeToChangelogFile="true"/>
<include file="20250412-db_changes.xml" relativeToChangelogFile="true"/>
<include file="20250423-db_changes.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>