diff options
| author | Daniel Schadt <kingdread@gmx.de> | 2022-12-19 21:09:36 +0100 | 
|---|---|---|
| committer | Daniel Schadt <kingdread@gmx.de> | 2022-12-19 21:09:36 +0100 | 
| commit | 8396483882a5beed915f2560325721934f58a37c (patch) | |
| tree | 7ece6d1b0d40b85ea3978e2ad2193fd6dfea4432 | |
| parent | 914d11c84198295a9f09756fe436f3114d4b0075 (diff) | |
| download | fietsboek-8396483882a5beed915f2560325721934f58a37c.tar.gz fietsboek-8396483882a5beed915f2560325721934f58a37c.tar.bz2 fietsboek-8396483882a5beed915f2560325721934f58a37c.zip  | |
output error when DROP COLUMN fails
In case it might be caused by something else than SQLite's inability to
delete a column, it's good to have the actual error written out
somewhere.
| -rw-r--r-- | fietsboek/alembic/versions/20221214_c939800af428.py | 12 | 
1 files changed, 8 insertions, 4 deletions
diff --git a/fietsboek/alembic/versions/20221214_c939800af428.py b/fietsboek/alembic/versions/20221214_c939800af428.py index 79ec899..4b07983 100644 --- a/fietsboek/alembic/versions/20221214_c939800af428.py +++ b/fietsboek/alembic/versions/20221214_c939800af428.py @@ -20,14 +20,15 @@ def upgrade():      # ### commands auto generated by Alembic - please adjust! ###      try:          op.drop_column('tracks', 'gpx') -    except sa.exc.OperationalError: +    except sa.exc.OperationalError as exc:          # sqlite < 3.35.0 does not know "ALTER TABLE DROP COLUMN", in which          # case we probably don't want to break the DB. Instead, we simply          # "drop" the column by setting it empty, which should still help in          # saving some space.          logging.getLogger(__name__).warning(              "Your database does not support dropping a column. " -            "We're setting the content to zero instead." +            "We're setting the content to zero instead (%s).", +            exc,          )          op.execute("UPDATE tracks SET gpx = '';")      # ### end Alembic commands ### @@ -36,6 +37,9 @@ def downgrade():      # ### commands auto generated by Alembic - please adjust! ###      try:          op.add_column('tracks', sa.Column('gpx', sa.BLOB(), nullable=True)) -    except sa.exc.OperationalError: -        logging.getLogger(__name__).warning("The column already exists.") +    except sa.exc.OperationalError as exc: +        logging.getLogger(__name__).warning( +            "The column already exists - doing nothing (%s).", +            exc, +        )      # ### end Alembic commands ###  | 
