"""Implementing balance and fiscal_note_items tables

Revision ID: 6099ed2a58e0
Revises: <KEY>
Create Date: 2021-10-11 14:52:44.126077

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

# revision identifiers, used by Alembic.
revision = "6099ed2a58e0"
down_revision = "<KEY>"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "balance",
        sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column("value", sa.Float(), nullable=False),
        sa.Column("type", sa.Enum("DEBT", "CREDIT", name="balancetype"), nullable=False),
        sa.Column(
            "operation",
            sa.Enum(
                "PAYMENT_OF_EMPLOYEES",
                "PAYMENT_OF_SUPPLIERS",
                "ANOTHER_PAYMENTS",
                "SALE_IN_PIX",
                "SALE_IN_DEBT",
                "SALE_IN_CREDIT",
                "SALE_IN_MONEY",
                name="operationtype",
            ),
            nullable=False,
        ),
        sa.Column("description", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.Column("owner_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.ForeignKeyConstraint(
            ["owner_id"],
            ["users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_balance_created_at"), "balance", ["created_at"], unique=False)
    op.create_index(op.f("ix_balance_operation"), "balance", ["operation"], unique=False)
    op.create_index(op.f("ix_balance_owner_id"), "balance", ["owner_id"], unique=False)
    op.create_index(op.f("ix_balance_type"), "balance", ["type"], unique=False)
    op.create_table(
        "fiscal_note_items",
        sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column("buy_value", sa.Float(), nullable=False),
        sa.Column("sugested_sell_value", sa.Float(), nullable=False),
        sa.Column("owner_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column("fiscal_note_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column("item_id", 