Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Grails] Schema Export

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While working on a project we decided we wanted to specify the names of all of our indexes and foreign keys. When we do a grails run-app, assuming the database exists but no tables, everything gets created as expected except our index and key names are not used. They are defaulted to FK1234555465, etc. However, if we execute

grails dev schema-export export

indexes and keys are named properly. Is this a bug or is this expected?

Another side question here is, Ive noticed also that unless you're using HSQLDB, Grails will not create the database for you. You have to drop and create it manually, and then Grails will generate the schema. This is a small issue, but kind of annoying with the extra step. I just figured I'd bring it up in case anyone knows the reason for this.
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on your side question, what DB are you using and at what stage do you want Grails to create the DB for you?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vyas Sanzgiri wrote:on your side question, what DB are you using and at what stage do you want Grails to create the DB for you?


I'm using MySQL and I want the DB created if my dev is set to create/create-drop.
 
Peter Ledbrook
author
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

indexes and keys are named properly. Is this a bug or is this expected?


Do the indexes have the incorrect names in the database? Or is it just the foreign keys? As for the foreign keys, I notice you've raised an issue already. Whatever feature is already there may not be working correctly, but I have to admit I don't know for sure.


Another side question here is, Ive noticed also that unless you're using HSQLDB, Grails will not create the database for you. You have to drop and create it manually, and then Grails will generate the schema. This is a small issue, but kind of annoying with the extra step. I just figured I'd bring it up in case anyone knows the reason for this.


This is due to Hibernate's auto DDL feature. Why does Hibernate not do it? I don't know, but I suspect it's because the database user configured for the application typically shouldn't be allowed to create databases (something that a system/database administrator should be doing).

Cheers,

Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic