Make a partly-undone import retryable, and refuse a plan it cannot deliver

This commit is contained in:
2026-09-03 09:16:01 -04:00
parent b0bd73f62d
commit ddf41c3e65
20 changed files with 588 additions and 37 deletions

View File

@@ -0,0 +1,51 @@
"""Give importbatches.status room for a value longer than 'undone'.
7d37 sized the column String(16), which fitted the two statuses it shipped with.
'partially-undone' - the status an undo writes when some entries reverted and
others hit conflicts - is exactly 16 characters. It fits, with nothing to spare:
the next status anyone adds, or a rename of this one, silently truncates on
MySQL in non-strict mode and errors in strict.
Widened to 32 rather than left at the exact fit, because a column that happens
to be wide enough is not the same as a column that is wide enough.
Revision ID: 7d38_widen_importbatch_status
Revises: 7d37_import_batches_and_journal
"""
from alembic import op
import sqlalchemy as sa
revision = '7d38_widen_importbatch_status'
down_revision = '7d37_import_batches_and_journal'
branch_labels = None
depends_on = None
def _has_table(bind, name):
return sa.inspect(bind).has_table(name)
def upgrade():
bind = op.get_bind()
if not _has_table(bind, 'importbatches'):
return
# SQLite cannot ALTER a column type; it also does not enforce VARCHAR
# length, so there is nothing to widen there.
if bind.dialect.name == 'sqlite':
return
op.alter_column('importbatches', 'status',
existing_type=sa.String(length=16),
type_=sa.String(length=32),
existing_nullable=False)
def downgrade():
bind = op.get_bind()
if not _has_table(bind, 'importbatches') or bind.dialect.name == 'sqlite':
return
op.alter_column('importbatches', 'status',
existing_type=sa.String(length=32),
type_=sa.String(length=16),
existing_nullable=False)