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
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
I got an error saying it can't automatically cast to uuid
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.Take a look a this for a general guidance https://stackoverflow.com/questions/75481238/postgresql-migration-from-idbigint-to-iduuid-while-preserving-relations
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...