Reputation: 85
Grails can automatically create database tables (e.g. in MySQL) based on domain classes.
During debugging, is there a command that will simply print out the SQL statement that would be executed against the database to create the table, based on a domain class?
That is, instead of having Grails actually trying to create the table and generate potential errors (yes, that may include the CREATE TABLE statement).
I would find it useful sometimes to have Grails tell me what SQL CREATE TABLE statement it thinks a domain class maps to.
Upvotes: 3
Views: 820
Reputation: 75681
Use the schema-export command for this.
If you're using Grails 3 you'll need to add the plugin as a classpath
dependency in buildscript.dependencies
. This is done for you in recent Grails 3 versions but in an earlier release you just need to add it yourself:
buildscript {
...
dependencies {
...
classpath "org.grails.plugins:hibernate:4.3.10.5"
}
}
Upvotes: 3