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 Report: RenameField and RenameModel operations don't work #51

Open
ThomasAitken opened this issue Jan 24, 2025 · 0 comments
Open

Bug Report: RenameField and RenameModel operations don't work #51

ThomasAitken opened this issue Jan 24, 2025 · 0 comments

Comments

@ThomasAitken
Copy link

First of all, thank you again for this library, and thank you for your recent changes to support MySQL. A follow up on my earlier issue is that I ended up creating a version of this where I alter Django's default dependency graph so that pre-deploy migrations can always be run on their own, even if out of sequence. I am not planning to submit a pull request for this, although please let me know if you are interested in this concept and I can explain more (it relies on the concept that a pre-deploy migration need never actually rely on a post-deploy migration).

Anyhow, this issue is a bug report

First bug

This is a bug that causes migrations containing RenameField and (I suspect) RenameModel operations to fail completely.

Steps to reproduce:

  1. Rename a field
  2. Run makemigrations
  3. Confirm field renaming in questioning flow
  4. Select one of the two latter options

Now try to plan/run the newly generated migration using python manage.py migrate. You get an error trace like this:

  File "/Users/admin/ClipsalRepos/helios/clippy/migrations/0156_rename_nem3_state_tariffrate_nem4_state.py", line 7, in <module>
    class Migration(migrations.Migration):
  File "/Users/admin/ClipsalRepos/helios/clippy/migrations/0156_rename_nem3_state_tariffrate_nem4_state.py", line 14, in Migration
    syzygy.operations.RenameField(),
  File "/Users/admin/Library/Caches/pypoetry/virtualenvs/helios-EL_XmWmL-py3.10/lib/python3.10/site-packages/syzygy/operations.py", line 309, in __init__
    self.stage = kwargs.pop("stage")
KeyError: 'stage'

Commentary

Line 120 in autodetector.py is meant to prevent this: operation = RenameField.for_stage(operation, stage) by re-initialising the operation class with the appropriate stage

But the generated migration uses a new instance of this class, so this line does nothing.

Second Bug

The questioner flow uses 0-based indexing for the choices but it should be 1-based indexing because they're displayed as 1, 2, 3, 4.

Apologies if I somehow misunderstood something with regard to either of these two bugs

@ThomasAitken ThomasAitken changed the title Two Bugs: RenameField and RenameModel operations don't work Bug Report: RenameField and RenameModel operations don't work Jan 24, 2025
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

1 participant