Title
c

Christian Strang

01/08/2021, 12:42 PM
Any way to ignore constraints when running a table truncate via
executeRaw
in my seed file? `Raw query failed. Code:
0A000
. Message: `db error: ERROR: cannot truncate a table referenced in a foreign key constraint``
r

Ryan

01/08/2021, 12:48 PM
Hey @Christian Strang 👋 There’s an option to set the variable ``SET FOREIGN_KEY_CHECKS = 0;` to disable checks before performing a truncate but I haven’t tried this.
c

Christian Strang

01/08/2021, 12:50 PM
Thank you, I'll see if I can get it working and post my final query if it does
💯 1
As I'm using postgresql the
SET FOREIGN_KEY_CHECKS = 0
is not an option, I tried it with the postgres equivalent but it also failed. For now its just easier to reset the db as a whole in development, but would be nice if someone found a way to truncate tables while ignoring constraints.
r

Ryan

01/08/2021, 1:12 PM
I think this should work after the following request is supported, but I think resetting and creating the tables again before seeding would be the recommended approach for now.
👍 1