{"id":1286,"date":"2010-07-15T00:54:34","date_gmt":"2010-07-14T19:24:34","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1286"},"modified":"2010-09-03T12:57:15","modified_gmt":"2010-09-03T07:27:15","slug":"how-to-generate-ddl-script-for-domain-classes-in-grails-using-schema-export-target","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-generate-ddl-script-for-domain-classes-in-grails-using-schema-export-target\/","title":{"rendered":"How to generate DDL script for domain classes in Grails using schema-export target"},"content":{"rendered":"<p>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.<\/p>\n<p>I use a not-so-commonly known Grails command\/script <strong>schema-export<\/strong> to help me deal me with this situation without much fuss of writing the DDL script myself.<\/p>\n<p>To generate DDL script for all the domain classes<\/p>\n<p>&gt; <strong><em>grails schema-export<\/em><\/strong><\/p>\n<p>The DDL script in this case is created as {PROJECT_ROOT}<strong><em>\/target\/ddl.sql<\/em><\/strong> file.<\/p>\n<p>You can also specify the path of the file where you want the schema file to get generated.<\/p>\n<p><strong>&gt; grails schema-export sql\/ddl.sql<\/strong><\/p>\n<p>Hope this helps!<\/p>\n<p>-Deepak<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":8},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1286"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1286"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1286\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}