Database Changesets

This commit is contained in:
Индекс Зиро 2025-02-18 18:52:58 +03:00
parent 3af9977b12
commit caf100cc9a
13 changed files with 164 additions and 11 deletions

View File

@ -3,7 +3,7 @@ spring:
name: NTO-Finals
datasource:
url: jdbc:postgresql://localhost:5430/application_db
url: jdbc:postgresql://localhost:5432/application_db
username: indexzero
password: gkl370WVUPMgLhK
driver-class-name: org.postgresql.Driver
@ -23,4 +23,4 @@ spring:
show-sql: true
server:
port: 8081
port: 8080

View File

@ -5,7 +5,7 @@
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">
<changeSet id="2024-10-20--0002-employee" author="okalugin">
<preConditions onFail="MARK_RAN">
<not>
@ -25,11 +25,11 @@
<constraints nullable="false"/>
</column>
<column name="name" type="VARCHAR(100)">
<column name="password" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="photo" type="VARCHAR(100)">
<column name="name" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
@ -37,10 +37,11 @@
<constraints nullable="false"/>
</column>
<column name="last_visit" type="TIMESTAMP">
<column name="photo_url" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>

View File

@ -0,0 +1,24 @@
<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">
<changeSet id="1739891751754-1" author="okalugin">
<preConditions>
<not>
<tableExists tableName="authority"/>
</not>
</preConditions>
<createTable tableName="authority">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="authority" type="varchar(50)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,30 @@
<?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="2025-02-08--0004-employee-authorities" author="okalugin">
<preConditions>
<not>
<tableExists tableName="employee_authorities"/>
</not>
</preConditions>
<createTable tableName="employee_authorities">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="employee_id" type="BIGINT">
<constraints nullable="false" foreignKeyName="fk_employeeauth_employee" referencedTableName="employee"
referencedColumnNames="id"/>
</column>
<column name="authorities_id" type="BIGINT">
<constraints nullable="false" foreignKeyName="fk_employeeauth_authority" referencedTableName="authority"
referencedColumnNames="id"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,40 @@
<?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="2025-02-18--0005-employee-visits" author="okalugin">
<preConditions>
<not>
<tableExists tableName="employee_visits"/>
</not>
</preConditions>
<createTable tableName="employee_visits">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="user_id" type="BIGINT">
<constraints nullable="false" foreignKeyName="fk_employeeauth_employee" referencedTableName="employee"
referencedColumnNames="id"/>
</column>
<column name="visit_time" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
<column name="reader" type="bigint">
<constraints nullable="false" foreignKeyName="fk_reader_code" referencedTableName="code"
referencedColumnNames="id"/>
</column>
<column name="type" type="VARCHAR(100)">
<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="2025-02-18--0003-authority-data" author="okalugin">
<loadData tableName="authority" file="db.changelog/data/csv/2025-02-18--0003-authority-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="2025-02-18--0004-employee-authorities-data" author="okalugin">
<loadData tableName="employee_authorities" file="db.changelog/data/csv/2025-02-18--0004-employee-authorities-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="2025-02-18--0005-employee-visits-data" author="okalugin">
<loadData tableName="employee_visits" file="db.changelog/data/csv/2025-02-18--0005-employee-visits-data.csv"
separator=";"
quotchar='"'
encoding="UTF-8"/>
</changeSet>
</databaseChangeLog>

View File

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

View File

@ -0,0 +1,3 @@
authority
EMPLOYEE
ADMIN
1 authority
2 EMPLOYEE
3 ADMIN

View File

@ -0,0 +1,5 @@
employee_id;authorities_id
1;1
2;2
3;2
4;2
1 employee_id authorities_id
2 1 1
3 2 2
4 3 2
5 4 2

View File

@ -0,0 +1,2 @@
user_id;visit_time;reader;type
1;2024-02-12T08:30:00;1;smartphone
1 user_id visit_time reader type
2 1 2024-02-12T08:30:00 1 smartphone

View File

@ -6,8 +6,14 @@
<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/1.0/2025-02-18--0003-authority.xml"/>
<include file="db.changelog/1.0/2025-02-18--0004-employee-authorities.xml"/>
<include file="db.changelog/1.0/2025-02-18--0005-employee-visits.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"/>
<include file="db.changelog/data/2025-02-18--0003-authority-data.xml"/>
<include file="db.changelog/data/2025-02-18--0004-employee-authorities-data.xml"/>
<include file="db.changelog/data/2025-02-18--0005-employee-visits-data.xml"/>
</databaseChangeLog>