gh-ost icon indicating copy to clipboard operation
gh-ost copied to clipboard

ENUM to Varchar

Open disser4 opened this issue 2 years ago • 1 comments

Getting a weird error via gh-ost. We are trying to alter a table from an ENUM to a Varchar

2022-10-13 04:47:38 FATAL Error 1048: Column 'payment_type' cannot be null; query=
                        update /* gh-ost `customcheckout`.`_purchase_gho` */
                                        `customcheckout`.`_purchase_gho

This also happened when we were not changing this column. It's almost like gh-ost can't use the default data type on the new column.

ALTER TABLE purchase CHANGE COLUMN payment_type payment_type varchar(255) not null default 'CREDIT_CARD';

Any idea why gh-ost quietly fails? It seems like after a random time, it just fails.

disser4 avatar Oct 13 '22 17:10 disser4

:wave: @disser4 it sounds like the problem is that you are trying to change the field payment_type to not null, but payment_type is null for some rows. This is a data issue rather than a gh-ost issue - you'll either need to populate payment_type in all rows with a value before running your schema migration, or remove the not null constraint from the schema migration.

dm-2 avatar Oct 21 '22 16:10 dm-2