1
votes

I am using grails 3.3.2. Is there any way to remove the auto generated foreign key constraints? Thanks.

I have tried:

  1. grails schema-export

  2. remove those lines like "alter table xxx add constraint yyy foreign key zzzz..."

  3. change dbCreate: none

But it's not convenient especially when domain class changed.

1
Why do you need this? Can you give an example?Evgeny Smirnov
It's a read only application. It's not convenient while importing data.yang wang
Do you want it remove permanently or temporary?Nitin Dhomse

1 Answers

0
votes

You have the 2 options to remove the foreign key constraints of your database.

  1. Remove static belongsTo from your domain class which is mapping to another domain ( database table )

OR

  1. You can do foreign key check off at the database level from database console (for MySql) as follows but, be careful while doing this, this may violate your foreign key constraint rule.

    SET FOREIGN_KEY_CHECKS = 0; // disable foreign key check
    SET FOREIGN_KEY_CHECKS = 1; // enable foreign key check