7
votes

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.

1
When you ran that command, what actually happened? What did you expect to happen? "Does not work for me" is not a very detailed description of the problem.SteveDonie

1 Answers

3
votes

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.