3 Kasım 2022 Perşembe

liquibase plugin

Giriş
Çalıştırmak için şöyle yaparız
$ mvn liquibase:update
Elimizde şöyle bir şey olsun
<properties>
  <java.version>17</java.version>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <maven.compiler.source>${java.version}</maven.compiler.source>
  <maven.compiler.target>${java.version}</maven.compiler.target>

  <!-- Liquibase properties -->
  <liquibase-maven-plugin.version>4.16.1</liquibase-maven-plugin.version>
  <mysql.version>8.0.30</mysql.version>
  <db.url>jdbc:mysql://localhost:3306/mydb?useUnicode=true&amp;characterEncoding=UTF-8&amp;createDatabaseIfNotExist=true</db.url>
  <db.username>root</db.username>
  <db.password></db.password>
</properties>
Şu satırı dahil ederizchangeLogFile ile sql dosyalarının yerini belirtiriz.
<plugin>
  <!-- Liquibase plugin -->
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>${liquibase-maven-plugin.version}</version>
  <configuration>
    <changeLogFile>${project.basedir}/db/changelog-master.yml</changeLogFile>

    <!-- DB connection config -->
    <driver>com.mysql.jdbc.Driver</driver>
    <url>${db.url}</url>
    <username>${db.username}</username>
    <password>${db.password}</password>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>${mysql.version}</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</plugin>
db dizinindeki changelog-master.yml şöyledir
databaseChangeLog:
  - includeAll:
      - path: changes
      - relativeToChangelogFile: true
changes dizininde şu dosyalar vardır
001_createTablePerson.yml
002_addColumnUsername.yml
003_addLookupTableState.yml



Hiç yorum yok:

Yorum Gönder

Local Snapshot Kullanmak

Örnek Şöyle yaparız <repository> <id>snapshot-repository</id> <name>Maven2 Snapshot Repository</name> &l...