52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
"""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)
|