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

"Alter" field doesn't alter enum #5

Open
gammelalf opened this issue Oct 6, 2023 · 1 comment
Open

"Alter" field doesn't alter enum #5

gammelalf opened this issue Oct 6, 2023 · 1 comment

Comments

@gammelalf
Copy link
Member

On postgres:
When adding a new enum variant, the drop column doesn't delete the enum type, so the new creation is ignored

@WebFreak001
Copy link
Member

WebFreak001 commented Dec 19, 2023

the issue, at least on postgres, is actually that there is never any new type creation being done.

On CreateField the pre_statements field is set to None, making it not try to CREATE TYPE, at least in postgres.

Only on CreateModel the pre_statements are generated and evaluated.

so there are two things to fix here:

  1. CreateField is broken with enums (choice), because it never creates the type (also making it not error here for you, since there is no attempt to re-create an existing type)
  2. there should be a proper AlterField or more fine grained alternatives such as AddChoice/RemoveChoice - also so that choice fields are not deleted and recreated in production

As well as arguably DeleteField with choice should probably delete the enum type that was created beforehand.

to work around this while keeping migration-generating capabilities, it would also be nice to be able to create raw SQL statements that set structure_safe, but still have some kind of internal CreateField/DeleteField steps so that the rorm-cli internal model would understand what is being done. (tracking issue: #6)

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