<filename>migrations/versions/f415d880664f_add_the_table_forum.py
"""Add the table Forum

Revision ID: f<PASSWORD>880664f
Revises: <PASSWORD>
Create Date: 2021-02-15 02:40:36.669342

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f<PASSWORD>'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('forum',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('short_name', sa.String(length=32), nullable=True),
    sa.Column('creator_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['creator_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_forum_name'), 'forum', ['name'], unique=True)
    op.create_index(op.f('ix_forum_short_name'), 'forum', ['short_name'], unique=True)
    op.add_column('thread', sa.Column('creator_id', sa.Integer(), nullable=True))
    op.add_column('thread', sa.Column('forum_id', sa.Integer(), nullable=True))
    op.drop_constraint('thread_short_name_key', 'thread', type_='unique')
    op.drop_constraint('thread_author_id_fkey', 'thread', type_='foreignkey')
    op.create_foreign_key(None, 'thread', 'users', ['creator_id'], ['id'])
    op.create_foreign_key(None, 'thread', 'forum', ['forum_id'], ['id'])
    op.drop_column('thread', 'author_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('thread', sa.Column('author_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'thread', type_='foreignkey')
    op.drop_constraint(None, 'thread', type_='foreignkey')
    op.create_foreign_key('thread_author_id_fkey', 'thread', 'users', ['author_id'], ['id'])
    op.create_unique_constraint('thread_short_name_key', 'thread', ['short_name'])
    op.drop_column('thread', 'forum_id')
    op.drop_column('thread', 'creator_id')
    op.drop_index(op.f('ix_forum_short_name'), table_name='forum')
    op.drop_index(op.f('ix_forum_name'), table_name='forum')
    op.drop_table('forum')
    # ### end Alembic commands ###

<filename>migrations/versions/f415d880664f_add_the_table_forum.py
"""Add the table Forum

Revision ID: f<PASSWORD>880664f
Revises: <PASSWORD>
Create Date: 2021-02-15 02:40:36.669342

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f<PASSWORD>'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('forum',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('short_name', sa.String(length=32), nullable=True),
    sa.Column('creator_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['creator_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_forum_name'), 'forum', ['name'], unique=True)
    op.create_index(op.f('ix_forum_short_name'), 'forum', ['short_name'], unique=True)
    op.add_column('thread', sa.Column('creator_id', sa.Integer(), nullable=True))
    op.add_column('thread', sa.Column('forum_id', sa.Integer(), nullable=True))
    op.drop_constraint('thread_short_name_key', 'thread', type_='unique')
    op.drop_constraint('thread_author_id_fkey', 'thread', type_='foreignkey')
    op.create_foreign_key(None, 'thread', 'users', ['creator_id'], ['id'])
    op.create_foreign_key(None, 'thread', 'forum', ['forum_id'], ['id'])
    op.drop_column('thread', 'author_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('thread', sa.Column('author_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'thread', type_='foreignkey')
    op.drop_constraint(None, 'thread', type_='foreignkey')
    op.create_foreign_key('thread_author_id_fkey', 'thread', 'users', ['author_id'], ['id'])
    op.create_unique_constraint('thread_short_name_key', 'thread', ['short_name'])
    op.drop_column('thread', 'forum_id')
    op.drop_column('thread', 'creator_id')
    op.drop_index(op.f('ix_forum_short_name'), table_name='forum')
    op.drop_index(op.f('ix_forum_name'), table_name='forum')
    op.drop_table('forum')
    # ### end Alembic commands ###

Add the table Forum  Revision ID: f<PASSWORD>880664f Revises: <PASSWORD> Create Date: 2021-02-15 02:40:36.669342 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###