Open ShiftyMcCool opened 1 year ago
Also just happened with changing a text
type to a uuid
so not just an enum issue
Is this still being looked at? Seems to still be happening when changing a column's type.
Also experienced trying to alter column from integer to boolean using generate / pushpg
Got around it using ALTER TABLE "users" ALTER COLUMN "admin" SET DATA TYPE boolean USING (admin::boolean);
Also experienced trying to alter column from integer to boolean using generate / pushpg
Got around it using
ALTER TABLE "users" ALTER COLUMN "admin" SET DATA TYPE boolean USING (admin::boolean);
Where do i use that?
Just noting that this seems to come up pretty frequently when using Payload - essentially anytime you rename something like a radio field, select, etc. and db push
(which is automatic with Payload in development mode) things end up in a bad state with a cannot be cast automatically
error.
Also experienced trying to alter column from integer to boolean using generate / pushpg Got around it using
ALTER TABLE "users" ALTER COLUMN "admin" SET DATA TYPE boolean USING (admin::boolean);
Where do i use that?
In the latest sql file that drizzle kit generated. You just add the last part USING (admin::boolean)
to the end of the line ALTER TABLE "users" ALTER COLUMN "admin" SET DATA TYPE boolean
Just found this comment which explains why the error occurs. If you want to avoid editing sql files then first delete the column and generate a migration, then re-add your edits and generate another migration. https://stackoverflow.com/a/31592810/16335768
What version of
drizzle-orm
are you using?0.27.2
What version of
drizzle-kit
are you using?0.19.10
Describe the Bug
I created a table in a previous migration with a field set for
text
. Later, I updated that field to an enum and generated the SQL.Schema (bits surrounded with ** were added to existing schema):
Generated SQL:
Received this error when attempting to run the generated SQL with the
runMigration()
method:Needed to change the following to allow it to run:
ALTER TABLE "users" ALTER COLUMN "role" SET DATA TYPE user_role **USING (role::user_role)**;
Expected behavior
Generated SQL should cast enums correctly
Environment & setup
No response