DT
Drizzle Team•2mo ago
Jack

Drizzle migration, any way to create an index BEFORE the constraints are added to tables?

I have a multi-tenanted application whereby I store the tenant ID on as many tables as possible. I want to ensure each table has the correct pairing of the userId to the tenantId using a unique index pairing the two columns in the users table, then enforcing that pairing as a foreign key constraint on the tables that reference a userId and tenantId. However, the generated migration file creates the indexes AFTER the constraints are added, causing the migration to fail. I can edit this migration and move the line further up, but for me that defeats the purpose of a lot of the autonomy migrations give me. 😅 Any ideas or help? Thanks a lot
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server