Mysterious Postgres Schema Issue
I have the following
schema.ts
file:
To generate the migration sql I run the following:
And then to complete the migration I run this:
This all works exactly as I would expect, and opening drizzle studio I see the correct columns.
But, for some reason when I switch the uuid from aId to bId it stops working.
In fact, everything I've tried changing it to has resulted in the same error:
I don't see any errors in the SQL code generated but i can send that if any of you think it would be useful. Additionally, I can send my dirzzle.config.ts, package.json, and a photo of my file structure.
Update: I just created a completely new project and was only partially able to reproduce the issue. It doesn't work with aId either now.1 Reply
Update 2: I think the issue could be with the order that Drizzle is creating the tables.
Here's the generated SQL:
And if I just manually swap the order that the tables are created the code runs without errors.
Hmm, I think that what Drizzle is generating should be valid though, right? Maybe this is an issue with my Postgres installation??
Update 3 -- Resolved: Just dropped my database and recreated it, this fixed the issue somehow. If anyone knows why this may have worked please let me know cause I'm curous.