1
0

Update template and add liquibase

This commit is contained in:
Владимир Шперлинг 2024-11-22 13:58:16 +07:00
parent a23ad50d41
commit 68a2acd925
8 changed files with 136 additions and 2 deletions

View File

@ -9,8 +9,6 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@ -52,6 +50,10 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="2024-10-20--0001-code" author="anepretimov">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="code"/>
</not>
</preConditions>
<createTable tableName="code">
<column name="id"
type="NUMERIC(19,0)"
autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="value" type="NUMERIC(19,0)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="2024-10-20--0002-employee" author="anepretimov">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="employee"/>
</not>
</preConditions>
<createTable tableName="employee">
<column name="id"
type="NUMERIC(19,0)"
autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="login" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="name" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="photo" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="position" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="last_visit" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="2024-10-20--0001-code-data" author="anepretimov">
<loadData tableName="code" file="db.changelog/data/csv/2024-10-20--0001-code-data.csv"
separator=";"
quotchar='"'
encoding="UTF-8"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="2024-10-20--0002-employee-data" author="anepretimov">
<loadData tableName="employee" file="db.changelog/data/csv/2024-10-20--0002-employee-data.csv"
separator=";"
quotchar='"'
encoding="UTF-8"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,6 @@
id;value
1;1234567890123456789
2;9223372036854775807
3;1122334455667788990
4;998877665544332211
5;5566778899001122334
1 id value
2 1 1234567890123456789
3 2 9223372036854775807
4 3 1122334455667788990
5 4 998877665544332211
6 5 5566778899001122334

View File

@ -0,0 +1,5 @@
id;login;name;photo;position;last_visit
1;pivanov;Иванов Петр Федорович;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Разработчик;2024-02-12T08:30:00
2;ipetrov;Петров Иван Константинович;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Аналитик;2024-02-13T08:35:00
3;asemenov;Семенов Анатолий Анатольевич;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Разработчик;2024-02-13T08:31:00
4;afedorov;Федоров Александр Сергеевич;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Тестировщик;2024-02-12T08:36:00
1 id login name photo position last_visit
2 1 pivanov Иванов Петр Федорович https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg Разработчик 2024-02-12T08:30:00
3 2 ipetrov Петров Иван Константинович https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg Аналитик 2024-02-13T08:35:00
4 3 asemenov Семенов Анатолий Анатольевич https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg Разработчик 2024-02-13T08:31:00
5 4 afedorov Федоров Александр Сергеевич https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg Тестировщик 2024-02-12T08:36:00

View File

@ -0,0 +1,13 @@
<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.8.xsd">
<include file="db.changelog/1.0/2024-10-20--0001-code.xml"/>
<include file="db.changelog/1.0/2024-10-20--0002-employee.xml"/>
<include file="db.changelog/data/2024-10-20--0001-code-data.xml"/>
<include file="db.changelog/data/2024-10-20--0002-employee-data.xml"/>
</databaseChangeLog>