Alembic not going back to previous migration?
Currently, I am working on this PR. A problem arose with some SQLite tests and I made changes to the latest migration file.
This is my output of alembic -c src/mailman/config/alembic.cfg history
command
2d2d0ef0828f -> 58858f75303c (head), Added new bounce attributes 15401063d4e3 -> 2d2d0ef0828f, add tag column b2e694dfde35 -> 15401063d4e3, roster_visibility 89913992dd5a -> b2e694dfde35, unique email contraint dfe82cf73702 -> 89913992dd5a, remove mime_is_default_digest 3f31035ed0d7 -> dfe82cf73702, add_alias_domain 4bd95c99b2e7 -> 3f31035ed0d7, further_increase_pendedkeyvalue_value_size 3002bac0c25a -> 4bd95c99b2e7, Fix template password field. a46993b05703 -> 3002bac0c25a, dmarc_attributes 448a93984c35 -> a46993b05703, increase pendedkeyvalue value size fa0d96e28631 -> 448a93984c35, unsubscription_workflow 7b254d88f122 -> fa0d96e28631, File cache and template manager. d4fbb4fd34ca -> 7b254d88f122, Members and list moderation action. bfda02ab3a9b -> d4fbb4fd34ca, Add a numerical position column to sort header matches. 781a38e146bf -> bfda02ab3a9b, Ban indexes 70af5a4e5790 -> 781a38e146bf, MailingList indexes 47294d3a604 -> 70af5a4e5790, digests 3e09bb4a5dc -> 47294d3a604, Pendable indexes 33bc0099223 -> 3e09bb4a5dc, Add indexes on the Member table. 42756496720 -> 33bc0099223, Add member indexes 2bb9b382198 -> 42756496720, header_matches 16c2b25c7b -> 2bb9b382198, Workflow state table 46e92facee7 -> 16c2b25c7b, List subscription policy 33e1f5f6fa8 -> 46e92facee7, add_serverowner_domainowner 51b7f92bd06c -> 33e1f5f6fa8, Migration from Python 2 to Python 3. <base> -> 51b7f92bd06c, Initial migration.
On doing alembic -c src/mailman/config/alembic.cfg current -v
Current revision(s) for sqlite:////home/aaryan/mailman/mailman/var/data/mailman.db: Rev: 2d2d0ef0828f Parent: 15401063d4e3 Path: /home/aaryan/mailman/mailman/src/mailman/database/alembic/versions/2d2d0ef0828f_add_tag_column.py
add tag column
Revision ID: 2d2d0ef0828f Revises: 15401063d4e3 Create Date: 2019-04-27 08:58:48.496854
But when I run alembic -c src/mailman/config/alembic.cfg upgrade head
. It gives a long traceback, the main gist of which is
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) duplicate column name: bounce_info [SQL: 'ALTER TABLE address ADD COLUMN bounce_info BLOB'] (Background on this error at: >http://sqlalche.me/e/e3q8)
The whole traceback is [here[(https://gist.github.com/berserker1/6b214626042a6c976f780b33d2d12f32)
I did alembic -c src/mailman/config/alembic.cfg downgrade 2d2d0ef0828f
to ensure it has restored to the previous version but still, again the error pops up
Basically, Alembic is not able to properly downgrade and hence recognising a duplicate column when I upgrade.
Any pointer to this would be helpful.
I will explain a little bit more what I exactly did, I downgraded alembic to 2d2d0ef0828f
version, made changes to 58858f75303c
migration file and then tried to upgrade again but alembic is recognising duplicating columns which means it has not downgraded properly, can we somehow erase all changes keep till 2d2d0ef0828f
version somehow cleanly?
Pointers on this are required.
On 6/28/19 2:59 PM, Aaryan Bhagat wrote:
I will explain a little bit more what I exactly did, I downgraded alembic to
2d2d0ef0828f
version, made changes to58858f75303c
migration file and then tried to upgrade again but alembic is recognising duplicating columns which means it has not downgraded properly, can we somehow erase all changes keep till2d2d0ef0828f
version somehow cleanly?
Pointers on this are required.
It's not alembic's fault. It's sqlite which can't remove a column. You have to test for things like this. There are examples in the existing migrations such as 46e92facee7_add_serverowner_domainowner.py.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Aaryan Bhagat
-
Mark Sapiro