How to generate DDL script for domain classes in Grails using schema-export target « Intelligrape Groovy & Grails Blogs

How to generate DDL script for domain classes in Grails using schema-export target

Posted by Deepak Mittal

On most of my grails projects, I am used to let grails handle database schema creation for me. However, there is a project where the database is shared between multiple applications. In that project, we have to check-in our table creation/modification script as a SQL file, which is later executed by a DBA.

I use a not-so-commonly known Grails command/script schema-export to help me deal me with this situation without much fuss of writing the DDL script myself.

To generate DDL script for all the domain classes

> grails schema-export

The DDL script in this case is created as {PROJECT_ROOT}/target/ddl.sql file.

You can also specify the path of the file where you want the schema file to get generated.

> grails schema-export sql/ddl.sql

Hope this helps!

-Deepak

  • Share/Bookmark
This entry was posted on Thursday, July 15th, 2010 at 12:54 am and is filed under Database, Grails . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply