Custom migration

I have a user table where the userId (FK) is a serial and I want to convert it to uuid. There is already data in that table. How can i do this custom migration? Do I need to create a custom migration file and write the DML?
4 Replies
Angelelz
Angelelz4w ago
I’m not totally sure but I think drizzle-kit can do this for you You can change the column data type and generate the migration just to see what it does, if you don’t like it you can always drop the migration
CaptainFantastic
CaptainFantasticOP4w ago
I got an error saying it can't automatically cast to uuid
Angelelz
Angelelz4w ago
Then custom is the way to go. You can run drizzle kit with the --custom option. This will create an empty sql migration where you can add all your logic.
Angelelz
Angelelz4w ago
Stack Overflow
PostgreSQL migration from id(bigint) to id(uuid) while preserving r...
I have many tables and a lot of data and I would like to change all primary key types from bigint to uuid type. I have no idea how to preserve relations. Here is an example. This means I am plannin...
Want results from more Discord servers?
Add your server