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

Atlas can't revert back data type that already changed #3081

Open
afifurrohman-id opened this issue Aug 30, 2024 · 2 comments
Open

Atlas can't revert back data type that already changed #3081

afifurrohman-id opened this issue Aug 30, 2024 · 2 comments
Assignees

Comments

@afifurrohman-id
Copy link

Hello in my case i have table:

  • my initial migration
CREATE TABLE "prefix"."a" (yes smallint);
  • 2nd migration (change smallint type to boolean)
ALTER TABLE "prefix"."a" ADD COLUMN "yes_tmp" boolean;

-- Update the new tmp column with value converted to boolean from old column data
UPDATE "prefix"."a" SET "yes_tmp" = CASE WHEN "yes" = 0 THEN FALSE ELSE TRUE END;

-- Drop the old column
ALTER TABLE "prefix"."a" DROP COLUMN "yes";

-- Rename the new tmp column to old column name
ALTER TABLE "prefix"."a" RENAME COLUMN "yes_tmp" TO "yes";

but in my case when i revert / down it can't cast back from boolean to smallint and atlas exit with that error

is there any solution?

@a8m a8m self-assigned this Aug 30, 2024
@afifurrohman-id
Copy link
Author

Hi @a8m also can i ask does atlas have concept called down migration file?

@afifurrohman-id
Copy link
Author

Hi @a8m also can i ask does atlas have concept called down migration file?

okay my bad, based on this docs atlas use different approach: docs

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