i need to migrate a String column to Boolean (post...
# orm-help
m
i need to migrate a String column to Boolean (postgres), all values are either "Yes" or "No". Postgres is able to natively cast these values to Booleans, but after updating my prisma schema and running
prisma migrate dev
I see this: `The
trust
column on the
Lead
table would be dropped and recreated. This will lead to data loss.` Is it possible to convert this column without data loss? If I just do it in a plain SQL migration, will that mess anything up with Prisma?
r
@Michael Auderer 👋 You can perform this in the following way: 1. Create a migration by changing the column type in
schema.prisma
and run
prisma migrate dev --create-only
. 2. Edit the generated
.sql
file and convert the SQL to an
alter table
command and cast all the values to boolean. 3. Apply the migration using
prisma migrate dev
.