alembic-postgresql-enum icon indicating copy to clipboard operation
alembic-postgresql-enum copied to clipboard

Do not ignore Alembic migration context prefixes when generating migrations

Open Jazzinghen opened this issue 8 months ago • 0 comments

Description

When generating the migrations alembic-postgresql-enum assumes that both SQLalchemy and Alembic's module prefixes are the default ones.

To fix this issue the following changes have been introduced:

  • Extract both information when creating Enums and use them in the generated python strings
  • Extract Alembic module prefix when handling Enum synchronizations
  • Updated testing framework to customize the migration environment for a test
  • Added a schema creation test with custom module prefixes

I had to disable running the test TestNewArrayColumnColumnCustomContext as how they are executed does not allow (at least to the extent of my knowledge) using "nested" modules (e.g. alembic.op breaks with FAILED sync_enum_values/test_run_array_new_column.py::TestNewArrayColumnColumnCustomContext::test_run - NameError: name 'alembic' is not defined).

Checklist

This pull request is:

  • [ ] A documentation / typographical / small typing error fix
    • Good to go, no issue or tests are needed
  • [x] A short code fix
    • please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • [ ] A new feature implementation
    • please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

Jazzinghen avatar Apr 24 '25 02:04 Jazzinghen