git-extractor/src/main/resources/db/changelog-20221012_170000-schema.xml

130 lines
6.7 KiB
XML

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="barmina" id="20221012-170000-1">
<createTable tableName="antecedent_value">
<column name="id" type="integer">
<constraints nullable="false"/>
</column>
<column name="version" type="integer"/>
<column name="antecedent_value" type="text">
<constraints nullable="false"/>
</column>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_antecedent_value" tableName="antecedent_value"/>
<createTable tableName="rule">
<column name="id" type="integer">
<constraints nullable="false"/>
</column>
<column name="version" type="integer"/>
<column name="first_antecedent_value_id" type="integer"/>
<column name="first_antecedent_id" type="integer"/>
<column name="second_antecedent_value_id" type="integer"/>
<column name="second_antecedent_id" type="integer"/>
<column name="consequent" type="text">
<constraints nullable="false"/>
</column>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_rule" tableName="rule"/>
<addForeignKeyConstraint baseTableName="rule" baseColumnNames="first_antecedent_value_id"
constraintName="fk_first_antecedent_value"
referencedTableName="antecedent_value"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="rule" baseColumnNames="first_antecedent_id"
constraintName="fk_first_time_series"
referencedTableName="time_series"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="rule" baseColumnNames="second_antecedent_value_id"
constraintName="fk_second_antecedent_value"
referencedTableName="antecedent_value"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="rule" baseColumnNames="second_antecedent_id"
constraintName="fk_second_time_series"
referencedTableName="time_series"
referencedColumnNames="id"/>
</changeSet>
<changeSet author="orion" id="20221012-170000-2">
<addColumn tableName="time_series">
<column name="time_series_type" type="varchar(100)"></column>
</addColumn>
</changeSet>
<changeSet author="orion" id="20221012-170000-3">
<dropForeignKeyConstraint baseTableName="rule" constraintName="fk_first_time_series"/>
<dropForeignKeyConstraint baseTableName="rule" constraintName="fk_second_antecedent_value"/>
<delete tableName="rule"/>
<dropColumn tableName="rule" columnName="first_antecedent_id"/>
<dropColumn tableName="rule" columnName="second_antecedent_id"/>
<addColumn tableName="rule">
<column name="first_antecedent" type="varchar(100)"/>
</addColumn>
<addColumn tableName="rule">
<column name="second_antecedent" type="varchar(100)"/>
</addColumn>
</changeSet>
<changeSet author="orion" id="20221012-170000-4">
<delete tableName="antecedent_value"/>
<insert tableName="antecedent_value">
<column name="id" value="1"/>
<column name="version" value="0"/>
<column name="antecedent_value" value="спад"/>
</insert>
<insert tableName="antecedent_value">
<column name="id" value="2"/>
<column name="version" value="0"/>
<column name="antecedent_value" value="стабильно"/>
</insert>
<insert tableName="antecedent_value">
<column name="id" value="3"/>
<column name="version" value="0"/>
<column name="antecedent_value" value="рост"/>
</insert>
</changeSet>
<changeSet author="orion" id="20221127-170000-1">
<addColumn tableName="time_series">
<column name="branch_id" type="integer"/>
</addColumn>
<addForeignKeyConstraint baseTableName="time_series" baseColumnNames="branch_id"
constraintName="fk_time_series_branch" referencedTableName="branch"
referencedColumnNames="id"/>
</changeSet>
<changeSet author="orion" id="20221127-170000-2">
<sql>
delete
from time_series_value
where time_series_id in (select id from time_series where time_series_type is null OR branch_id is null);
delete
from time_series
where time_series_type is null
OR branch_id is null;
</sql>
</changeSet>
<changeSet author="orion" id="20230207-220000-1">
<addColumn tableName="branch">
<column name="indexing_status" type="varchar(100)"/>
</addColumn>
<update tableName="branch">
<column name="indexing_status" value="FINISHED"/>
</update>
</changeSet>
<changeSet author="orion" id="20230220-120000-1">
<addColumn tableName="git_repository">
<column name="repository_id" type="varchar(100)"/>
</addColumn>
</changeSet>
<changeSet author="orion" id="20230220-120000-2">
<dropForeignKeyConstraint baseTableName="time_series"
constraintName="fk_time_series_branch"/>
<addForeignKeyConstraint baseTableName="time_series" baseColumnNames="branch_id"
constraintName="fk_time_series_branch" referencedTableName="branch"
referencedColumnNames="id" onDelete="CASCADE"/>
</changeSet>
<changeSet author="orion" id="20230220-120000-3">
<dropForeignKeyConstraint baseTableName="time_series_value"
constraintName="fk_time_series"/>
<addForeignKeyConstraint baseTableName="time_series_value" baseColumnNames="time_series_id"
constraintName="fk_time_series"
referencedTableName="time_series"
referencedColumnNames="id" onDelete="CASCADE"/>
</changeSet>
</databaseChangeLog>