사용자 도구

사이트 도구


java:database:migration:liquibase

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
java:database:migration:liquibase [2020/07/16 14:46]
kwon37xi
java:database:migration:liquibase [2022/04/14 12:34] (현재)
kwon37xi
줄 15: 줄 15:
  
 // JDBC 드라이버 등 관련 의존성을 일일이 따로 걸어주거나 아래처럼 runtime에서 그대로 가져온다. // JDBC 드라이버 등 관련 의존성을 일일이 따로 걸어주거나 아래처럼 runtime에서 그대로 가져온다.
 +// 공식문서에는 runtime 을 상속하라고 돼 있지만 실제로는 runtimeClasspath 여야 작동했음. Gradle 6.5.x
 configurations { configurations {
-  liquibaseRuntime.extendsFrom runtime+  liquibaseRuntime.extendsFrom runtimeClasspath 
 } }
  
줄 29: 줄 30:
 liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate5:3.6'  liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate5:3.6' 
 liquibaseRuntime sourceSets.main.output liquibaseRuntime sourceSets.main.output
-</code> 
  
-===== Change Types =====+liquibase { 
 +    activities { 
 +        main { 
 +            changeLogFile 'src/migration/changelog-main.xml' 
 +            url "jdbc:url..." 
 +            username "username" 
 +            password "password" 
 +        } 
 +    } 
 +
 +</code> 
 +===== ChangeLog 관리 ===== 
 +  * main changelog 관리 XML을 만들고, 거기서 각각 단일 changeset 을 가지는 다른 xml 들을 include 하는 형태로 관리하는 것이 좋다. 
 +  * 하나의 chagelog 파일은 하나의 changeset 만 가지는 것이 좋다. 
 +  * ''changelog-main.xml''<code xml> 
 +<?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.8.xsd">   
 +  <include  file="com/example/db/changelog/db.changelog-1.0.xml"/>    
 +  <include  file="com/example/db/changelog/db.changelog-1.1.xml"/>    
 +  <include  file="com/example/db/changelog/db.changelog-2.0.xml"/>    
 +</databaseChangeLog>  
 +</code> 
 +  * ''changelog-1.0.xml'' ... <code xml> 
 +<?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.8.xsd">    
 +  <changeSet  author="authorName"  id="changelog-1.0">   
 +    <createTable  tableName="TablesAndTables">   
 +      <column  name="COLUMN1"  type="TEXT">   
 +        <constraints  nullable="true"  primaryKey="false"  unique="false"/>   
 +      </column>   
 +    </createTable>   
 +  </changeSet>   
 +</databaseChangeLog>  
 +</code> 
 +===== Change Set Types =====
 ==== sql ==== ==== sql ====
   * https://docs.liquibase.com/change-types/community/sql.html   * https://docs.liquibase.com/change-types/community/sql.html
줄 42: 줄 84:
             endDelimiter="\nGO"               endDelimiter="\nGO"  
             splitStatements="true"               splitStatements="true"  
-            stripComments="true">insert into person (name) values ('Bob')+            stripComments="true">
         <comment>What about Bob?</comment>           <comment>What about Bob?</comment>  
-    </sql>  +            <![CDATA[ 
 +            insert into person (name) values ('Bob'
 +    ]]></sql>  
 </changeSet> </changeSet>
 </code> </code>
줄 53: 줄 97:
   * [[https://dzone.com/articles/managing-your-database-with-liquibase-and-gradle|Managing Your Database With Liquibase and Gradle - DZone Database]]   * [[https://dzone.com/articles/managing-your-database-with-liquibase-and-gradle|Managing Your Database With Liquibase and Gradle - DZone Database]]
   * [[https://joont92.github.io/etc/liquibase/|liquibase | 기록은 기억의 연장선]]   * [[https://joont92.github.io/etc/liquibase/|liquibase | 기록은 기억의 연장선]]
 +  * [[https://www.baeldung.com/liquibase-vs-flyway|Liquibase vs Flyway | Baeldung]]
java/database/migration/liquibase.1594878411.txt.gz · 마지막으로 수정됨: 2020/07/16 14:46 저자 kwon37xi