Skip to content

Override SQLAlchemy drop_all() to call drop_alembic_version_table() #98

@ntarocco

Description

@ntarocco

As spotted by @dinosk in this troubleshooting, the call to db.drop_all() will NOT delete the alembic table alembic_version.

This can lead to several unpredictable issues.
The drop_all() method should drop ALL tables, and not left something behind.
A workaround has been provided with the method invenio_db.utils.drop_alembic_version_table().

Proposed solution
Override the SQLAlchemy db.drop_all() method to (pseudo-code):

def def drop_all():
    super()
    drop_alembic_version_table()

WARNING: this modification can potentially break other modules' tests. Moreover, whenever the function drop_alembic_version_table() is used after a drop_all(), it should be cleaned up.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions