0

I am using liquibase 2.x (can't upgrade just yet) and want to generate my migrations.xml from a SQL file. There is the sql tag that lets me target the dbs but that seems like its only 3.x.

I am currently using h2 and liquibase.diff.Diff to do this, but it has issues generating the changeSet (VARCHAR(2147483647) freaks out in derby). It also feels wrong to me by loading the SQL into h2 then Diffing to create a changeSet for PoststgreSQL. Is there a way to let me generate my migrations.xml file without diffing?

I am also fine generating different changeSets for different DBs as long as its in the same migration.xml

is there any way to do this?

1 Answer 1

1

I don't think there is another way to generate a diff changeset file. You would have to create your database, let liquibase run the diff to generate a base changelog file and then rework it manually.

This is what we did. And the rework included:

  • changing the author tag to the real username
  • changing the id attribute to a self enumerated value
  • changing the type BIT by BOOLEAN (we generated the diff from mysql but also wanted to put it on oracle where BIT is not a valid type)
  • remove the generated schema names (to keep the schema variable)
  • rename IDs of constraints (that hibernate previously generated during development time) by better Names
  • Use sequences only where the database supports sequences. Otherwise use a simple table.

These are just examples of what we did. But I guess you will not get around the manual part.

Sign up to request clarification or add additional context in comments.

2 Comments

Agreed. Liquibase does not really have the ability to parse all the different dialects of SQL and relies on the database engines themselves to do that.
I have a function that does this at a ChangeSet level, but found that moving between different DBs (H2 -> Derby -> Postsql), I also had to get into the types and change them per DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.