Can a Graix 2.x schema export or a similar command generate DDL for schema updates based on the data source?

Grails Graphical Export does a great job of creating DDL to create database schemas for a specific database. However, what I would like to do is that grails simply outputs DDL to update an already created schema, not DDL, to create it from scratch.

I think this should be possible, since grails has the ability to actually update schemas, if you specifically dbCreate = "update" in your data source.

But I just want Grails to spit out that it will run, and not really, so I can execute it myself using the SQL tool under control.

+4
source share
1 answer

As @GreyBeardedGeek pointed out in a comment, the database migration plugin (which is enabled by default now) can generate the “diffa schemas” you are looking for, and this is substantially more than what vanilla dbCreate = "update" does, since updating the native db from Grails depends only on what Hibernate offers, and it is very conservative in the updates that it can do.

In particular, part of the Database Migration plugin that you are looking for is a dbm-update-sql script that will give you the SQL that it executed to update the database to the current version of the schema.

In general, I would highly recommend using a tool like the database migration plugin, as it combines your database schema with application code, and you can easily combine them together, and also include many tools to trigger updates much less painful and allows rollbacks and custom scripts to massage things as needed.

+5
source

Source: https://habr.com/ru/post/1434304/


All Articles