"""adds models 2.0

Revision ID: a7882a87de99
Revises: <PASSWORD>
Create Date: 2022-03-03 21:50:30.137666

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('sessions',
                    sa.Column('id', postgresql.UUID(
                        as_uuid=True), nullable=False),
                    sa.Column('start', sa.DateTime(), nullable=False),
                    sa.Column('end', sa.DateTime(), nullable=False),
                    sa.Column('finished', sa.Boolean(), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('storage',
                    sa.Column('id', postgresql.UUID(
                        as_uuid=True), nullable=False),
                    sa.Column('name', sa.String(), nullable=False),
                    sa.Column('quantity', sa.Integer(), nullable=False),
                    sa.Column('description', sa.Text(), nullable=True),
                    sa.Column('validity', sa.Date(), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('tattoo_images',
                    sa.Column('id', postgresql.UUID(
                        as_uuid=True), nullable=False),
                    sa.Column('image_bin', sa.LargeBinary(), nullable=False),
                    sa.Column('image_name', sa.String(), nullable=False),
                    sa.Column('iamge_mimetype', sa.String(), nullable=False),
                    sa.Column('id_tattoo', postgresql.UUID(
                        as_uuid=True), nullable=True),
                    sa.ForeignKeyConstraint(['id_tattoo'], ['tattoos.id'], ),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.add_column('clients', sa.Column(
        'image_name', sa.String(), nullable=True))
    op.add_column('clients', sa.Column(
        'image_bin', sa.LargeBinary(), nullable=True))
    op.add_column('clients', sa.Column(
        'image_mimetype', sa.String(), nullable=True))
    op.add_column('materials', sa.Column(
        'id_storage', postgresql.UUID(as_uuid=True), nullable=True))
    op.add_column('materials', sa.Column(
        'id_tattoo', postgresql.UUID(as_uuid=True), nullable=True))
    op.drop_constraint('materials_id_product_fkey',
                       'materials', type_='foreignkey')
    op.drop_constraint('materials_id_order_fkey',
                       'materials', type_='foreignkey')
    op.create_foreign_key(None, 'materials', 'tattoos', ['id_tattoo'], ['id'])
    op.create_foreign_key(None, 'materials', 'storage', ['id_storage'], ['id'])
    op.drop_column('materials', 'id_order')
    op.drop_column('materials', 'id_product')
    op.add_column('tattooists', sa.Column(
        'image_name', sa.String(), nullable=True))
    op.add_column('tattooists', sa.Column(
        'image_bin', sa.LargeBinary(), nullable=True))
    op.add_column('tattooists', sa.Column(
        'image_mimetype', sa.String(), nullable=True))
    op.add_column('tattoos', sa.Column(
        'id_session', postgresql.UUID(as_uuid=True), nullable=True))
    op.alter_column('tattoos', 'colors',
                    existing_type=sa.BOOLEAN(),
                    nullable=False)
    op.drop_constraint('tattoos_id_event_fkey', 'tattoos', type_='foreignkey')
    op.create_foreign_key(None, 'tattoos', 'sessions', ['id_session'], ['id'])
    op.drop_column('tattoos', 'duration')
    op.drop_column('tattoos', 'id_event')
    op.drop_table('orders')
    op.drop_table('products')
    op.drop_table('events')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('tattoos', sa.Column(
        'id_event', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('tattoos', sa.Column('duration', sa.INTEGER(),
                  autoincrement=False, nullable=False))
    op.drop_constraint(None, 'tattoos', type_='foreignkey')
    op.create_foreign_key('tattoos_id_event_fkey', 'tattoos',
                          'events', ['id_event'], ['id'])
    op.alter_column('tattoos', 'colors',
                    existing_type=sa.BOOLEAN(),
                    nullable=True)
    op.drop_column('tattoos', 'id_session')
    op.drop_column('tattooists', 'image_mimetype')
    op.drop_column('tattooists', 'image_bin')
    op.drop_column('tattooists', 'image_name')
    op.add_column('materials', sa.Column(
        'id_product', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('materials', sa.Column(
        'id_order', postgresql.UUID(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'materials', type_='foreignkey')
    op.drop_constraint(None, 'materials', type_='foreignkey')
    op.create_foreign_key('materials_id_order_fkey',
                          'materials', 'orders', ['id_order'], ['id'])
    op.create_foreign_key('materials_id_product_fkey',
                          'materials', 'products', ['id_product'], ['id'])
    op.drop_column('materials', 'id_tattoo')
    op.drop_column('materials', 'id_storage')
    op.drop_column('clients', 'image_mimetype')
    op.drop_column('clients', 'image_bin')
    op.drop_column('clients', 'image_name')
    op.create_table('events',
                    sa.Column('id', postgresql.UUID(),
                              autoincrement=False, nullable=False),
                    sa.Column('date', sa.DATE(),
                              autoincrement=False, nullable=True),
                    sa.Column('start', postgresql.TIMESTAMP(),
                              autoincrement=False, nullable=True),
                    sa.Column('end', postgresql.TIMESTAMP(),
                              autoincrement=False, nullable=True),
                    sa.Column('finished', sa.BOOLEAN(),
                              autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='events_pkey'),
                    postgresql_ignore_search_path=False
                    )
    op.create_table('products',
                    sa.Column('id', postgresql.UUID(),
                              autoincrement=False, nullable=False),
                    sa.Column('name', sa.VARCHAR(),
                              autoincrement=False, nullable=False),
                    sa.Column('quantity', sa.INTEGER(),
                              autoincrement=False, nullable=False),
                    sa.Column('description', sa.TEXT(),
                              autoincrement=False, nullable=True),
                    sa.Column('validity', sa.DATE(),
                              autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='products_pkey')
                    )
    op.create_table('orders',
                    sa.Column('id', postgresql.UUID(),
                              autoincrement=False, nullable=False),
                    sa.Column('id_tattoo', postgresql.UUID(),
                              autoincrement=False, nullable=True),
                    sa.ForeignKeyConstraint(
                        ['id_tattoo'], ['tattoos.id'], name='orders_id_tattoo_fkey'),
                    sa.PrimaryKeyConstraint('id', name='orders_pkey')
                    )
    op.drop_table('tattoo_images')
    op.drop_table('storage')
    op.drop_table('sessions')
    # ### end Alembic commands ###

"""adds models 2.0

Revision ID: a7882a87de99
Revises: <PASSWORD>
Create Date: 2022-03-03 21:50:30.137666

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('sessions',
                    sa.Column('id', postgresql.UUID(
                        as_uuid=True), nullable=False),
                    sa.Column('start', sa.DateTime(), nullable=False),
                    sa.Column('end', sa.DateTime(), nullable=False),
                    sa.Column('finished', sa.Boolean(), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('storage',
                    sa.Column('id', postgresql.UUID(
                        as_uuid=True), nullable=False),
                    sa.Column('name', sa.String(), nullable=False),
                    sa.Column('quantity', sa.Integer(), nullable=False),
                    sa.Column('description', sa.Text(), nullable=True),
                    sa.Column('validity', sa.Date(), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('tattoo_images',
                    sa.Column('id', postgresql.UUID(
                        as_uuid=True), nullable=False),
                    sa.Column('image_bin', sa.LargeBinary(), nullable=False),
                    sa.Column('image_name', sa.String(), nullable=False),
                    sa.Column('iamge_mimetype', sa.String(), nullable=False),
                    sa.Column('id_tattoo', postgresql.UUID(
                        as_uuid=True), nullable=True),
                    sa.ForeignKeyConstraint(['id_tattoo'], ['tattoos.id'], ),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.add_column('clients', sa.Column(
        'image_name', sa.String(), nullable=True))
    op.add_column('clients', sa.Column(
        'image_bin', sa.LargeBinary(), nullable=True))
    op.add_column('clients', sa.Column(
        'image_mimetype', sa.String(), nullable=True))
    op.add_column('materials', sa.Column(
        'id_storage', postgresql.UUID(as_uuid=True), nullable=True))
    op.add_column('materials', sa.Column(
        'id_tattoo', postgresql.UUID(as_uuid=True), nullable=True))
    op.drop_constraint('materials_id_product_fkey',
                       'materials', type_='foreignkey')
    op.drop_constraint('materials_id_order_fkey',
                       'materials', type_='foreignkey')
    op.create_foreign_key(None, 'materials', 'tattoos', ['id_tattoo'], ['id'])
    op.create_foreign_key(None, 'materials', 'storage', ['id_storage'], ['id'])
    op.drop_column('materials', 'id_order')
    op.drop_column('materials', 'id_product')
    op.add_column('tattooists', sa.Column(
        'image_name', sa.String(), nullable=True))
    op.add_column('tattooists', sa.Column(
        'image_bin', sa.LargeBinary(), nullable=True))
    op.add_column('tattooists', sa.Column(
        'image_mimetype', sa.String(), nullable=True))
    op.add_column('tattoos', sa.Column(
        'id_session', postgresql.UUID(as_uuid=True), nullable=True))
    op.alter_column('tattoos', 'colors',
                    existing_type=sa.BOOLEAN(),
                    nullable=False)
    op.drop_constraint('tattoos_id_event_fkey', 'tattoos', type_='foreignkey')
    op.create_foreign_key(None, 'tattoos', 'sessions', ['id_session'], ['id'])
    op.drop_column('tattoos', 'duration')
    op.drop_column('tattoos', 'id_event')
    op.drop_table('orders')
    op.drop_table('products')
    op.drop_table('events')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('tattoos', sa.Column(
        'id_event', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('tattoos', sa.Column('duration', sa.INTEGER(),
                  autoincrement=False, nullable=False))
    op.drop_constraint(None, 'tattoos', type_='foreignkey')
    op.create_foreign_key('tattoos_id_event_fkey', 'tattoos',
                          'events', ['id_event'], ['id'])
    op.alter_column('tattoos', 'colors',
                    existing_type=sa.BOOLEAN(),
                    nullable=True)
    op.drop_column('tattoos', 'id_session')
    op.drop_column('tattooists', 'image_mimetype')
    op.drop_column('tattooists', 'image_bin')
    op.drop_column('tattooists', 'image_name')
    op.add_column('materials', sa.Column(
        'id_product', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('materials', sa.Column(
        'id_order', postgresql.UUID(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'materials', type_='foreignkey')
    op.drop_constraint(None, 'materials', type_='foreignkey')
    op.create_foreign_key('materials_id_order_fkey',
                          'materials', 'orders', ['id_order'], ['id'])
    op.create_foreign_key('materials_id_product_fkey',
                          'materials', 'products', ['id_product'], ['id'])
    op.drop_column('materials', 'id_tattoo')
    op.drop_column('materials', 'id_storage')
    op.drop_column('clients', 'image_mimetype')
    op.drop_column('clients', 'image_bin')
    op.drop_column('clients', 'image_name')
    op.create_table('events',
                    sa.Column('id', postgresql.UUID(),
                              autoincrement=False, nullable=False),
                    sa.Column('date', sa.DATE(),
                              autoincrement=False, nullable=True),
                    sa.Column('start', postgresql.TIMESTAMP(),
                              autoincrement=False, nullable=True),
                    sa.Column('end', postgresql.TIMESTAMP(),
                              autoincrement=False, nullable=True),
                    sa.Column('finished', sa.BOOLEAN(),
                              autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='events_pkey'),
                    postgresql_ignore_search_path=False
                    )
    op.create_table('products',
                    sa.Column('id', postgresql.UUID(),
                              autoincrement=False, nullable=False),
                    sa.Column('name', sa.VARCHAR(),
                              autoincrement=False, nullable=False),
                    sa.Column('quantity', sa.INTEGER(),
                              autoincrement=False, nullable=False),
                    sa.Column('description', sa.TEXT(),
                              autoincrement=False, nullable=True),
                    sa.Column('validity', sa.DATE(),
                              autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='products_pkey')
                    )
    op.create_table('orders',
                    sa.Column('id', postgresql.UUID(),
                              autoincrement=False, nullable=False),
                    sa.Column('id_tattoo', postgresql.UUID(),
                              autoincrement=False, nullable=True),
                    sa.ForeignKeyConstraint(
                        ['id_tattoo'], ['tattoos.id'], name='orders_id_tattoo_fkey'),
                    sa.PrimaryKeyConstraint('id', name='orders_pkey')
                    )
    op.drop_table('tattoo_images')
    op.drop_table('storage')
    op.drop_table('sessions')
    # ### end Alembic commands ###

adds models 2.0  Revision ID: a7882a87de99 Revises: <PASSWORD> Create Date: 2022-03-03 21:50:30.137666 # 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 ###