Liqulbase的HeIlo world
這是一個(gè)基于Liquibase關(guān)系型數(shù)據(jù)庫變更集的“hello world”簡單例子。
想要試驗(yàn)的話,解壓源代碼后運(yùn)行Java的構(gòu)建工具M(jìn)aven。
d h3-liquibase-helloworld
mvn liquibase:update
變更記錄文件
下面是一個(gè)Liquibase的變更記錄文件的例子。
它定義了兩個(gè)變更集,或者說是遷移,id為l和2
變更集創(chuàng)建了一張名為customer的表,有一個(gè)name字段。
變更集2對(duì)customer這張表增加了一個(gè)address列。
<?xml version="1 .0 " encoding= " utf-8 " ?>
<databaseChangeLog
xmlns " http://wwwliquibase.org/xml/ns/dbchangelog "
xmlns:xsi"http://www.w3.org/200l/XMLSchema-instance"
xsi:schemaLocation" http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd" >
<changeSet id="" author= "jave">
<createTable tableName="customer" >
(column name="id" type"int"/>
<column name=" name " type=" varchar (50) ">
</createTable>
</changeSet>
<changeSet id= "2" author="jave">
<addColumn tableNarne= "customer" >
<column name="address" type="varchar (255) ">
</addColumn>
</changeSet>
</databaseChangeLog>