"""empty message

Revision ID: b03df3e31b8d
Revises: 
Create Date: 2021-08-11 12:46:17.757283

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('label_provider',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('root_folder', sa.String(), nullable=False),
    sa.Column('configuration_file', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('root_folder', 'configuration_file')
    )
    op.create_table('model',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('root_folder', sa.String(), nullable=False),
    sa.Column('supports_encoded', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('root_folder')
    )
    op.create_table('project',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=False),
    sa.Column('model_id', sa.Integer(), nullable=True),
    sa.Column('label_provider_id', sa.Integer(), nullable=True),
    sa.Column('root_folder', sa.String(), nullable=False),
    sa.Column('external_data', sa.Boolean(), nullable=False),
    sa.Column('data_folder', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['label_provider_id'], ['label_provider.id'], ondelete='SET NULL'),
    sa.ForeignKeyConstraint(['model_id'], ['model.id'], ondelete='SET NULL'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('root_folder')
    )
    op.create_index(op.f('ix_project_created'), 'project', ['created'], unique=False)
    op.create_table('collection',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('reference', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('position', sa.Integer(), nullable=False),
    sa.Column('autoselect', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('project_id', 'reference')
    )
    op.create_table('label',
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('parent_id', sa.Integer(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=False),
    sa.Column('reference', sa.String(), nullable=True),
    sa.Column('hierarchy_level', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['parent_id'], ['label.id'], ondelete='SET NULL'),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('project_id', 'reference')
    )
    op.create_index(op.f('ix_label_created'), 'label', ['created'], unique=False)
    op.create_table('file',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('uuid', sa.String(), nullable=False),
    sa.Column('extension', sa.String(), nullable=False),
    sa.Column('type', sa.String(), nullable=False),
    sa.Column('size', sa.Integer(), nullable=False),
    sa.Column('created', sa.DateTime(), nullable=False),
    sa.Column('path', sa.String(), nullable=False),
    sa.Column('frames', sa.Integer(), nullable=True),
    sa.Column('fps', sa.Float(), nullable=True),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('collection_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['collection_id'], ['collection.id'], ondelete='SET NULL'),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('project_id', 'path')
    )
    op.create_index(op.f('ix_file_created'), 'file', ['created'], unique=False)
    op.create_table('result',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('file_id', sa.Integer(), nullable=False),
    sa.Column('origin', sa.String(), nullable=False),
    sa.Column('type', sa.String(), nullable=False),
    sa.Column('label_id', sa.Integer(), nullable=True),
    sa.Column('data_encoded', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['file_id'], ['file.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['label_id'], ['label.id'], ondelete='SET NULL'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('result')
    op.drop_index(op.f('ix_file_created'), table_name='file')
    op.drop_table('file')
    op.drop_index(op.f('ix_label_created'), table_name='label')
    op.drop_table('label')
    op.drop_table('collection')
    op.drop_index(op.f('ix_project_created'), table_name='project')
    op.drop_table('project')
    op.drop_table('model')
    op.drop_table('label_provider')
    # ### end Alembic commands ###
