<?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="hairullin">
        <comment>ALTER VIEW metrics.view_convert_info_comparison_csv_xml</comment>
		<sql>
		DROP VIEW metrics.view_convert_info_comparison_csv_xml;

		CREATE OR REPLACE VIEW metrics.view_convert_info_comparison_csv_xml
		 AS
		 SELECT convert_info_comparison_csv_xml.convert_info_comparison_csv_xml_id,
			COALESCE(round(convert_info_comparison_csv_xml.count_xml_formed::numeric * 100::numeric / NULLIF(convert_info_comparison_csv_xml.count_csv_formed::numeric, 0::numeric),2), 0::numeric) AS percent_xml_formed
		   FROM metrics.convert_info_comparison_csv_xml;

		ALTER TABLE metrics.view_convert_info_comparison_csv_xml
			OWNER TO ervu_business_metrics;

		GRANT ALL ON TABLE metrics.view_convert_info_comparison_csv_xml TO ervu_business_metrics;	
		</sql>
	</changeSet>
	
	<changeSet id="0002" author="hairullin">
        <comment>ADD COLUMN count_incorrect_authentications</comment>
		<sql>
		ALTER TABLE IF EXISTS admin_indicators.user_activity
		ADD COLUMN IF NOT EXISTS count_incorrect_authentications bigint NOT NULL DEFAULT 0;

		COMMENT ON COLUMN admin_indicators.user_activity.count_incorrect_authentications
		IS 'Количество неверных аутентификаций';	
		</sql>
	</changeSet>
	
</databaseChangeLog>