Drizzle schema vs SQL when migrating serial id to uuid?
I have a Postgres DB and I want to migrate serial primary key IDs to UUIDs, and I'm running into some potential issues here.
I've already added the
Problem 1:
To prevent having to update my whole application code, I want to basically swap the ID and UUID columns and let them keep the
Is this something I can solve by editing my schema, or would this be something I need to do by running SQL queries?
Problem 2:
If I need to do this via SQL queries, how do I then reflect this new state in my Drizzle schema? Maybe introspecting would be a good option here?
Or maybe I should just change my schema, generate a migration and then edit the migration by hand before running it?
Note: this is a development database migration, so this is essentially practice for whenever I might need to do something similar in prod
I've already added the
uuid columns and user_uuid, thing_uuid relation columns to my tables via my Drizzle schema. Using PgAdmin I verified that the various uuid columns are not empty, and I've filled the relational UUIDs with queries like this one:Problem 1:
To prevent having to update my whole application code, I want to basically swap the ID and UUID columns and let them keep the
id and user_id column names, but with uuid primary keys of course.Is this something I can solve by editing my schema, or would this be something I need to do by running SQL queries?
Problem 2:
If I need to do this via SQL queries, how do I then reflect this new state in my Drizzle schema? Maybe introspecting would be a good option here?
Or maybe I should just change my schema, generate a migration and then edit the migration by hand before running it?
Note: this is a development database migration, so this is essentially practice for whenever I might need to do something similar in prod