0

My configuration is set to

development {
    dataSource {
        dbCreate = "create-drop" // one of 'create', 'create-drop','update'
        url = "***"
    }
}

I was thinking that this would drop all tables and hence all records and recreate all the tables again but when i build the app and check the records in the tables through phpmyadmin i can see the records not being deleted. All the records are there. Shouldn't all the tables be empty after building with this configuration? Thanks for the help!

I looked at the log file and it reports the following error:

enter image description here

It looks like it encountered errors when trying to delete the tables namely composite event and race registration but my dilemma is why would it encounter error when dropping tables. The create-drop configuration setting according to my assumption would drop all tables and create all tables. Please correct my misunderstandings. I appreciate the help. Thanks!

kofhearts
  • 3,607
  • 8
  • 46
  • 79
  • 2
    You might turn on sql logging by adding `logSql=true` to your data source configuration to watch what happens during startup. I can see drop and create statements getting executed with this turned on. – sCrain Sep 18 '15 at 12:35
  • Unfortunately from your screenshot, I can't see the errors encountered from the drop statements. Just the subsequent failed creations. Capturing the earlier failures might make the problem more apparent. In the mean time, I see you are using mysql... you might find something of use from this similar question: [Grails 2.4.4 DataSource “create-drop” fails to drop all tables having FKs](http://stackoverflow.com/questions/28016256/grails-2-4-4-datasource-create-drop-fails-to-drop-all-tables-having-fks) – sCrain Sep 20 '15 at 06:40
  • I went to phpmyadmin and tried to drop tables but my account doesn't have any privileges to drop tables. I was reading this link http://little418.com/2009/05/grails-cannot-create-table-because-it-already-exists.html and the second point says "You have some DB tool connected to your database which is preventing the drop command from being executed. Simply close all of your database tools." so i am thinking since drop command is not allowed the create table fails because duplicate tables are not allowed. could this be the reason? – kofhearts Sep 20 '15 at 06:50
  • Yes, I would try that suggestion and make sure you don't have any dbtools running. If that still fails, capturing the exact error grails encounters when the drop statements are executed will be pretty important. – sCrain Sep 20 '15 at 07:35
  • @sCrain I just checked the sql log and the interesting thing is that i don't see any drop commands. The majority of commands are select and few inserts. – kofhearts Sep 20 '15 at 11:28
  • Sounds like the databases may be in a bad state with extra objects still left over. Make sure no grails processes are running and connect to the database using a db-tool. Use the same user credentials that you have configured in the grails datasource. This way, you should be able to have the authority to delete the objects that were created by grails. Then find and delete all of the tables that still exist. Once you do this, grails should hopefully be able to start clean. – sCrain Sep 20 '15 at 15:51
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/90166/discussion-between-scrain-and-user734861). – sCrain Sep 20 '15 at 16:02

0 Answers0