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
