Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'org.springframework.boot' version '2.2.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'org.flywaydb.flyway' version '6.2.3'
id 'org.liquibase.gradle' version '2.0.4'
}

sourceCompatibility = '11'
Expand All @@ -18,7 +18,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'

implementation 'org.flywaydb:flyway-core'
implementation "org.liquibase:liquibase-core:3.6.3"
runtimeOnly 'com.h2database:h2:1.4.200'

testCompile 'org.assertj:assertj-core'
Expand All @@ -29,10 +29,3 @@ dependencies {
test {
useJUnitPlatform()
}

flyway {
url = 'jdbc:h2:mem:'
locations = [
'classpath:db/migration'
]
}
6 changes: 5 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
logging.level.org.flywaydb=debug
spring.datasource.url=jdbc:h2:mem:
spring.datasource.username=
spring.datasource.password=
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml
logging.level.liquibase=DEBUG
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="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">
<changeSet author="il.gusevskiy@gmail.com" id="v1">
<createTable tableName="companies">
<column autoIncrement="true" name="id" type="INT">
<constraints primaryKey="true"/>
</column>
<column name="name" type="VARCHAR(255)">
<constraints nullable="false" unique="true"/>
</column>
</createTable>
<rollback>
<dropTable tableName="companies"/>
</rollback>
</changeSet>
<changeSet author="il.gusevskiy@gmail.com" id="v2">
<sqlFile path="db/changelog/sql/v3.1-insert_companies.sql" relativeToChangelogFile="false"/>
</changeSet>
<changeSet author="il.gusevskiy@gmail.com" id="v3">
<createTable tableName="employees">
<column name="title" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="user_id" type="INT">
<constraints nullable="false" unique="true"
foreignKeyName="fk_user" references="users(id)"/>
</column>
<column name="company_id" type="INT">
<constraints nullable="false"
foreignKeyName="fk_company" references="companies(id)"/>
</column>
</createTable>
<rollback>
<dropTable tableName="companies"/>
</rollback>
</changeSet>
<changeSet author="il.gusevskiy@gmail.com" id="v4">
<sqlFile path="db/changelog/sql/v3.4-insert_employees.sql" relativeToChangelogFile="false"/>
</changeSet>
</databaseChangeLog>
29 changes: 29 additions & 0 deletions src/main/resources/db/changelog/changes/v1-v2-create_users.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="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">
<changeSet author="il.gusevskiy@gmail.com" id="v1">
<createTable tableName="users">
<column autoIncrement="true" name="id" type="INT">
<constraints primaryKey="true"/>
</column>
<column name="username" type="VARCHAR(255)">
<constraints nullable="false" unique="true"/>
</column>
<column name="first_name" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="last_name" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
</createTable>
<rollback>
<dropTable tableName="users"/>
</rollback>
</changeSet>
<changeSet author="il.gusevskiy@gmail.com" id="v2">
<sqlFile path="db/changelog/sql/v1-insert_users.sql" relativeToChangelogFile="false"/>
</changeSet>
</databaseChangeLog>
9 changes: 9 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="/db/changelog/changes/v1-v2-create_users.xml"/>
<include file="/db/changelog/changes/v1-3-create_companies_and_employees.xml"/>
</databaseChangeLog>

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/resources/db/migration/V1__init_users_table.sql

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.List;

@DataJpaTest
public class AfliFlywayEmployeeTest {
public class AfliLiquibaseEmployeeTest {

private static final String FIND_ALL_COMPANIES = "" +
"SELECT name " +
Expand Down