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

Direct Alembic to ignore the sqlite_sequence table #586

Merged
merged 4 commits into from
Apr 26, 2020

Conversation

Andrew-Dickinson
Copy link
Contributor

I believe this fixes both of the database concerns raised in #553:

Starting from this change, when I use alembic to create a new automatic migration (to test something for #557 ), it picks up something strange even if I don't touch the models:

$ python -m ihatemoney.manage db migrate -d ihatemoney/migrations -m test-after-history
INFO  [alembic.autogenerate.compare] Detected removed table 'sqlite_sequence'
  Generating /home/dev/tmp/ihatemoney/ihatemoney/migrations/versions/9c340fd31fff_test_after_history.py ...  done

and

Now I remember that Alembic was giving me a warning about not taking into account ALTER while applying the migration:

INFO  [alembic.runtime.migration] Running upgrade a67119aa3ee5 -> 6c6fb2b7f229, empty message
INFO  [alembic.runtime.migration] Running upgrade 6c6fb2b7f229 -> 2dcb0c0048dc, autologger
/dev/venv3-ihatemoney/lib/python3.8/site-packages/alembic/ddl/sqlite.py:40: UserWarning: Skipping unsupported ALTER for creation of implicit constraint
Please refer to the batch mode feature which allows for SQLite migrations using a copy-and-move strategy.
INFO  [alembic.runtime.migration] Running upgrade 2dcb0c0048dc -> cb038f79982e, sqlite_autoincrement

By directing Alembic to ignore the SQLite built-in table "sqlite_sequence", which according to the documentation is managed automatically by SQLite

@zorun
Copy link
Collaborator

zorun commented Apr 25, 2020

Thanks, it fixed the spurious migration detection Detected removed table 'sqlite_sequence' 👍

However the Skipping unsupported ALTER warning is still there when applying the sqlite_autoincrement migration. If you think that the warning can be ignored, it's fine, because the main issue was the spurious migration.

@Andrew-Dickinson
Copy link
Contributor Author

I did a bit more digging and discovered that the Skipping unsupported ALTER warning was actually coming from the enum type in the autologger migration. By wrapping it in a batch migration I believe that I've fixed it

@zorun
Copy link
Collaborator

zorun commented Apr 26, 2020

Ah right, my bad! The warning is indeed gone 👍

@Natim Natim merged commit 2c32c61 into spiral-project:master Apr 26, 2020
@zorun zorun added this to the v5 milestone Jul 17, 2020
TomRoussel pushed a commit to TomRoussel/ihatemoney that referenced this pull request Mar 2, 2024
* Direct Alembic to ignore the sqlite_sequence table

* Direct Alembic to ignore the sqlite_sequence table

* Fix "Skipping unsupported ALTER" warning on database migration
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

Successfully merging this pull request may close these issues.

3 participants