applying migrations... PostgresError: column "x" cannot be cast automatically to type x

when I modify a column from type text to enum
export const channelSubscriptionsTable = pgTable("channel_subscriptions", {
  ...
  subscription_type: text("subscription_type"),
});

to this
export const subscriptionTypeEnum = pgEnum("subscription_type", [
  "free",
  "paid",
]);
export const channelSubscriptionsTable = pgTable("channel_subscriptions", {
  ...
  subscription_type: subscriptionTypeEnum("subscription_type")
});

I got this error
 severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42804',
  hint: 'You might need to specify "USING subscription_type::subscription_type".',
  file: 'tablecmds.c',
  line: '12310',
  routine: 'ATPrepAlterColumnType'

How do I fix this?
Was this page helpful?