alembic: track string field lengths

This commit is contained in:
Lephe 2021-04-25 22:52:13 +02:00
parent d7d8244da9
commit 4be0e1572c
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 61 additions and 2 deletions

View File

@ -41,7 +41,7 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url)
context.configure(url=url, compare_type=True)
with context.begin_transaction():
context.run_migrations()
@ -73,7 +73,8 @@ def run_migrations_online():
context.configure(connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args)
**current_app.extensions['migrate'].configure_args,
compare_type=True)
try:
with context.begin_transaction():

View File

@ -0,0 +1,58 @@
"""update trailing field lengths
Revision ID: 44c2e37ef899
Revises: cfb91e6aa9fc
Create Date: 2021-04-25 22:51:58.510197
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '44c2e37ef899'
down_revision = 'cfb91e6aa9fc'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('guest', 'name',
existing_type=sa.VARCHAR(length=64),
type_=sa.Unicode(length=32),
existing_nullable=True)
op.alter_column('topic', 'title',
existing_type=sa.VARCHAR(length=32),
type_=sa.Unicode(length=128),
existing_nullable=True)
op.alter_column('trophy', 'name',
existing_type=sa.TEXT(),
type_=sa.Unicode(length=64),
existing_nullable=True)
op.alter_column('user', 'type',
existing_type=sa.VARCHAR(length=20),
type_=sa.String(length=30),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('user', 'type',
existing_type=sa.String(length=30),
type_=sa.VARCHAR(length=20),
existing_nullable=True)
op.alter_column('trophy', 'name',
existing_type=sa.Unicode(length=64),
type_=sa.TEXT(),
existing_nullable=True)
op.alter_column('topic', 'title',
existing_type=sa.Unicode(length=128),
type_=sa.VARCHAR(length=32),
existing_nullable=True)
op.alter_column('guest', 'name',
existing_type=sa.Unicode(length=32),
type_=sa.VARCHAR(length=64),
existing_nullable=True)
# ### end Alembic commands ###