Grails Tip: Using Schema Export
Ever wonder what the DDL would look like that Grails generates to create or update your database? Well, no need to wonder any longer. Grails is packed full with little things to make your life simpler, and one that you may not have heard of yet is the Grails ‘schema-export’ command line option. Under the covers this handy utility delegates to Hibernate’s SchemaExport. The output can either go to a file or to standard out.
Examples:
- ‘grails schema-export’ : generates the DDL for the development environment into the default file ddl.sql
- ‘grails prod schema-export’ : generates the DDL for the production environment to the default file ddl.sql
- ‘grails schema-export export’ : generates the export DDL (drop then create)
- ‘grails schema-export stdout’ : generates the DDL and sends it to starndard out
Member discussion