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

[BUG]: truncated tables on ALTER COLUMN statements #4245

Open
1 task done
ORESoftware opened this issue Mar 9, 2025 · 1 comment
Open
1 task done

[BUG]: truncated tables on ALTER COLUMN statements #4245

ORESoftware opened this issue Mar 9, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@ORESoftware
Copy link

ORESoftware commented Mar 9, 2025

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

drizzle-orm: v0.39.3

What version of drizzle-kit are you using?

drizzle-kit: v0.30.4 drizzle-orm: v0.39.3

Other packages

drizzle-kit: v0.30.4 drizzle-orm: v0.39.3

Describe the Bug

https://gist.github.com/ORESoftware/d74b1e6ffd7f02fd658d28c5597a3367

doing migration with Drizzle ORM delete/truncated all data from our "skills" table:

ALTER TABLE "skills" ALTER COLUMN "skill_desc" SET DATA TYPE jsonb;
ALTER TABLE "skills" ALTER COLUMN "skill_desc" SET DEFAULT '[]'::jsonb;
ALTER TABLE "skills" ALTER COLUMN "skill_desc" SET NOT NULL;

the initial error was that I could not convert skill_desc from text to jsonb automatically

not sure how it could ever result in truncating the whole table regardless....

it's happened more than once, so I need to figure out how to mitigate this :(

those statements were the ones printed and I assume they ran in that order....

@ORESoftware ORESoftware added the bug Something isn't working label Mar 9, 2025
@ORESoftware
Copy link
Author

ORESoftware commented Mar 9, 2025

note those ALTER statements alone aren't capable of truncating a table, so it might be something else that drizzle is running? Crazy and scary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant