Resolve "Создать таблицы в БД" #38

Merged
BarminaA merged 1 commits from 7-create-changelog into master 2021-03-26 17:40:50 +04:00
2 changed files with 74 additions and 0 deletions
Showing only changes of commit c9385b82a3 - Show all commits

View File

@ -0,0 +1,73 @@
<?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="20210326-170000-1">
<createTable tableName="repository">
<column name="id" type="integer">
<constraints nullable="false"/>
</column>
<column name="url" type="text"/>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_repository" tableName="repository"/>
<createTable tableName="branch">
<column name="id" type="integer">
<constraints nullable="false"/>
</column>
<column name="name" type="text"/>
<column name="repository_id" type="integer"/>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_branch" tableName="branch"/>
<addForeignKeyConstraint baseTableName="branch" baseColumnNames="repository_id" constraintName="fk_repository"
referencedTableName="repository"
referencedColumnNames="id"/>
<createTable tableName="author">
<column name="id" type="integer">
<constraints nullable="false"/>
</column>
<column name="name" type="text"/>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_author" tableName="author"/>
<createTable tableName="file_change">
<column name="id" type="integer">
<constraints nullable="false"/>
</column>
<column name="file" type="text"/>
<column name="commit_id" type="integer"/>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_file_change" tableName="file_change"/>
<addForeignKeyConstraint baseTableName="file_change" baseColumnNames="commit_id" constraintName="fk_commit"
referencedTableName="commit"
referencedColumnNames="id"/>
<createTable tableName="line_change">
<column name="id" type="integer">
<constraints nullable="false"/>
</column>
<column name="line_from" type="text"/>
<column name="line_to" type="text"/>
<column name="file_change_id" type="integer"/>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_line_change" tableName="line_change"/>
<addForeignKeyConstraint baseTableName="line_change" baseColumnNames="file_change_id"
constraintName="fk_file_change" referencedTableName="file_change"
referencedColumnNames="id"/>
<dropColumn tableName="commit" columnName="author"/>
<addColumn tableName="commit">
<column name="author_id" type="integer"/>
</addColumn>
<addColumn tableName="commit">
<column name="branch_id" type="integer"/>
</addColumn>
<addForeignKeyConstraint baseTableName="commit" baseColumnNames="author_id" constraintName="fk_author"
referencedTableName="author"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="commit" baseColumnNames="branch_id" constraintName="fk_branch"
referencedTableName="branch"
referencedColumnNames="id"/>
</changeSet>
</databaseChangeLog>

View File

@ -4,4 +4,5 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="db/changelog-20210317_140000-schema.xml"/> <include file="db/changelog-20210317_140000-schema.xml"/>
<include file="db/changelog-20210326_170000-schema.xml"/>
</databaseChangeLog> </databaseChangeLog>