Liquibase - 기존 DB를 이용해서 초기(initial) ChangeSet 만들기

DevOps|2018. 4. 5. 18:12

Generating Change Logs

  • Example
liquibase --driver=oracle.jdbc.OracleDriver \
      --classpath=\path\to\classes:jdbcdriver.jar \
      --changeLogFile=com/example/db.changelog.xml \
      --url="jdbc:oracle:thin:@localhost:1521:XE" \
      --username=scott \
      --password=tiger \
      generateChangeLog
  • default options
liquibase --driver=org.postgresql.Driver --classpath=C:/Users/daniel/.IntelliJIdea2017.3/config/jdbc-drivers/PostgreSQL/42.2.1/postgresql-42.2.1.jar --changeLogFile=db.changelog.xml --url="jdbc:postgresql://localhost:5432/postgres" --username=postgres --password=postgres generateChangeLog
liquibase --driver=org.postgresql.Driver --classpath=C:/Users/daniel/.IntelliJIdea2017.3/config/jdbc-drivers/PostgreSQL/42.2.1/postgresql-42.2.1.jar --changeLogFile=db.data.changelog.xml --url="jdbc:postgresql://localhost:5432/postgres" --username=postgres --password=postgres --diffTypes="data" generateChangeLog
  • all(default + include data)
liquibase --driver=org.postgresql.Driver --classpath=C:/Users/daniel/.IntelliJIdea2017.3/config/jdbc-drivers/PostgreSQL/42.2.1/postgresql-42.2.1.jar --changeLogFile=db.all.changelog.xml --url="jdbc:postgresql://localhost:5432/postgres" --username=postgres --password=postgres --diffTypes="tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data" generateChangeLog
  • 데이터베이스 업데이트를 위해 Liquibase가 사용하는 SQL 파일 생성
liquibase --driver=org.postgresql.Driver --classpath=C:/Users/daniel/.IntelliJIdea2017.3/config/jdbc-drivers/PostgreSQL/42.2.1/postgresql-42.2.1.jar --changeLogFile=db.all.changelog.xml --url="jdbc:postgresql://localhost:5432/postgres" --username=postgres --password=postgres --diffTypes="tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data" updateSQL  > updateSQL.sql
  • 생성된 ChangeSet은 여러 개로 나뉘어져 있는데, 하나의 ChangeSet으로 병합하는게 좋다.
    • 변경 로그를 하나만 남기기 위해서.
    • 가독성



EOF

댓글()