"""physical products shop_locations and inventory

Revision ID: cc6211ec360e
Revises: 7217f39a20a8
Create Date: 2024-06-08 09:40:24.200194

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'cc6211ec360e'
down_revision = '7217f39a20a8'
branch_labels = None
depends_on = None

from make_post_sell.models.meta import UUIDType


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('mps_shop_location',
    sa.Column('id', UUIDType, nullable=False),
    sa.Column('shop_id', UUIDType, nullable=False),
    sa.Column('name', sa.Unicode(length=64), nullable=False),
    sa.Column('address', sa.Unicode(length=256), nullable=False),
    sa.Column('city', sa.Unicode(length=64), nullable=False),
    sa.Column('state', sa.Unicode(length=64), nullable=False),
    sa.Column('country', sa.Unicode(length=64), nullable=False),
    sa.Column('postal_code', sa.Unicode(length=16), nullable=False),
    sa.Column('created_timestamp', sa.BigInteger(), nullable=False),
    sa.ForeignKeyConstraint(['shop_id'], ['mps_shop.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_mps_shop_location_id'), 'mps_shop_location', ['id'], unique=False)
    op.create_table('mps_inventory',
    sa.Column('id', UUIDType, nullable=False),
    sa.Column('shop_location_id', UUIDType, nullable=False),
    sa.Column('product_id', UUIDType, nullable=False),
    sa.Column('quantity', sa.Integer(), nullable=False),
    sa.Column('created_timestamp', sa.BigInteger(), nullable=False),
    sa.Column('updated_timestamp', sa.BigInteger(), nullable=False),
    sa.ForeignKeyConstraint(['product_id'], ['mps_product.id'], ),
    sa.ForeignKeyConstraint(['shop_location_id'], ['mps_shop_location.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_mps_inventory_id'), 'mps_inventory', ['id'], unique=False)

    op.add_column('mps_product', sa.Column('is_physical', sa.Boolean(), nullable=False, server_default=sa.false()))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('mps_product', 'is_physical')
    op.drop_index(op.f('ix_mps_inventory_id'), table_name='mps_inventory')
    op.drop_table('mps_inventory')
    op.drop_index(op.f('ix_mps_shop_location_id'), table_name='mps_shop_location')
    op.drop_table('mps_shop_location')
    # ### end Alembic commands ###
