"""add program metadata and a base for events

Revision ID: ba47de949e59
Revises: daa5d5913ef8
Create Date: 2022-06-16 12:05:40.797694

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ba47de949e59'
down_revision = 'daa5d5913ef8'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('event',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.Unicode(length=128), nullable=True),
    sa.Column('main_topic', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['main_topic'], ['topic.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('program', sa.Column('real_author', sa.Unicode(length=128), nullable=True))
    op.add_column('program', sa.Column('version', sa.Unicode(length=64), nullable=True))
    op.add_column('program', sa.Column('size', sa.Unicode(length=64), nullable=True))
    op.add_column('program', sa.Column('license', sa.String(length=32), nullable=True))
    op.add_column('program', sa.Column('label', sa.Boolean(), server_default='FALSE', nullable=False))
    op.add_column('program', sa.Column('event', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'program', 'event', ['event'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'program', type_='foreignkey')
    op.drop_column('program', 'event')
    op.drop_column('program', 'label')
    op.drop_column('program', 'license')
    op.drop_column('program', 'size')
    op.drop_column('program', 'version')
    op.drop_column('program', 'real_author')
    op.drop_table('event')
    # ### end Alembic commands ###
