Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating liquibase xml file from current database

I have tried to create liquibase XML existing from MySQL database. My goal is to generate liquibase XML schema from MySQL database.

Any way to achieve this solution.

I have already tried with dropwizard command

java -jar myjar-4.1.0.jar --changeLogFile="generate.xml" --diffTypes="data" generateChangeLog

but it does not work for me.

like image 422
Maulik Kakadiya Avatar asked Apr 13 '18 08:04

Maulik Kakadiya


1 Answers

After trying so many time finally I got my solution.

Follow following steps to generate migration from existing MySQL database. Add initial migrations.xml into the project with below lines.

<?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.0.xsd">
    </databaseChangeLog>

Run: above migration with "db migrate" for dropwizard, it'll create databaseChangeLog and databaseChangeLogLock tables into Database.

Run Following command as per requirement.

Command Syntax :

liquibase --driver=com.mysql.jdbc.Driver --classpath=[path to db driver jar] --changeLogFile=[Path to above migration.xml]  --url=[Database URL] --username=[Username] --password=[Password] [command parameters]

U can refer this link or link for above common parameter

Note: Command require [path to DB driver jar], JDBC.jar file for this if you don't have.

like image 198
Maulik Kakadiya Avatar answered Sep 28 '22 05:09

Maulik Kakadiya