Spring Boot liquidata

properties

1
2
3
4
5
spring.liquibase.user=root
spring.liquibase.password=
spring.liquibase.enabled=true
spring.liquibase.url=jdbc:h2:file:./test;MODE=MYSQL;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
spring.liquibase.change-log=classpath:/liquibase/changelog-master.xml

文件目录结构

1
2
3
4
5
|resource
|---changelog
|| 2018-05-08-init-schema.xml
|---liquibase
|| changelog-master.xml

master

1
2
3
4
5
6
<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">
<include file="classpath:/changelog/2018-05-08-init-schema.xml" relativeToChangelogFile="false"/>
</databaseChangeLog>

scheme

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<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">
<property name="autoIncrement" value="now()" dbms="mysql"/>
<changeSet id="init-schema" author="Jason.Su">
<comment>init schema</comment>
<!-- Position -->
<createTable tableName="t_position">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>

<column name="user_id" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>

<column name="currency" type="INTEGER">
<constraints nullable="false"/>
</column>

<column name="size" type="DOUBLE">
<constraints nullable="false"/>
</column>

<column name="cost" type="DECIMAL(18,8)">
<constraints nullable="false"/>
</column>

<column name="is_closed" type="BOOLEAN">
<constraints nullable="false"/>
</column>

<column name="created_at" type="timestamp" defaultValueComputed="CURRENT_TIMESTAMP">
<constraints nullable="false"/>
</column>

<column name="updated_at" type="timestamp" defaultValueComputed="CURRENT_TIMESTAMP">
<constraints nullable="false"/>
</column>
</createTable>

<modifySql dbms="mysql">
<append value="ENGINE=INNODB DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci"/>
</modifySql>
</changeSet>
</databaseChangeLog>