Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Planner creates failing ALTER COLUMN for column changing from int to enum #3130

Open
dolzenko opened this issue Sep 19, 2024 · 1 comment
Open
Assignees

Comments

@dolzenko
Copy link

dolzenko commented Sep 19, 2024

I'm using atlas schema apply with 2 DBs, one has the column lang_code defined as TEXT another as ENUM, so Atlas generates the ALTER TABLE but it can't proceed. Is that a bug in convergence code?

  -- modify "characteristics_localization" table
    -> ALTER TABLE "public"."characteristics_localization" ALTER COLUMN "lang_code" TYPE "public"."lang_code";
    pq: column "lang_code" cannot be cast automatically to type lang_code

  -------------------------
  -- 24.95230433s
  -- 1 migration with errors
  -- 16 sql statements ok, 1 with errors
Error: executing statement "ALTER TABLE \"public\".\"characteristics_localization\" ALTER COLUMN \"lang_code\" TYPE \"public\".\"lang_code\";": pq: column "lang_code" cannot be cast automatically to type lang_code

What I mean by that is that it could easily see that this won't work and warn me some time earlier on, or is it by design?

@a8m
Copy link
Member

a8m commented Sep 19, 2024

Hey @dolzenko!

The planner can be smarter here, by adding pre-migration checks and let you control the type conversion. For now, I'll suggest you to run schema apply with the --edit flag and modify this statement.

I'll keep this issue open and assign it to myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants