epicweb-dev / epic-stack

This is a Full Stack app starter with the foundational things setup and configured for you to hit the ground running on your next EPIC idea.
https://www.epicweb.dev/epic-stack
MIT License
4.32k stars 355 forks source link

Fix `cleanupDb` when foreign key constraints exist #795

Closed ovistoica closed 1 month ago

ovistoica commented 1 month ago

PR to address https://github.com/epicweb-dev/epic-stack/issues/791

Test Plan

If the npm run setup works as expected, the seeding and the db cleanup works correctly.

To test this fix fully, we'd need to add some data to the database with FK constraints, not have ON DELETE CASCADE on it, and expect cleanupDb to succeed.

Also, another good test would be to monkey patch the cleanupDb to throw inside the transaction and expect foreign_keys to be still on (catch clause reached)

Checklist

Screenshots