62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
|
"""empty message
|
||
|
|
||
|
Revision ID: fa9fad0a40c3
|
||
|
Revises: 31f169c37c61
|
||
|
Create Date: 2023-04-07 18:05:59.713134
|
||
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
from sqlalchemy.dialects import mysql
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = 'fa9fad0a40c3'
|
||
|
down_revision = '31f169c37c61'
|
||
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.create_table('img_attrs',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=128), nullable=True),
|
||
|
sa.Column('path', sa.String(length=128), nullable=True),
|
||
|
sa.Column('post_id', sa.Integer(), nullable=True),
|
||
|
sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
with op.batch_alter_table('posts', schema=None) as batch_op:
|
||
|
batch_op.add_column(sa.Column('img_count', sa.Integer(), nullable=True))
|
||
|
batch_op.alter_column('title',
|
||
|
existing_type=mysql.TEXT(),
|
||
|
nullable=False)
|
||
|
batch_op.alter_column('content',
|
||
|
existing_type=mysql.TEXT(),
|
||
|
nullable=False)
|
||
|
batch_op.alter_column('author_id',
|
||
|
existing_type=mysql.INTEGER(display_width=11),
|
||
|
nullable=False)
|
||
|
batch_op.drop_column('img_path')
|
||
|
|
||
|
# ### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
with op.batch_alter_table('posts', schema=None) as batch_op:
|
||
|
batch_op.add_column(sa.Column('img_path', mysql.VARCHAR(length=64), nullable=True))
|
||
|
batch_op.alter_column('author_id',
|
||
|
existing_type=mysql.INTEGER(display_width=11),
|
||
|
nullable=True)
|
||
|
batch_op.alter_column('content',
|
||
|
existing_type=mysql.TEXT(),
|
||
|
nullable=True)
|
||
|
batch_op.alter_column('title',
|
||
|
existing_type=mysql.TEXT(),
|
||
|
nullable=True)
|
||
|
batch_op.drop_column('img_count')
|
||
|
|
||
|
op.drop_table('img_attrs')
|
||
|
# ### end Alembic commands ###
|