"""base v1.0

Revision ID: be9e8a0c5a1a
Revises: 
Create Date: 2020-06-09 04:05:22.699310

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

# revision identifiers, used by Alembic.
revision = "be9e8a0c5a1a"
down_revision = None
branch_labels = None
depends_on = None


def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()


def upgrade_nemweb():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "BIDTYPE",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("BIDTYPE", sa.String(length=10), nullable=True),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_table(
        "DUID",
        sa.Column(
            "id",
            mysql.SMALLINT(display_width=6),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("DUID", sa.String(length=10), nullable=True),
        sa.Column(
            "STATION_NAME_ID", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "PARTICIPANT_ID", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "FUEL_SOURCE_ID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "TECHNOLOGY_ID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "CLASSIFICATION_ID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "TECHFUEL_ID",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("MW", sa.DECIMAL(precision=29, scale=3), nullable=True),
    )
    op.create_table(
        "DispatchedMarket",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("DispatchedMarket", sa.String(length=30), nullable=True),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_table(
        "INTERCONNECTORID",
        sa.Column(
            "id",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("INTERCONNECTORID", sa.String(length=9), nullable=True),
    )
    op.create_table(
        "INTERVAL_TABLE",
        sa.Column(
            "DISPATCHINTERVAL", mysql.BIGINT(display_width=20), nullable=False
        ),
        sa.Column(
            "TRADINGINTERVAL", mysql.INTEGER(display_width=11), nullable=False
        ),
        sa.Column("DATETIME", sa.DateTime(), nullable=False),
        sa.Column("DATE", sa.Date(), nullable=False),
        sa.Column("TIME", sa.Time(), nullable=False),
        sa.Column(
            "DISPATCHPERIOD", mysql.SMALLINT(display_width=6), nullable=False
        ),
        sa.Column(
            "TRADINGPERIOD", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.Column("YEAR", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column("MONTH", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("WEEKDAY", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("FY", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("PEAK", mysql.TINYINT(display_width=4), nullable=False),
        sa.PrimaryKeyConstraint("DISPATCHINTERVAL"),
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_DATE"),
        "INTERVAL_TABLE",
        ["DATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_DATETIME"),
        "INTERVAL_TABLE",
        ["DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_DISPATCHPERIOD"),
        "INTERVAL_TABLE",
        ["DISPATCHPERIOD"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_FY"), "INTERVAL_TABLE", ["FY"], unique=False
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_MONTH"),
        "INTERVAL_TABLE",
        ["MONTH"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_TIME"),
        "INTERVAL_TABLE",
        ["TIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_TRADINGINTERVAL"),
        "INTERVAL_TABLE",
        ["TRADINGINTERVAL"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_TRADINGPERIOD"),
        "INTERVAL_TABLE",
        ["TRADINGPERIOD"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_WEEKDAY"),
        "INTERVAL_TABLE",
        ["WEEKDAY"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERVAL_TABLE_YEAR"),
        "INTERVAL_TABLE",
        ["YEAR"],
        unique=False,
    )
    op.create_table(
        "Market",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("Market", sa.String(length=8), nullable=True),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_table(
        "REGIONID",
        sa.Column(
            "id",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("REGIONID", sa.String(length=6), nullable=True),
    )
    op.create_table(
        "RUNTYPE",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("RUNTYPE", sa.String(length=45), nullable=True),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("RUNTYPE"),
    )
    op.create_table(
        "Unit",
        sa.Column("ID", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column("Unit", mysql.VARCHAR(length=30), nullable=True),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("Unit"),
    )
    op.create_table(
        "DUID",
        sa.Column("ID", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column("DUID", mysql.VARCHAR(length=10), nullable=True),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("DUID"),
        schema="nemweb_meta",
    )
    op.create_table(
        "REGIONID",
        sa.Column("id", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("REGIONID", mysql.VARCHAR(length=6), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("REGIONID"),
        schema="nemweb_meta",
    )
    op.create_table(
        "CO2EII_PUBLISHING",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(
            "CONTRACTYEAR", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("WEEKNO", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "TOTAL_SENT_OUT_ENERGY",
            sa.DECIMAL(precision=14, scale=8),
            nullable=True,
        ),
        sa.Column(
            "TOTAL_EMISSIONS", sa.DECIMAL(precision=14, scale=8), nullable=True
        ),
        sa.Column(
            "CO2E_INTENSITY_INDEX",
            sa.DECIMAL(precision=5, scale=4),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        "SETTLEMENTDATE_2",
        "CO2EII_PUBLISHING",
        ["SETTLEMENTDATE", "REGIONID"],
        unique=True,
    )
    op.create_index(
        op.f("ix_CO2EII_PUBLISHING_CONTRACTYEAR"),
        "CO2EII_PUBLISHING",
        ["CONTRACTYEAR"],
        unique=False,
    )
    op.create_index(
        op.f("ix_CO2EII_PUBLISHING_REGIONID"),
        "CO2EII_PUBLISHING",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_CO2EII_PUBLISHING_SETTLEMENTDATE"),
        "CO2EII_PUBLISHING",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_CO2EII_PUBLISHING_WEEKNO"),
        "CO2EII_PUBLISHING",
        ["WEEKNO"],
        unique=False,
    )
    op.create_table(
        "DISPATCH_PRICE",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column(
            "DISPATCHINTERVAL", mysql.BIGINT(display_width=20), nullable=True
        ),
        sa.Column("RRP", sa.DECIMAL(precision=10, scale=5), nullable=True),
        sa.Column("ROP", sa.DECIMAL(precision=12, scale=5), nullable=True),
        sa.Column("APCFLAG", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "CUMUL_PRE_AP_ENERGY_PRICE",
            sa.DECIMAL(precision=16, scale=10),
            nullable=True,
        ),
        sa.Column(
            "INTERVENTION",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("0"),
            nullable=False,
        ),
        sa.Column(
            "RAISE6SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE6SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE6SECAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "RAISE60SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE60SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE60SECAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "RAISE5MINRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE5MINROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE5MINAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "RAISEREGRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISEREGROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISEREGAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "LOWER6SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER6SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER6SECAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "LOWER60SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER60SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER60SECAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "LOWER5MINRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER5MINROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER5MINAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "LOWERREGRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWERREGROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWERREGAPCFLAG", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_APCFLAG"),
        "DISPATCH_PRICE",
        ["APCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_DISPATCHINTERVAL"),
        "DISPATCH_PRICE",
        ["DISPATCHINTERVAL"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_INTERVENTION"),
        "DISPATCH_PRICE",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_LOWER5MINAPCFLAG"),
        "DISPATCH_PRICE",
        ["LOWER5MINAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_LOWER60SECAPCFLAG"),
        "DISPATCH_PRICE",
        ["LOWER60SECAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_LOWER6SECAPCFLAG"),
        "DISPATCH_PRICE",
        ["LOWER6SECAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_LOWERREGAPCFLAG"),
        "DISPATCH_PRICE",
        ["LOWERREGAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_RAISE5MINAPCFLAG"),
        "DISPATCH_PRICE",
        ["RAISE5MINAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_RAISE60SECAPCFLAG"),
        "DISPATCH_PRICE",
        ["RAISE60SECAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_RAISE6SECAPCFLAG"),
        "DISPATCH_PRICE",
        ["RAISE6SECAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_RAISEREGAPCFLAG"),
        "DISPATCH_PRICE",
        ["RAISEREGAPCFLAG"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_REGIONID"),
        "DISPATCH_PRICE",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_PRICE_SETTLEMENTDATE"),
        "DISPATCH_PRICE",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "DISPATCH_PRICE",
        ["SETTLEMENTDATE", "REGIONID", "INTERVENTION"],
        unique=True,
    )
    op.create_table(
        "DISPATCH_REGIONSUM",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "TOTALDEMAND", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "AVAILABLEGENERATION",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "AVAILABLELOAD", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "DEMANDFORECAST", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "DISPATCHABLEGENERATION",
            sa.DECIMAL(precision=7, scale=2),
            nullable=True,
        ),
        sa.Column(
            "DISPATCHABLELOAD", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "NETINTERCHANGE", sa.DECIMAL(precision=6, scale=2), nullable=True
        ),
        sa.Column(
            "EXCESSGENERATION", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "INITIALSUPPLY", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "CLEAREDSUPPLY", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "TOTALINTERMITTENTGENERATION",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "DEMAND_AND_NONSCHEDGEN",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column("UIGF", sa.DECIMAL(precision=10, scale=5), nullable=True),
        sa.Column(
            "SEMISCHEDULE_CLEAREDMW",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "DISPATCHINTERVAL", mysql.BIGINT(display_width=20), nullable=True
        ),
        sa.Column(
            "SEMISCHEDULE_COMPLIANCEMW",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "INTERVENTION",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("0"),
            nullable=False,
        ),
        sa.Column(
            "LOWERREGLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER5MINLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER60SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER6SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE5MINLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISEREGLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE60SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE6SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "AGGREGATEDISPATCHERROR",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE6SECACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.Column(
            "RAISE5MINACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.Column(
            "RAISE60SECACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.Column(
            "RAISEREGACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.Column(
            "LOWER6SECACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.Column(
            "LOWER5MINACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.Column(
            "LOWER60SECACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.Column(
            "LOWERREGACTUALAVAILABILITY",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_DISPATCH_REGIONSUM_DISPATCHINTERVAL"),
        "DISPATCH_REGIONSUM",
        ["DISPATCHINTERVAL"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_REGIONSUM_INTERVENTION"),
        "DISPATCH_REGIONSUM",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_REGIONSUM_REGIONID"),
        "DISPATCH_REGIONSUM",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_REGIONSUM_SETTLEMENTDATE"),
        "DISPATCH_REGIONSUM",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "DISPATCH_REGIONSUM",
        ["REGIONID", "SETTLEMENTDATE", "INTERVENTION"],
        unique=True,
    )
    op.create_table(
        "DISPATCH_UNIT_SCADA",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column(
            "SCADAVALUE", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SCADA_DUID"),
        "DISPATCH_UNIT_SCADA",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SCADA_SETTLEMENTDATE"),
        "DISPATCH_UNIT_SCADA",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq", "DISPATCH_UNIT_SCADA", ["SETTLEMENTDATE", "DUID"], unique=True
    )
    op.create_table(
        "DISPATCH_UNIT_SOLUTION",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column(
            "INTERVENTION", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "DISPATCHMODE", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column("AGCSTATUS", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "INITIALMW", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "TOTALCLEARED", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "RAMPDOWNRATE", sa.DECIMAL(precision=8, scale=2), nullable=True
        ),
        sa.Column(
            "RAMPUPRATE", sa.DECIMAL(precision=8, scale=2), nullable=True
        ),
        sa.Column(
            "LOWER5MIN", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "LOWER60SEC", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "LOWER6SEC", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "RAISE5MIN", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "RAISE60SEC", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "RAISE6SEC", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "LOWERREG", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "RAISEREG", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "AVAILABILITY", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_AGCSTATUS"),
        "DISPATCH_UNIT_SOLUTION",
        ["AGCSTATUS"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_DISPATCHMODE"),
        "DISPATCH_UNIT_SOLUTION",
        ["DISPATCHMODE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_DUID"),
        "DISPATCH_UNIT_SOLUTION",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_INTERVENTION"),
        "DISPATCH_UNIT_SOLUTION",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_SETTLEMENTDATE"),
        "DISPATCH_UNIT_SOLUTION",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq_idx",
        "DISPATCH_UNIT_SOLUTION",
        ["DUID", "SETTLEMENTDATE", "INTERVENTION"],
        unique=True,
    )
    op.create_table(
        "DISPATCH_UNIT_SOLUTION_OLD",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column(
            "INITIALMW", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "TOTALCLEARED", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.Column(
            "INTERVENTION", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_OLD_DUID"),
        "DISPATCH_UNIT_SOLUTION_OLD",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_OLD_INTERVENTION"),
        "DISPATCH_UNIT_SOLUTION_OLD",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_OLD_SETTLEMENTDATE"),
        "DISPATCH_UNIT_SOLUTION_OLD",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "DISPATCH_UNIT_SOLUTION_OLD",
        ["SETTLEMENTDATE", "DUID", "INTERVENTION"],
        unique=True,
    )
    op.create_table(
        "METER_DATA_GEN_DUID",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("INTERVAL_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column(
            "MWH_READING", sa.DECIMAL(precision=10, scale=6), nullable=True
        ),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        "DUID_2",
        "METER_DATA_GEN_DUID",
        ["DUID", "INTERVAL_DATETIME"],
        unique=True,
    )
    op.create_index(
        op.f("ix_METER_DATA_GEN_DUID_DUID"),
        "METER_DATA_GEN_DUID",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_METER_DATA_GEN_DUID_INTERVAL_DATETIME"),
        "METER_DATA_GEN_DUID",
        ["INTERVAL_DATETIME"],
        unique=False,
    )
    op.create_table(
        "MTPASA_REGIONSOLUTION",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("RUN_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("RUN_NO", mysql.INTEGER(display_width=11), nullable=True),
        sa.Column("RUNTYPE", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("DAY", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "DEMAND10", sa.DECIMAL(precision=12, scale=2), nullable=True
        ),
        sa.Column(
            "ENERGYREQDEMAND10",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "UNCONSTRAINEDCAPACITY",
            sa.DECIMAL(precision=12, scale=0),
            nullable=True,
        ),
        sa.Column(
            "CONSTRAINEDCAPACITY",
            sa.DECIMAL(precision=12, scale=0),
            nullable=True,
        ),
        sa.Column(
            "NETINTERCHANGEUNDERSCARCITY",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "SURPLUSCAPACITY", sa.DECIMAL(precision=12, scale=2), nullable=True
        ),
        sa.Column(
            "RESERVECONDITION", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "MAXSURPLUSRESERVE",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "MAXSPARECAPACITY",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "LORCONDITION", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "AGGREGATECAPACITYAVAILABLE",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "AGGREGATESCHEDULEDLOAD",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "AGGREGATEPASAAVAILABILITY",
            sa.DECIMAL(precision=12, scale=0),
            nullable=True,
        ),
        sa.Column(
            "TOTALINTERMITTENTGENERATION",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "DEMAND50", sa.DECIMAL(precision=12, scale=2), nullable=True
        ),
        sa.Column(
            "DEMAND_AND_NONSCHEDGEN",
            sa.DECIMAL(precision=15, scale=5),
            nullable=True,
        ),
        sa.Column("UIGF", sa.DECIMAL(precision=12, scale=2), nullable=True),
        sa.Column(
            "SEMISCHEDULEDCAPACITY",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "DEFICITRESERVE", sa.DECIMAL(precision=16, scale=6), nullable=True
        ),
        sa.Column(
            "ENERGYREQDEMAND50",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.ForeignKeyConstraint(["RUNTYPE"], ["RUNTYPE.ID"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_MTPASA_REGIONSOLUTION_DAY"),
        "MTPASA_REGIONSOLUTION",
        ["DAY"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_REGIONSOLUTION_REGIONID"),
        "MTPASA_REGIONSOLUTION",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_REGIONSOLUTION_RUNTYPE"),
        "MTPASA_REGIONSOLUTION",
        ["RUNTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_REGIONSOLUTION_RUN_DATETIME"),
        "MTPASA_REGIONSOLUTION",
        ["RUN_DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_REGIONSOLUTION_RUN_NO"),
        "MTPASA_REGIONSOLUTION",
        ["RUN_NO"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "MTPASA_REGIONSOLUTION",
        ["RUN_DATETIME", "RUN_NO", "DAY", "REGIONID", "RUNTYPE"],
        unique=True,
    )
    op.create_table(
        "NEMPriceSetter",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("PeriodID", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("Market", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "DispatchedMarket", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column("Price", sa.DECIMAL(precision=12, scale=5), nullable=True),
        sa.Column("Unit", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("BandNo", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("Unit_2", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("BandNo_2", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "Increase", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RRNBandPrice", sa.DECIMAL(precision=10, scale=2), nullable=True
        ),
        sa.Column(
            "BandCost", sa.DECIMAL(precision=14, scale=6), nullable=True
        ),
        sa.Column(
            "OCD_flag",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("0"),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(
            ["DispatchedMarket"], ["DispatchedMarket.ID"],
        ),
        sa.ForeignKeyConstraint(["Market"], ["Market.ID"],),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.ForeignKeyConstraint(["Unit"], ["Unit.ID"],),
        sa.ForeignKeyConstraint(["Unit_2"], ["Unit.ID"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_NEMPriceSetter_DispatchedMarket"),
        "NEMPriceSetter",
        ["DispatchedMarket"],
        unique=False,
    )
    op.create_index(
        op.f("ix_NEMPriceSetter_Market"),
        "NEMPriceSetter",
        ["Market"],
        unique=False,
    )
    op.create_index(
        op.f("ix_NEMPriceSetter_OCD_flag"),
        "NEMPriceSetter",
        ["OCD_flag"],
        unique=False,
    )
    op.create_index(
        op.f("ix_NEMPriceSetter_PeriodID"),
        "NEMPriceSetter",
        ["PeriodID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_NEMPriceSetter_REGIONID"),
        "NEMPriceSetter",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_NEMPriceSetter_Unit"),
        "NEMPriceSetter",
        ["Unit"],
        unique=False,
    )
    op.create_index(
        op.f("ix_NEMPriceSetter_Unit_2"),
        "NEMPriceSetter",
        ["Unit_2"],
        unique=False,
    )
    op.create_index(
        "uniq_idx",
        "NEMPriceSetter",
        [
            "Market",
            "Unit",
            "Unit_2",
            "PeriodID",
            "REGIONID",
            "DispatchedMarket",
            "OCD_flag",
            "BandNo",
            "BandNo_2",
        ],
        unique=True,
    )
    op.create_table(
        "OFFER_BIDDAYOFFER",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("OFFERDATE", sa.DateTime(), nullable=True),
        sa.Column("VERSIONNO", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("BIDTYPE", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "DAILYENERGYCONSTRAINT",
            mysql.INTEGER(display_width=11),
            nullable=True,
        ),
        sa.Column(
            "PRICEBAND1", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND2", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND3", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND4", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND5", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND6", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND7", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND8", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND9", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND10", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "MINIMUMLOAD", mysql.MEDIUMINT(display_width=9), nullable=True
        ),
        sa.Column("LASTCHANGED", sa.DateTime(), nullable=True),
        sa.Column("ENTRYTYPE", sa.CHAR(length=5), nullable=True),
        sa.Column("T1", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("T2", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("T3", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("T4", mysql.TINYINT(display_width=4), nullable=True),
        sa.ForeignKeyConstraint(["BIDTYPE"], ["BIDTYPE.ID"],),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_OFFER_BIDDAYOFFER_BIDTYPE"),
        "OFFER_BIDDAYOFFER",
        ["BIDTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDDAYOFFER_DUID"),
        "OFFER_BIDDAYOFFER",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDDAYOFFER_ENTRYTYPE"),
        "OFFER_BIDDAYOFFER",
        ["ENTRYTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDDAYOFFER_LASTCHANGED"),
        "OFFER_BIDDAYOFFER",
        ["LASTCHANGED"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDDAYOFFER_OFFERDATE"),
        "OFFER_BIDDAYOFFER",
        ["OFFERDATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDDAYOFFER_SETTLEMENTDATE"),
        "OFFER_BIDDAYOFFER",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDDAYOFFER_VERSIONNO"),
        "OFFER_BIDDAYOFFER",
        ["VERSIONNO"],
        unique=False,
    )
    op.create_table(
        "OFFER_BIDPEROFFER",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("OFFERDATE", sa.DateTime(), nullable=True),
        sa.Column("PERIODID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "VERSIONNO", mysql.MEDIUMINT(display_width=9), nullable=True
        ),
        sa.Column("BIDTYPE", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("MAXAVAIL", mysql.MEDIUMINT(display_width=9), nullable=True),
        sa.Column("ROCUP", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("ROCDOWN", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column(
            "BANDAVAIL1", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL2", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL3", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL4", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL5", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL6", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL7", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL8", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL9", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL10", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("LASTCHANGED", sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(["BIDTYPE"], ["BIDTYPE.ID"],),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_OFFER_BIDPEROFFER_BIDTYPE"),
        "OFFER_BIDPEROFFER",
        ["BIDTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDPEROFFER_DUID"),
        "OFFER_BIDPEROFFER",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDPEROFFER_LASTCHANGED"),
        "OFFER_BIDPEROFFER",
        ["LASTCHANGED"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDPEROFFER_OFFERDATE"),
        "OFFER_BIDPEROFFER",
        ["OFFERDATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDPEROFFER_PERIODID"),
        "OFFER_BIDPEROFFER",
        ["PERIODID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDPEROFFER_SETTLEMENTDATE"),
        "OFFER_BIDPEROFFER",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_OFFER_BIDPEROFFER_VERSIONNO"),
        "OFFER_BIDPEROFFER",
        ["VERSIONNO"],
        unique=False,
    )
    op.create_table(
        "P5MIN_REGIONSOLUTION",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("RUN_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("INTERVAL_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("RRP", sa.DECIMAL(precision=10, scale=5), nullable=True),
        sa.Column(
            "EXCESSGENERATION", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "RAISE6SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE60SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE5MINRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "RAISEREGRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER6SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER60SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER5MINRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWERREGRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "TOTALDEMAND", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "AVAILABLEGENERATION",
            sa.DECIMAL(precision=8, scale=3),
            nullable=True,
        ),
        sa.Column(
            "AVAILABLELOAD", sa.DECIMAL(precision=7, scale=3), nullable=True
        ),
        sa.Column(
            "DEMANDFORECAST", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "DISPATCHABLEGENERATION",
            sa.DECIMAL(precision=7, scale=2),
            nullable=True,
        ),
        sa.Column(
            "DISPATCHABLELOAD", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "NETINTERCHANGE", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "LOWER5MINLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER60SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER6SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE5MINLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE60SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE6SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "AGGREGATEDISPATCHERROR",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "INITIALSUPPLY", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "CLEAREDSUPPLY", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "LOWERREGLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISEREGLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "TOTALINTERMITTENTGENERATION",
            sa.DECIMAL(precision=8, scale=3),
            nullable=True,
        ),
        sa.Column(
            "DEMAND_AND_NONSCHEDGEN",
            sa.DECIMAL(precision=8, scale=3),
            nullable=True,
        ),
        sa.Column("UIGF", sa.DECIMAL(precision=8, scale=3), nullable=True),
        sa.Column(
            "SEMISCHEDULE_CLEAREDMW",
            sa.DECIMAL(precision=9, scale=4),
            nullable=True,
        ),
        sa.Column(
            "SEMISCHEDULE_COMPLIANCEMW",
            sa.DECIMAL(precision=9, scale=4),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_P5MIN_REGIONSOLUTION_INTERVAL_DATETIME"),
        "P5MIN_REGIONSOLUTION",
        ["INTERVAL_DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_P5MIN_REGIONSOLUTION_REGIONID"),
        "P5MIN_REGIONSOLUTION",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_P5MIN_REGIONSOLUTION_RUN_DATETIME"),
        "P5MIN_REGIONSOLUTION",
        ["RUN_DATETIME"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "P5MIN_REGIONSOLUTION",
        ["RUN_DATETIME", "INTERVAL_DATETIME", "REGIONID"],
        unique=True,
    )
    op.create_table(
        "PREDISPATCH_PRICESENSITIVITIES",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(
            "PREDISPATCHSEQNO", mysql.BIGINT(display_width=20), nullable=True
        ),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("PERIODID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "INTERVENTION", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "INTERVENTION_ACTIVE",
            mysql.TINYINT(display_width=4),
            nullable=True,
        ),
        sa.Column("DATETIME", sa.DateTime(), nullable=True),
        sa.Column("RRPEEP1", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP2", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP3", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP4", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP5", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP6", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP7", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP8", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column("RRPEEP9", sa.DECIMAL(precision=12, scale=6), nullable=True),
        sa.Column(
            "RRPEEP10", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP11", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP12", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP13", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP14", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP15", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP16", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP17", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP18", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP19", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP20", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP21", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP22", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP23", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP24", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP25", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP26", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP27", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP28", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP29", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP30", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP31", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP32", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP33", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP34", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP35", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP36", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP37", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP38", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP39", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP40", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP41", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP42", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column(
            "RRPEEP43", sa.DECIMAL(precision=12, scale=6), nullable=True
        ),
        sa.Column("LASTCHANGED", sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_DATETIME"),
        "PREDISPATCH_PRICESENSITIVITIES",
        ["DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_INTERVENTION"),
        "PREDISPATCH_PRICESENSITIVITIES",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_INTERVENTION_ACTIVE"),
        "PREDISPATCH_PRICESENSITIVITIES",
        ["INTERVENTION_ACTIVE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_PERIODID"),
        "PREDISPATCH_PRICESENSITIVITIES",
        ["PERIODID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_PREDISPATCHSEQNO"),
        "PREDISPATCH_PRICESENSITIVITIES",
        ["PREDISPATCHSEQNO"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_REGIONID"),
        "PREDISPATCH_PRICESENSITIVITIES",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        "uniq_idx",
        "PREDISPATCH_PRICESENSITIVITIES",
        ["PREDISPATCHSEQNO", "REGIONID", "PERIODID", "INTERVENTION"],
        unique=True,
    )
    op.create_table(
        "PREDISPATCH_REGION_PRICES",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(
            "PREDISPATCHSEQNO", mysql.INTEGER(display_width=11), nullable=True
        ),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("PERIODID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("RRP", sa.DECIMAL(precision=10, scale=5), nullable=True),
        sa.Column("DATETIME", sa.DateTime(), nullable=True),
        sa.Column(
            "INTERVENTION", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.Column(
            "RAISE60SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE5MINRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "RAISEREGRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE6SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER6SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER60SECRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER5MINRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "LOWERREGRRP", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_DATETIME"),
        "PREDISPATCH_REGION_PRICES",
        ["DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_INTERVENTION"),
        "PREDISPATCH_REGION_PRICES",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_PERIODID"),
        "PREDISPATCH_REGION_PRICES",
        ["PERIODID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_PREDISPATCHSEQNO"),
        "PREDISPATCH_REGION_PRICES",
        ["PREDISPATCHSEQNO"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_REGIONID"),
        "PREDISPATCH_REGION_PRICES",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "PREDISPATCH_REGION_PRICES",
        ["REGIONID", "PREDISPATCHSEQNO", "INTERVENTION", "PERIODID"],
        unique=True,
    )
    op.create_table(
        "PREDISPATCH_REGION_SOLUTION",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(
            "PREDISPATCHSEQNO", mysql.INTEGER(display_width=11), nullable=True
        ),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "TOTALDEMAND", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "AVAILABLEGENERATION",
            sa.DECIMAL(precision=8, scale=3),
            nullable=True,
        ),
        sa.Column(
            "AVAILABLELOAD", sa.DECIMAL(precision=7, scale=3), nullable=True
        ),
        sa.Column(
            "DEMANDFORECAST", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "DISPATCHABLEGENERATION",
            sa.DECIMAL(precision=7, scale=2),
            nullable=True,
        ),
        sa.Column(
            "DISPATCHABLELOAD", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "NETINTERCHANGE", sa.DECIMAL(precision=7, scale=2), nullable=False
        ),
        sa.Column(
            "EXCESSGENERATION", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column("DATETIME", sa.DateTime(), nullable=True),
        sa.Column(
            "INITIALSUPPLY", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "CLEAREDSUPPLY", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "TOTALINTERMITTENTGENERATION",
            sa.DECIMAL(precision=8, scale=3),
            nullable=True,
        ),
        sa.Column(
            "DEMAND_AND_NONSCHEDGEN",
            sa.DECIMAL(precision=8, scale=3),
            nullable=True,
        ),
        sa.Column("UIGF", sa.DECIMAL(precision=8, scale=3), nullable=True),
        sa.Column(
            "SEMISCHEDULE_CLEAREDMW",
            sa.DECIMAL(precision=9, scale=4),
            nullable=False,
        ),
        sa.Column(
            "SEMISCHEDULE_COMPLIANCEMW",
            sa.DECIMAL(precision=9, scale=4),
            nullable=True,
        ),
        sa.Column("PERIODID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "INTERVENTION", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_DATETIME"),
        "PREDISPATCH_REGION_SOLUTION",
        ["DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_INTERVENTION"),
        "PREDISPATCH_REGION_SOLUTION",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_PERIODID"),
        "PREDISPATCH_REGION_SOLUTION",
        ["PERIODID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_PREDISPATCHSEQNO"),
        "PREDISPATCH_REGION_SOLUTION",
        ["PREDISPATCHSEQNO"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_REGIONID"),
        "PREDISPATCH_REGION_SOLUTION",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "PREDISPATCH_REGION_SOLUTION",
        ["REGIONID", "PREDISPATCHSEQNO", "INTERVENTION", "PERIODID"],
        unique=True,
    )
    op.create_table(
        "ROOFTOP_ACTUAL",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("INTERVAL_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("POWER", sa.DECIMAL(precision=8, scale=3), nullable=True),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_ROOFTOP_ACTUAL_INTERVAL_DATETIME"),
        "ROOFTOP_ACTUAL",
        ["INTERVAL_DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_ROOFTOP_ACTUAL_REGIONID"),
        "ROOFTOP_ACTUAL",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        "uniq_idx",
        "ROOFTOP_ACTUAL",
        ["INTERVAL_DATETIME", "REGIONID"],
        unique=True,
    )
    op.create_table(
        "ROOFTOP_FORECAST",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("VERSION_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("INTERVAL_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "POWERMEAN", sa.DECIMAL(precision=8, scale=3), nullable=True
        ),
        sa.Column(
            "POWERPOE50", sa.DECIMAL(precision=8, scale=3), nullable=True
        ),
        sa.Column(
            "POWERPOELOW", sa.DECIMAL(precision=8, scale=3), nullable=True
        ),
        sa.Column(
            "POWERPOEHIGH", sa.DECIMAL(precision=8, scale=3), nullable=True
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_ROOFTOP_FORECAST_INTERVAL_DATETIME"),
        "ROOFTOP_FORECAST",
        ["INTERVAL_DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_ROOFTOP_FORECAST_REGIONID"),
        "ROOFTOP_FORECAST",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_ROOFTOP_FORECAST_VERSION_DATETIME"),
        "ROOFTOP_FORECAST",
        ["VERSION_DATETIME"],
        unique=False,
    )
    op.create_index(
        "uniq_idx",
        "ROOFTOP_FORECAST",
        ["VERSION_DATETIME", "INTERVAL_DATETIME", "REGIONID"],
        unique=True,
    )
    op.create_table(
        "TRADING_PRICE",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=False),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("RRP", sa.DECIMAL(precision=7, scale=2), nullable=True),
        sa.Column("ROP", sa.DECIMAL(precision=8, scale=2), nullable=True),
        sa.Column(
            "RAISE6SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE6SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE60SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE60SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE5MINRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISE5MINROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISEREGRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "RAISEREGROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER6SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER6SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER60SECRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER60SECROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER5MINRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWER5MINROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWERREGRRP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.Column(
            "LOWERREGROP", sa.DECIMAL(precision=12, scale=5), nullable=True
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_TRADING_PRICE_REGIONID"),
        "TRADING_PRICE",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_TRADING_PRICE_SETTLEMENTDATE"),
        "TRADING_PRICE",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq", "TRADING_PRICE", ["SETTLEMENTDATE", "REGIONID"], unique=True
    )
    op.create_table(
        "TRADING_REGIONSUM",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "TOTALDEMAND", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "AVAILABLEGENERATION",
            sa.DECIMAL(precision=7, scale=2),
            nullable=True,
        ),
        sa.Column(
            "AVAILABLELOAD", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "DEMANDFORECAST", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "DISPATCHABLEGENERATION",
            sa.DECIMAL(precision=7, scale=2),
            nullable=True,
        ),
        sa.Column(
            "DISPATCHABLELOAD", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "NETINTERCHANGE", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "EXCESSGENERATION", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "INITIALSUPPLY", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "CLEAREDSUPPLY", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "TOTALINTERMITTENTGENERATION",
            sa.DECIMAL(precision=7, scale=2),
            nullable=True,
        ),
        sa.Column(
            "DEMAND_AND_NONSCHEDGEN",
            sa.DECIMAL(precision=7, scale=2),
            nullable=True,
        ),
        sa.Column("UIGF", sa.DECIMAL(precision=7, scale=2), nullable=True),
        sa.Column(
            "LOWERREGLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER5MINLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER60SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "LOWER6SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE5MINLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISEREGLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE60SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.Column(
            "RAISE6SECLOCALDISPATCH",
            sa.DECIMAL(precision=10, scale=5),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(["REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_TRADING_REGIONSUM_REGIONID"),
        "TRADING_REGIONSUM",
        ["REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_TRADING_REGIONSUM_SETTLEMENTDATE"),
        "TRADING_REGIONSUM",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "TRADING_REGIONSUM",
        ["SETTLEMENTDATE", "REGIONID"],
        unique=True,
    )
    op.create_table(
        "YESTBID_BIDDAYOFFER",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("BIDOFFERDATE", sa.DateTime(), nullable=True),
        sa.Column(
            "PRICEBAND1", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND2", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND3", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND4", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND5", sa.DECIMAL(precision=7, scale=2), nullable=False
        ),
        sa.Column(
            "PRICEBAND6", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND7", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND8", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "PRICEBAND9", sa.DECIMAL(precision=7, scale=2), nullable=False
        ),
        sa.Column(
            "PRICEBAND10", sa.DECIMAL(precision=7, scale=2), nullable=True
        ),
        sa.Column(
            "MINIMUMLOAD", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("LASTCHANGED", sa.DateTime(), nullable=True),
        sa.Column(
            "BIDVERSIONNO", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("ENTRYTYPE", sa.String(length=10), nullable=True),
        sa.Column("BIDTYPE", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("BIDSETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column(
            "DAILYENERGYCONSTRAINT",
            sa.DECIMAL(precision=12, scale=6),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(["BIDTYPE"], ["BIDTYPE.ID"],),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_YESTBID_BIDDAYOFFER_BIDOFFERDATE"),
        "YESTBID_BIDDAYOFFER",
        ["BIDOFFERDATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDDAYOFFER_BIDTYPE"),
        "YESTBID_BIDDAYOFFER",
        ["BIDTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDDAYOFFER_DUID"),
        "YESTBID_BIDDAYOFFER",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDDAYOFFER_ENTRYTYPE"),
        "YESTBID_BIDDAYOFFER",
        ["ENTRYTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDDAYOFFER_LASTCHANGED"),
        "YESTBID_BIDDAYOFFER",
        ["LASTCHANGED"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "YESTBID_BIDDAYOFFER",
        ["DUID", "LASTCHANGED", "BIDOFFERDATE", "BIDTYPE"],
        unique=True,
    )
    op.create_table(
        "YESTBID_BIDPEROFFER",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("BIDOFFERDATE", sa.DateTime(), nullable=True),
        sa.Column("TRADINGPERIOD", sa.DateTime(), nullable=True),
        sa.Column("MAXAVAIL", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("FIXEDLOAD", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("ROCUP", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("ROCDOWN", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column(
            "BANDAVAIL1", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL2", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL3", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL4", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL5", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL6", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL7", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL8", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL9", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "BANDAVAIL10", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "PASAAVAILABILITY", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("PERIODID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("LASTCHANGED", sa.DateTime(), nullable=True),
        sa.Column(
            "BIDVERSIONNO", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column("BIDTYPE", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("BIDSETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column(
            "ENABLEMENTMIN", sa.DECIMAL(precision=6, scale=0), nullable=True
        ),
        sa.Column(
            "ENABLEMENTMAX", sa.DECIMAL(precision=6, scale=0), nullable=True
        ),
        sa.Column(
            "HIGHBREAKPOINT", sa.DECIMAL(precision=6, scale=0), nullable=True
        ),
        sa.Column(
            "LOWBREAKPOINT", sa.DECIMAL(precision=6, scale=0), nullable=True
        ),
        sa.ForeignKeyConstraint(["BIDTYPE"], ["BIDTYPE.ID"],),
        sa.ForeignKeyConstraint(["DUID"], ["nemweb_meta.DUID.ID"],),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_YESTBID_BIDPEROFFER_BIDOFFERDATE"),
        "YESTBID_BIDPEROFFER",
        ["BIDOFFERDATE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDPEROFFER_BIDTYPE"),
        "YESTBID_BIDPEROFFER",
        ["BIDTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDPEROFFER_DUID"),
        "YESTBID_BIDPEROFFER",
        ["DUID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDPEROFFER_LASTCHANGED"),
        "YESTBID_BIDPEROFFER",
        ["LASTCHANGED"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDPEROFFER_PERIODID"),
        "YESTBID_BIDPEROFFER",
        ["PERIODID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_YESTBID_BIDPEROFFER_TRADINGPERIOD"),
        "YESTBID_BIDPEROFFER",
        ["TRADINGPERIOD"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "YESTBID_BIDPEROFFER",
        ["DUID", "TRADINGPERIOD", "LASTCHANGED", "BIDTYPE"],
        unique=True,
    )
    op.create_table(
        "INTERCONNECTORID",
        sa.Column("id", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("INTERCONNECTORID", mysql.VARCHAR(length=9), nullable=False),
        sa.Column(
            "FROM_REGIONID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "TO_REGIONID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.ForeignKeyConstraint(
            ["FROM_REGIONID"], ["nemweb_meta.REGIONID.id"],
        ),
        sa.ForeignKeyConstraint(["TO_REGIONID"], ["nemweb_meta.REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("INTERCONNECTORID"),
        schema="nemweb_meta",
    )
    op.create_index(
        op.f("ix_nemweb_meta_INTERCONNECTORID_FROM_REGIONID"),
        "INTERCONNECTORID",
        ["FROM_REGIONID"],
        unique=False,
        schema="nemweb_meta",
    )
    op.create_index(
        op.f("ix_nemweb_meta_INTERCONNECTORID_TO_REGIONID"),
        "INTERCONNECTORID",
        ["TO_REGIONID"],
        unique=False,
        schema="nemweb_meta",
    )
    op.create_table(
        "DISPATCH_INTERCONNECTORRES",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column(
            "INTERCONNECTORID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "METEREDMWFLOW", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column("MWLOSSES", sa.DECIMAL(precision=8, scale=5), nullable=True),
        sa.Column(
            "EXPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "IMPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "MARGINALLOSS", sa.DECIMAL(precision=6, scale=5), nullable=True
        ),
        sa.Column(
            "DISPATCHINTERVAL", mysql.BIGINT(display_width=20), nullable=True
        ),
        sa.Column("MWFLOW", sa.DECIMAL(precision=10, scale=5), nullable=True),
        sa.Column(
            "INTERVENTION",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("0"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["INTERCONNECTORID"], ["nemweb_meta.INTERCONNECTORID.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_DISPATCHINTERVAL"),
        "DISPATCH_INTERCONNECTORRES",
        ["DISPATCHINTERVAL"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_INTERCONNECTORID"),
        "DISPATCH_INTERCONNECTORRES",
        ["INTERCONNECTORID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_INTERVENTION"),
        "DISPATCH_INTERCONNECTORRES",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_SETTLEMENTDATE"),
        "DISPATCH_INTERCONNECTORRES",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "DISPATCH_INTERCONNECTORRES",
        ["INTERCONNECTORID", "SETTLEMENTDATE", "INTERVENTION"],
        unique=True,
    )
    op.create_table(
        "MTPASA_INTERCONNECTORSOLUTION",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("RUN_DATETIME", sa.DateTime(), nullable=True),
        sa.Column("RUN_NO", mysql.INTEGER(display_width=11), nullable=True),
        sa.Column("RUNTYPE", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column("DAY", sa.DateTime(), nullable=True),
        sa.Column(
            "INTERCONNECTORID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "CAPACITYMWFLOW", sa.DECIMAL(precision=12, scale=2), nullable=True
        ),
        sa.Column(
            "CALCULATEDEXPORTLIMIT",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.Column(
            "CALCULATEDIMPORTLIMIT",
            sa.DECIMAL(precision=12, scale=2),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(
            ["INTERCONNECTORID"], ["nemweb_meta.INTERCONNECTORID.id"],
        ),
        sa.ForeignKeyConstraint(["RUNTYPE"], ["RUNTYPE.ID"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_DAY"),
        "MTPASA_INTERCONNECTORSOLUTION",
        ["DAY"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_INTERCONNECTORID"),
        "MTPASA_INTERCONNECTORSOLUTION",
        ["INTERCONNECTORID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_RUNTYPE"),
        "MTPASA_INTERCONNECTORSOLUTION",
        ["RUNTYPE"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_RUN_DATETIME"),
        "MTPASA_INTERCONNECTORSOLUTION",
        ["RUN_DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_RUN_NO"),
        "MTPASA_INTERCONNECTORSOLUTION",
        ["RUN_NO"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "MTPASA_INTERCONNECTORSOLUTION",
        ["RUN_DATETIME", "RUN_NO", "DAY", "INTERCONNECTORID", "RUNTYPE"],
        unique=True,
    )
    op.create_table(
        "P5MIN_INTERCONNECTORSOLN",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("RUN_DATETIME", sa.DateTime(), nullable=True),
        sa.Column(
            "INTERCONNECTORID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column("INTERVAL_DATETIME", sa.DateTime(), nullable=True),
        sa.Column(
            "METEREDMWFLOW", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column("MWFLOW", sa.DECIMAL(precision=10, scale=5), nullable=True),
        sa.Column(
            "MWLOSSES", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "EXPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "IMPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "MARGINALLOSS", sa.DECIMAL(precision=6, scale=5), nullable=True
        ),
        sa.Column(
            "FCASEXPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "FCASIMPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.ForeignKeyConstraint(
            ["INTERCONNECTORID"], ["nemweb_meta.INTERCONNECTORID.id"],
        ),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_P5MIN_INTERCONNECTORSOLN_INTERCONNECTORID"),
        "P5MIN_INTERCONNECTORSOLN",
        ["INTERCONNECTORID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_P5MIN_INTERCONNECTORSOLN_INTERVAL_DATETIME"),
        "P5MIN_INTERCONNECTORSOLN",
        ["INTERVAL_DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_P5MIN_INTERCONNECTORSOLN_RUN_DATETIME"),
        "P5MIN_INTERCONNECTORSOLN",
        ["RUN_DATETIME"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "P5MIN_INTERCONNECTORSOLN",
        ["RUN_DATETIME", "INTERCONNECTORID", "INTERVAL_DATETIME"],
        unique=True,
    )
    op.create_table(
        "PREDISPATCH_INTERCONNECTOR_SOLN",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(
            "PREDISPATCHSEQNO", mysql.INTEGER(display_width=11), nullable=True
        ),
        sa.Column(
            "INTERCONNECTORID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column("PERIODID", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "METEREDMWFLOW", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column("MWFLOW", sa.DECIMAL(precision=10, scale=5), nullable=True),
        sa.Column(
            "MWLOSSES", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column("DATETIME", sa.DateTime(), nullable=True),
        sa.Column(
            "EXPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "IMPORTLIMIT", sa.DECIMAL(precision=10, scale=5), nullable=True
        ),
        sa.Column(
            "MARGINALLOSS", sa.DECIMAL(precision=6, scale=5), nullable=False
        ),
        sa.Column(
            "INTERVENTION", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.ForeignKeyConstraint(
            ["INTERCONNECTORID"], ["nemweb_meta.INTERCONNECTORID.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_DATETIME"),
        "PREDISPATCH_INTERCONNECTOR_SOLN",
        ["DATETIME"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_INTERCONNECTORID"),
        "PREDISPATCH_INTERCONNECTOR_SOLN",
        ["INTERCONNECTORID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_INTERVENTION"),
        "PREDISPATCH_INTERCONNECTOR_SOLN",
        ["INTERVENTION"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_PERIODID"),
        "PREDISPATCH_INTERCONNECTOR_SOLN",
        ["PERIODID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_PREDISPATCHSEQNO"),
        "PREDISPATCH_INTERCONNECTOR_SOLN",
        ["PREDISPATCHSEQNO"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "PREDISPATCH_INTERCONNECTOR_SOLN",
        ["INTERCONNECTORID", "DATETIME", "PREDISPATCHSEQNO", "INTERVENTION"],
        unique=True,
    )
    op.create_table(
        "TRADING_INTERCONNECTORRES",
        sa.Column("id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("SETTLEMENTDATE", sa.DateTime(), nullable=True),
        sa.Column(
            "INTERCONNECTORID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "METEREDMWFLOW", sa.DECIMAL(precision=6, scale=2), nullable=True
        ),
        sa.Column("MWFLOW", sa.DECIMAL(precision=6, scale=2), nullable=True),
        sa.Column("MWLOSSES", sa.DECIMAL(precision=6, scale=2), nullable=True),
        sa.ForeignKeyConstraint(
            ["INTERCONNECTORID"], ["nemweb_meta.INTERCONNECTORID.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_TRADING_INTERCONNECTORRES_INTERCONNECTORID"),
        "TRADING_INTERCONNECTORRES",
        ["INTERCONNECTORID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_TRADING_INTERCONNECTORRES_SETTLEMENTDATE"),
        "TRADING_INTERCONNECTORRES",
        ["SETTLEMENTDATE"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "TRADING_INTERCONNECTORRES",
        ["SETTLEMENTDATE", "INTERCONNECTORID"],
        unique=True,
    )
    # ### end Alembic commands ###


def downgrade_nemweb():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("uniq", table_name="TRADING_INTERCONNECTORRES")
    op.drop_index(
        op.f("ix_TRADING_INTERCONNECTORRES_SETTLEMENTDATE"),
        table_name="TRADING_INTERCONNECTORRES",
    )
    op.drop_index(
        op.f("ix_TRADING_INTERCONNECTORRES_INTERCONNECTORID"),
        table_name="TRADING_INTERCONNECTORRES",
    )
    op.drop_table("TRADING_INTERCONNECTORRES")
    op.drop_index("uniq", table_name="PREDISPATCH_INTERCONNECTOR_SOLN")
    op.drop_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_PREDISPATCHSEQNO"),
        table_name="PREDISPATCH_INTERCONNECTOR_SOLN",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_PERIODID"),
        table_name="PREDISPATCH_INTERCONNECTOR_SOLN",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_INTERVENTION"),
        table_name="PREDISPATCH_INTERCONNECTOR_SOLN",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_INTERCONNECTORID"),
        table_name="PREDISPATCH_INTERCONNECTOR_SOLN",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_INTERCONNECTOR_SOLN_DATETIME"),
        table_name="PREDISPATCH_INTERCONNECTOR_SOLN",
    )
    op.drop_table("PREDISPATCH_INTERCONNECTOR_SOLN")
    op.drop_index("uniq", table_name="P5MIN_INTERCONNECTORSOLN")
    op.drop_index(
        op.f("ix_P5MIN_INTERCONNECTORSOLN_RUN_DATETIME"),
        table_name="P5MIN_INTERCONNECTORSOLN",
    )
    op.drop_index(
        op.f("ix_P5MIN_INTERCONNECTORSOLN_INTERVAL_DATETIME"),
        table_name="P5MIN_INTERCONNECTORSOLN",
    )
    op.drop_index(
        op.f("ix_P5MIN_INTERCONNECTORSOLN_INTERCONNECTORID"),
        table_name="P5MIN_INTERCONNECTORSOLN",
    )
    op.drop_table("P5MIN_INTERCONNECTORSOLN")
    op.drop_index("uniq", table_name="MTPASA_INTERCONNECTORSOLUTION")
    op.drop_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_RUN_NO"),
        table_name="MTPASA_INTERCONNECTORSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_RUN_DATETIME"),
        table_name="MTPASA_INTERCONNECTORSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_RUNTYPE"),
        table_name="MTPASA_INTERCONNECTORSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_INTERCONNECTORID"),
        table_name="MTPASA_INTERCONNECTORSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_INTERCONNECTORSOLUTION_DAY"),
        table_name="MTPASA_INTERCONNECTORSOLUTION",
    )
    op.drop_table("MTPASA_INTERCONNECTORSOLUTION")
    op.drop_index("uniq", table_name="DISPATCH_INTERCONNECTORRES")
    op.drop_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_SETTLEMENTDATE"),
        table_name="DISPATCH_INTERCONNECTORRES",
    )
    op.drop_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_INTERVENTION"),
        table_name="DISPATCH_INTERCONNECTORRES",
    )
    op.drop_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_INTERCONNECTORID"),
        table_name="DISPATCH_INTERCONNECTORRES",
    )
    op.drop_index(
        op.f("ix_DISPATCH_INTERCONNECTORRES_DISPATCHINTERVAL"),
        table_name="DISPATCH_INTERCONNECTORRES",
    )
    op.drop_table("DISPATCH_INTERCONNECTORRES")
    op.drop_index(
        op.f("ix_nemweb_meta_INTERCONNECTORID_TO_REGIONID"),
        table_name="INTERCONNECTORID",
        schema="nemweb_meta",
    )
    op.drop_index(
        op.f("ix_nemweb_meta_INTERCONNECTORID_FROM_REGIONID"),
        table_name="INTERCONNECTORID",
        schema="nemweb_meta",
    )
    op.drop_table("INTERCONNECTORID", schema="nemweb_meta")
    op.drop_index("uniq", table_name="YESTBID_BIDPEROFFER")
    op.drop_index(
        op.f("ix_YESTBID_BIDPEROFFER_TRADINGPERIOD"),
        table_name="YESTBID_BIDPEROFFER",
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDPEROFFER_PERIODID"),
        table_name="YESTBID_BIDPEROFFER",
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDPEROFFER_LASTCHANGED"),
        table_name="YESTBID_BIDPEROFFER",
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDPEROFFER_DUID"), table_name="YESTBID_BIDPEROFFER"
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDPEROFFER_BIDTYPE"),
        table_name="YESTBID_BIDPEROFFER",
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDPEROFFER_BIDOFFERDATE"),
        table_name="YESTBID_BIDPEROFFER",
    )
    op.drop_table("YESTBID_BIDPEROFFER")
    op.drop_index("uniq", table_name="YESTBID_BIDDAYOFFER")
    op.drop_index(
        op.f("ix_YESTBID_BIDDAYOFFER_LASTCHANGED"),
        table_name="YESTBID_BIDDAYOFFER",
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDDAYOFFER_ENTRYTYPE"),
        table_name="YESTBID_BIDDAYOFFER",
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDDAYOFFER_DUID"), table_name="YESTBID_BIDDAYOFFER"
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDDAYOFFER_BIDTYPE"),
        table_name="YESTBID_BIDDAYOFFER",
    )
    op.drop_index(
        op.f("ix_YESTBID_BIDDAYOFFER_BIDOFFERDATE"),
        table_name="YESTBID_BIDDAYOFFER",
    )
    op.drop_table("YESTBID_BIDDAYOFFER")
    op.drop_index("uniq", table_name="TRADING_REGIONSUM")
    op.drop_index(
        op.f("ix_TRADING_REGIONSUM_SETTLEMENTDATE"),
        table_name="TRADING_REGIONSUM",
    )
    op.drop_index(
        op.f("ix_TRADING_REGIONSUM_REGIONID"), table_name="TRADING_REGIONSUM"
    )
    op.drop_table("TRADING_REGIONSUM")
    op.drop_index("uniq", table_name="TRADING_PRICE")
    op.drop_index(
        op.f("ix_TRADING_PRICE_SETTLEMENTDATE"), table_name="TRADING_PRICE"
    )
    op.drop_index(
        op.f("ix_TRADING_PRICE_REGIONID"), table_name="TRADING_PRICE"
    )
    op.drop_table("TRADING_PRICE")
    op.drop_index("uniq_idx", table_name="ROOFTOP_FORECAST")
    op.drop_index(
        op.f("ix_ROOFTOP_FORECAST_VERSION_DATETIME"),
        table_name="ROOFTOP_FORECAST",
    )
    op.drop_index(
        op.f("ix_ROOFTOP_FORECAST_REGIONID"), table_name="ROOFTOP_FORECAST"
    )
    op.drop_index(
        op.f("ix_ROOFTOP_FORECAST_INTERVAL_DATETIME"),
        table_name="ROOFTOP_FORECAST",
    )
    op.drop_table("ROOFTOP_FORECAST")
    op.drop_index("uniq_idx", table_name="ROOFTOP_ACTUAL")
    op.drop_index(
        op.f("ix_ROOFTOP_ACTUAL_REGIONID"), table_name="ROOFTOP_ACTUAL"
    )
    op.drop_index(
        op.f("ix_ROOFTOP_ACTUAL_INTERVAL_DATETIME"),
        table_name="ROOFTOP_ACTUAL",
    )
    op.drop_table("ROOFTOP_ACTUAL")
    op.drop_index("uniq", table_name="PREDISPATCH_REGION_SOLUTION")
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_REGIONID"),
        table_name="PREDISPATCH_REGION_SOLUTION",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_PREDISPATCHSEQNO"),
        table_name="PREDISPATCH_REGION_SOLUTION",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_PERIODID"),
        table_name="PREDISPATCH_REGION_SOLUTION",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_INTERVENTION"),
        table_name="PREDISPATCH_REGION_SOLUTION",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_SOLUTION_DATETIME"),
        table_name="PREDISPATCH_REGION_SOLUTION",
    )
    op.drop_table("PREDISPATCH_REGION_SOLUTION")
    op.drop_index("uniq", table_name="PREDISPATCH_REGION_PRICES")
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_REGIONID"),
        table_name="PREDISPATCH_REGION_PRICES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_PREDISPATCHSEQNO"),
        table_name="PREDISPATCH_REGION_PRICES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_PERIODID"),
        table_name="PREDISPATCH_REGION_PRICES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_INTERVENTION"),
        table_name="PREDISPATCH_REGION_PRICES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_REGION_PRICES_DATETIME"),
        table_name="PREDISPATCH_REGION_PRICES",
    )
    op.drop_table("PREDISPATCH_REGION_PRICES")
    op.drop_index("uniq_idx", table_name="PREDISPATCH_PRICESENSITIVITIES")
    op.drop_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_REGIONID"),
        table_name="PREDISPATCH_PRICESENSITIVITIES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_PREDISPATCHSEQNO"),
        table_name="PREDISPATCH_PRICESENSITIVITIES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_PERIODID"),
        table_name="PREDISPATCH_PRICESENSITIVITIES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_INTERVENTION_ACTIVE"),
        table_name="PREDISPATCH_PRICESENSITIVITIES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_INTERVENTION"),
        table_name="PREDISPATCH_PRICESENSITIVITIES",
    )
    op.drop_index(
        op.f("ix_PREDISPATCH_PRICESENSITIVITIES_DATETIME"),
        table_name="PREDISPATCH_PRICESENSITIVITIES",
    )
    op.drop_table("PREDISPATCH_PRICESENSITIVITIES")
    op.drop_index("uniq", table_name="P5MIN_REGIONSOLUTION")
    op.drop_index(
        op.f("ix_P5MIN_REGIONSOLUTION_RUN_DATETIME"),
        table_name="P5MIN_REGIONSOLUTION",
    )
    op.drop_index(
        op.f("ix_P5MIN_REGIONSOLUTION_REGIONID"),
        table_name="P5MIN_REGIONSOLUTION",
    )
    op.drop_index(
        op.f("ix_P5MIN_REGIONSOLUTION_INTERVAL_DATETIME"),
        table_name="P5MIN_REGIONSOLUTION",
    )
    op.drop_table("P5MIN_REGIONSOLUTION")
    op.drop_index(
        op.f("ix_OFFER_BIDPEROFFER_VERSIONNO"), table_name="OFFER_BIDPEROFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDPEROFFER_SETTLEMENTDATE"),
        table_name="OFFER_BIDPEROFFER",
    )
    op.drop_index(
        op.f("ix_OFFER_BIDPEROFFER_PERIODID"), table_name="OFFER_BIDPEROFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDPEROFFER_OFFERDATE"), table_name="OFFER_BIDPEROFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDPEROFFER_LASTCHANGED"),
        table_name="OFFER_BIDPEROFFER",
    )
    op.drop_index(
        op.f("ix_OFFER_BIDPEROFFER_DUID"), table_name="OFFER_BIDPEROFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDPEROFFER_BIDTYPE"), table_name="OFFER_BIDPEROFFER"
    )
    op.drop_table("OFFER_BIDPEROFFER")
    op.drop_index(
        op.f("ix_OFFER_BIDDAYOFFER_VERSIONNO"), table_name="OFFER_BIDDAYOFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDDAYOFFER_SETTLEMENTDATE"),
        table_name="OFFER_BIDDAYOFFER",
    )
    op.drop_index(
        op.f("ix_OFFER_BIDDAYOFFER_OFFERDATE"), table_name="OFFER_BIDDAYOFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDDAYOFFER_LASTCHANGED"),
        table_name="OFFER_BIDDAYOFFER",
    )
    op.drop_index(
        op.f("ix_OFFER_BIDDAYOFFER_ENTRYTYPE"), table_name="OFFER_BIDDAYOFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDDAYOFFER_DUID"), table_name="OFFER_BIDDAYOFFER"
    )
    op.drop_index(
        op.f("ix_OFFER_BIDDAYOFFER_BIDTYPE"), table_name="OFFER_BIDDAYOFFER"
    )
    op.drop_table("OFFER_BIDDAYOFFER")
    op.drop_index("uniq_idx", table_name="NEMPriceSetter")
    op.drop_index(
        op.f("ix_NEMPriceSetter_Unit_2"), table_name="NEMPriceSetter"
    )
    op.drop_index(op.f("ix_NEMPriceSetter_Unit"), table_name="NEMPriceSetter")
    op.drop_index(
        op.f("ix_NEMPriceSetter_REGIONID"), table_name="NEMPriceSetter"
    )
    op.drop_index(
        op.f("ix_NEMPriceSetter_PeriodID"), table_name="NEMPriceSetter"
    )
    op.drop_index(
        op.f("ix_NEMPriceSetter_OCD_flag"), table_name="NEMPriceSetter"
    )
    op.drop_index(
        op.f("ix_NEMPriceSetter_Market"), table_name="NEMPriceSetter"
    )
    op.drop_index(
        op.f("ix_NEMPriceSetter_DispatchedMarket"), table_name="NEMPriceSetter"
    )
    op.drop_table("NEMPriceSetter")
    op.drop_index("uniq", table_name="MTPASA_REGIONSOLUTION")
    op.drop_index(
        op.f("ix_MTPASA_REGIONSOLUTION_RUN_NO"),
        table_name="MTPASA_REGIONSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_REGIONSOLUTION_RUN_DATETIME"),
        table_name="MTPASA_REGIONSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_REGIONSOLUTION_RUNTYPE"),
        table_name="MTPASA_REGIONSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_REGIONSOLUTION_REGIONID"),
        table_name="MTPASA_REGIONSOLUTION",
    )
    op.drop_index(
        op.f("ix_MTPASA_REGIONSOLUTION_DAY"),
        table_name="MTPASA_REGIONSOLUTION",
    )
    op.drop_table("MTPASA_REGIONSOLUTION")
    op.drop_index(
        op.f("ix_METER_DATA_GEN_DUID_INTERVAL_DATETIME"),
        table_name="METER_DATA_GEN_DUID",
    )
    op.drop_index(
        op.f("ix_METER_DATA_GEN_DUID_DUID"), table_name="METER_DATA_GEN_DUID"
    )
    op.drop_index("DUID_2", table_name="METER_DATA_GEN_DUID")
    op.drop_table("METER_DATA_GEN_DUID")
    op.drop_index("uniq", table_name="DISPATCH_UNIT_SOLUTION_OLD")
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_OLD_SETTLEMENTDATE"),
        table_name="DISPATCH_UNIT_SOLUTION_OLD",
    )
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_OLD_INTERVENTION"),
        table_name="DISPATCH_UNIT_SOLUTION_OLD",
    )
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_OLD_DUID"),
        table_name="DISPATCH_UNIT_SOLUTION_OLD",
    )
    op.drop_table("DISPATCH_UNIT_SOLUTION_OLD")
    op.drop_index("uniq_idx", table_name="DISPATCH_UNIT_SOLUTION")
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_SETTLEMENTDATE"),
        table_name="DISPATCH_UNIT_SOLUTION",
    )
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_INTERVENTION"),
        table_name="DISPATCH_UNIT_SOLUTION",
    )
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_DUID"),
        table_name="DISPATCH_UNIT_SOLUTION",
    )
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_DISPATCHMODE"),
        table_name="DISPATCH_UNIT_SOLUTION",
    )
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SOLUTION_AGCSTATUS"),
        table_name="DISPATCH_UNIT_SOLUTION",
    )
    op.drop_table("DISPATCH_UNIT_SOLUTION")
    op.drop_index("uniq", table_name="DISPATCH_UNIT_SCADA")
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SCADA_SETTLEMENTDATE"),
        table_name="DISPATCH_UNIT_SCADA",
    )
    op.drop_index(
        op.f("ix_DISPATCH_UNIT_SCADA_DUID"), table_name="DISPATCH_UNIT_SCADA"
    )
    op.drop_table("DISPATCH_UNIT_SCADA")
    op.drop_index("uniq", table_name="DISPATCH_REGIONSUM")
    op.drop_index(
        op.f("ix_DISPATCH_REGIONSUM_SETTLEMENTDATE"),
        table_name="DISPATCH_REGIONSUM",
    )
    op.drop_index(
        op.f("ix_DISPATCH_REGIONSUM_REGIONID"), table_name="DISPATCH_REGIONSUM"
    )
    op.drop_index(
        op.f("ix_DISPATCH_REGIONSUM_INTERVENTION"),
        table_name="DISPATCH_REGIONSUM",
    )
    op.drop_index(
        op.f("ix_DISPATCH_REGIONSUM_DISPATCHINTERVAL"),
        table_name="DISPATCH_REGIONSUM",
    )
    op.drop_table("DISPATCH_REGIONSUM")
    op.drop_index("uniq", table_name="DISPATCH_PRICE")
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_SETTLEMENTDATE"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_REGIONID"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_RAISEREGAPCFLAG"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_RAISE6SECAPCFLAG"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_RAISE60SECAPCFLAG"),
        table_name="DISPATCH_PRICE",
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_RAISE5MINAPCFLAG"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_LOWERREGAPCFLAG"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_LOWER6SECAPCFLAG"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_LOWER60SECAPCFLAG"),
        table_name="DISPATCH_PRICE",
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_LOWER5MINAPCFLAG"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_INTERVENTION"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_DISPATCHINTERVAL"), table_name="DISPATCH_PRICE"
    )
    op.drop_index(
        op.f("ix_DISPATCH_PRICE_APCFLAG"), table_name="DISPATCH_PRICE"
    )
    op.drop_table("DISPATCH_PRICE")
    op.drop_index(
        op.f("ix_CO2EII_PUBLISHING_WEEKNO"), table_name="CO2EII_PUBLISHING"
    )
    op.drop_index(
        op.f("ix_CO2EII_PUBLISHING_SETTLEMENTDATE"),
        table_name="CO2EII_PUBLISHING",
    )
    op.drop_index(
        op.f("ix_CO2EII_PUBLISHING_REGIONID"), table_name="CO2EII_PUBLISHING"
    )
    op.drop_index(
        op.f("ix_CO2EII_PUBLISHING_CONTRACTYEAR"),
        table_name="CO2EII_PUBLISHING",
    )
    op.drop_index("SETTLEMENTDATE_2", table_name="CO2EII_PUBLISHING")
    op.drop_table("CO2EII_PUBLISHING")
    op.drop_table("REGIONID", schema="nemweb_meta")
    op.drop_table("DUID", schema="nemweb_meta")
    op.drop_table("Unit")
    op.drop_table("RUNTYPE")
    op.drop_table("REGIONID")
    op.drop_table("Market")
    op.drop_index(op.f("ix_INTERVAL_TABLE_YEAR"), table_name="INTERVAL_TABLE")
    op.drop_index(
        op.f("ix_INTERVAL_TABLE_WEEKDAY"), table_name="INTERVAL_TABLE"
    )
    op.drop_index(
        op.f("ix_INTERVAL_TABLE_TRADINGPERIOD"), table_name="INTERVAL_TABLE"
    )
    op.drop_index(
        op.f("ix_INTERVAL_TABLE_TRADINGINTERVAL"), table_name="INTERVAL_TABLE"
    )
    op.drop_index(op.f("ix_INTERVAL_TABLE_TIME"), table_name="INTERVAL_TABLE")
    op.drop_index(op.f("ix_INTERVAL_TABLE_MONTH"), table_name="INTERVAL_TABLE")
    op.drop_index(op.f("ix_INTERVAL_TABLE_FY"), table_name="INTERVAL_TABLE")
    op.drop_index(
        op.f("ix_INTERVAL_TABLE_DISPATCHPERIOD"), table_name="INTERVAL_TABLE"
    )
    op.drop_index(
        op.f("ix_INTERVAL_TABLE_DATETIME"), table_name="INTERVAL_TABLE"
    )
    op.drop_index(op.f("ix_INTERVAL_TABLE_DATE"), table_name="INTERVAL_TABLE")
    op.drop_table("INTERVAL_TABLE")
    op.drop_table("INTERCONNECTORID")
    op.drop_table("DispatchedMarket")
    op.drop_table("DUID")
    op.drop_table("BIDTYPE")
    # ### end Alembic commands ###


def upgrade_nemweb_meta():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "CATEGORY",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "CATEGORY",
            sa.String(length=10, collation="utf8_bin"),
            nullable=False,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("CATEGORY"),
    )
    op.create_table(
        "CLASSIFICATION",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "CLASSIFICATION",
            sa.String(length=15, collation="utf8_bin"),
            nullable=True,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("CLASSIFICATION"),
    )
    op.create_table(
        "CURRENT_REGISTER",
        sa.Column(
            "ID",
            mysql.SMALLINT(display_width=6),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("DUID", sa.String(length=10), nullable=True),
        sa.Column("STATION_NAME", sa.String(length=100), nullable=True),
        sa.Column("PARTICIPANT", sa.String(length=80), nullable=True),
        sa.Column("CLASSIFICATION", sa.String(length=15), nullable=True),
        sa.Column("CATEGORY", sa.String(length=10), nullable=True),
        sa.Column("TECHNOLOGY_TYPE", sa.String(length=60), nullable=True),
        sa.Column("FUEL_SOURCE", sa.String(length=45), nullable=True),
        sa.Column("REGIONID", sa.String(length=6), nullable=True),
        sa.Column("DISPATCH_TYPE", sa.String(length=45), nullable=True),
        sa.Column("UNIT_NO", sa.String(length=50), nullable=True),
        sa.Column(
            "UNIT_SIZE", sa.DECIMAL(precision=7, scale=3), nullable=True
        ),
        sa.Column("REG_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_ROC", sa.DECIMAL(precision=4, scale=0), nullable=True),
        sa.Column("DATE", sa.Date(), nullable=True),
    )
    op.create_table(
        "CURRENT_REGISTER_DATE", sa.Column("DATE", sa.Date(), nullable=True)
    )
    op.create_table(
        "DISPATCH_TYPE",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "DISPATCH_TYPE",
            sa.String(length=45, collation="utf8_bin"),
            nullable=False,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("DISPATCH_TYPE"),
    )
    op.create_table(
        "DUID",
        sa.Column("ID", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column("DUID", mysql.VARCHAR(length=10), nullable=True),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("DUID"),
    )
    op.create_table(
        "DUID_EFFICIENCY",
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column(
            "THERMAL_EFFICIENCY",
            sa.DECIMAL(precision=7, scale=4),
            nullable=True,
        ),
    )
    op.create_table(
        "FUEL_CATEGORY",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "FUEL_CATEGORY",
            sa.String(length=45, collation="utf8_bin"),
            nullable=True,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("ID"),
    )
    op.create_table(
        "FUEL_TECHS",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "FUEL_TECH",
            sa.String(length=45, collation="utf8_bin"),
            nullable=True,
        ),
        sa.Column(
            "openNEM_keys",
            sa.String(length=45, collation="utf8_bin"),
            nullable=True,
        ),
        sa.Column(
            "openNEM_colors",
            sa.String(length=7, collation="utf8_bin"),
            nullable=True,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("FUEL_TECH"),
        sa.UniqueConstraint("openNEM_keys"),
    )
    op.create_table(
        "FULL_REGISTER",
        sa.Column(
            "ID",
            mysql.SMALLINT(display_width=6),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("DUID", sa.String(length=10), nullable=True),
        sa.Column("STATION_NAME", sa.String(length=100), nullable=True),
        sa.Column("PARTICIPANT", sa.String(length=80), nullable=True),
        sa.Column("CLASSIFICATION", sa.String(length=15), nullable=True),
        sa.Column("CATEGORY", sa.String(length=10), nullable=True),
        sa.Column("DISPATCH_TYPE", sa.String(length=45), nullable=True),
        sa.Column("REGIONID", sa.String(length=6), nullable=True),
        sa.Column("FUEL_CATEGORY", sa.String(length=45), nullable=True),
        sa.Column("TECHNOLOGY_CATEGORY", sa.String(length=45), nullable=True),
        sa.Column("FUEL_TECH", sa.String(length=45), nullable=True),
        sa.Column("UNIT_NO", sa.String(length=50), nullable=True),
        sa.Column(
            "UNIT_SIZE", sa.DECIMAL(precision=7, scale=3), nullable=True
        ),
        sa.Column("REG_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_ROC", sa.DECIMAL(precision=4, scale=0), nullable=True),
        sa.Column("DATE", sa.Date(), nullable=True),
    )
    op.create_table(
        "GENERATOR_TECHNICAL_DATA",
        sa.Column(
            "STATION_NAME_ID", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("STATION_NAME", sa.String(length=100), nullable=True),
        sa.Column("REGIONID", sa.String(length=6), nullable=True),
        sa.Column("FUEL_TECH", sa.String(length=45), nullable=True),
        sa.Column(
            "CAPACITY", sa.DECIMAL(precision=29, scale=3), nullable=True
        ),
        sa.Column(
            "THERMAL_EFFICIENCY",
            sa.DECIMAL(precision=7, scale=4),
            nullable=True,
        ),
        sa.Column("SCOPE_1", sa.DECIMAL(precision=5, scale=4), nullable=True),
    )
    op.create_table(
        "LAST_REGISTERED_DATE",
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("LAST_DATE", sa.Date(), nullable=True),
    )
    op.create_table(
        "NEM_EMISSION_INTENSITY",
        sa.Column(
            "ID",
            mysql.SMALLINT(display_width=6),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("STATION_NAME", sa.String(length=100), nullable=True),
        sa.Column("SCOPE_1", sa.DECIMAL(precision=5, scale=4), nullable=True),
        sa.Column("SCOPE_3", sa.DECIMAL(precision=5, scale=4), nullable=True),
        sa.Column("TOTAL", sa.DECIMAL(precision=6, scale=4), nullable=True),
    )
    op.create_table(
        "PARTICIPANTS",
        sa.Column("ID", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column(
            "PARTICIPANT",
            sa.String(length=80, collation="utf8_bin"),
            nullable=True,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("PARTICIPANT"),
    )
    op.create_table(
        "REGIONID",
        sa.Column("id", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("REGIONID", mysql.VARCHAR(length=6), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("REGIONID"),
    )
    op.create_table(
        "REGION_SUMMARY",
        sa.Column("REGIONID", sa.String(length=6), nullable=True),
        sa.Column("FUEL_TECH", sa.String(length=45), nullable=True),
        sa.Column("MW", sa.DECIMAL(precision=29, scale=3), nullable=True),
    )
    op.create_table(
        "REGISTERED_GENERATORS",
        sa.Column("STATION_NAME", sa.String(length=100), nullable=True),
        sa.Column("MW", sa.DECIMAL(precision=29, scale=3), nullable=True),
    )
    op.create_table(
        "STANDARDISED_REGISTER",
        sa.Column(
            "id",
            mysql.SMALLINT(display_width=6),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("DUID", sa.String(length=10), nullable=True),
        sa.Column("STATION_NAME", sa.String(length=100), nullable=True),
        sa.Column("PARTICIPANT", sa.String(length=80), nullable=True),
        sa.Column("CLASSIFICATION", sa.String(length=15), nullable=True),
        sa.Column("CATEGORY", sa.String(length=10), nullable=True),
        sa.Column("DISPATCH_TYPE", sa.String(length=45), nullable=True),
        sa.Column("REGIONID", sa.String(length=6), nullable=True),
        sa.Column("FUEL_CATEGORY", sa.String(length=45), nullable=True),
        sa.Column("TECHNOLOGY_CATEGORY", sa.String(length=45), nullable=True),
        sa.Column("FUEL_TECH", sa.String(length=45), nullable=True),
        sa.Column("UNIT_NO", sa.String(length=50), nullable=True),
        sa.Column(
            "UNIT_SIZE", sa.DECIMAL(precision=7, scale=3), nullable=True
        ),
        sa.Column("REG_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_ROC", sa.DECIMAL(precision=4, scale=0), nullable=True),
        sa.Column("DATE", sa.Date(), nullable=True),
    )
    op.create_table(
        "STATION_NAMES",
        sa.Column("ID", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column(
            "STATION_NAME",
            sa.String(length=100, collation="utf8_bin"),
            nullable=True,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("STATION_NAME"),
    )
    op.create_table(
        "STATION_SUMMARY",
        sa.Column(
            "ID",
            mysql.SMALLINT(display_width=6),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("DUID", sa.String(length=10), nullable=True),
        sa.Column(
            "STATION_NAME_ID",
            mysql.SMALLINT(display_width=6),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("STATION_NAME", sa.String(length=100), nullable=True),
        sa.Column("PARTICIPANT", sa.String(length=80), nullable=True),
        sa.Column("REGIONID", sa.String(length=6), nullable=True),
        sa.Column("openNEM_keys", sa.String(length=45), nullable=True),
        sa.Column("openNEM_colors", sa.String(length=7), nullable=True),
        sa.Column("REG_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_ROC", sa.DECIMAL(precision=4, scale=0), nullable=True),
    )
    op.create_table(
        "TECHNOLOGY_CATEGORY",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "TECHNOLOGY_CATEGORY",
            sa.String(length=45, collation="utf8_bin"),
            nullable=True,
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("TECHNOLOGY_CATEGORY"),
    )
    op.create_table(
        "_MAPPING_FUEL_SOURCE",
        sa.Column(
            "ID",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("FUEL_SOURCE", sa.String(length=45), nullable=True),
        sa.Column("FUEL_CATEGORY", sa.String(length=45), nullable=True),
    )
    op.create_table(
        "_MAPPING_TECHNOLOGY_TYPE",
        sa.Column(
            "ID",
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'0'"),
            nullable=True,
        ),
        sa.Column("TECHNOLOGY_TYPE", sa.String(length=60), nullable=True),
        sa.Column("TECHNOLOGY_CATEGORY", sa.String(length=45), nullable=True),
    )
    op.create_table(
        "_MAPPING_TECH_FUEL",
        sa.Column("FUEL_TECH", sa.String(length=45), nullable=True),
        sa.Column("FUEL_CATEGORY", sa.String(length=45), nullable=True),
        sa.Column("TECHNOLOGY_CATEGORY", sa.String(length=45), nullable=True),
    )
    op.create_table(
        "FUEL_SOURCES",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "FUEL_SOURCE",
            sa.String(length=45, collation="utf8_bin"),
            nullable=True,
        ),
        sa.Column(
            "FUEL_CATEGORY_ID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.ForeignKeyConstraint(["FUEL_CATEGORY_ID"], ["FUEL_CATEGORY.ID"],),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("FUEL_SOURCE"),
    )
    op.create_index(
        op.f("ix_FUEL_SOURCES_FUEL_CATEGORY_ID"),
        "FUEL_SOURCES",
        ["FUEL_CATEGORY_ID"],
        unique=False,
    )
    op.create_table(
        "FUEL_TECH_MAPPING",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "FUEL_CATEGORY_ID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "TECHNOLOGY_CATEGORY_ID",
            mysql.TINYINT(display_width=4),
            nullable=True,
        ),
        sa.Column(
            "FUEL_TECH_ID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.ForeignKeyConstraint(["FUEL_CATEGORY_ID"], ["FUEL_CATEGORY.ID"],),
        sa.ForeignKeyConstraint(["FUEL_TECH_ID"], ["FUEL_TECHS.ID"],),
        sa.ForeignKeyConstraint(
            ["TECHNOLOGY_CATEGORY_ID"], ["TECHNOLOGY_CATEGORY.ID"],
        ),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_FUEL_TECH_MAPPING_FUEL_CATEGORY_ID"),
        "FUEL_TECH_MAPPING",
        ["FUEL_CATEGORY_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_FUEL_TECH_MAPPING_FUEL_TECH_ID"),
        "FUEL_TECH_MAPPING",
        ["FUEL_TECH_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_FUEL_TECH_MAPPING_TECHNOLOGY_CATEGORY_ID"),
        "FUEL_TECH_MAPPING",
        ["TECHNOLOGY_CATEGORY_ID"],
        unique=False,
    )
    op.create_table(
        "INTERCONNECTORID",
        sa.Column("id", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column("INTERCONNECTORID", mysql.VARCHAR(length=9), nullable=False),
        sa.Column(
            "FROM_REGIONID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.Column(
            "TO_REGIONID", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.ForeignKeyConstraint(["FROM_REGIONID"], ["REGIONID.id"],),
        sa.ForeignKeyConstraint(["TO_REGIONID"], ["REGIONID.id"],),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("INTERCONNECTORID"),
    )
    op.create_index(
        op.f("ix_INTERCONNECTORID_FROM_REGIONID"),
        "INTERCONNECTORID",
        ["FROM_REGIONID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_INTERCONNECTORID_TO_REGIONID"),
        "INTERCONNECTORID",
        ["TO_REGIONID"],
        unique=False,
    )
    op.create_table(
        "NTNDP_EMISSIONS",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(
            "NTNDP_STATION_NAME",
            sa.String(length=45, collation="utf8_bin"),
            nullable=True,
        ),
        sa.Column(
            "STATION_NAME_ID", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column("SCOPE_1", sa.DECIMAL(precision=5, scale=4), nullable=True),
        sa.Column("SCOPE_3", sa.DECIMAL(precision=5, scale=4), nullable=True),
        sa.ForeignKeyConstraint(["STATION_NAME_ID"], ["STATION_NAMES.ID"],),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("NTNDP_STATION_NAME"),
        sa.UniqueConstraint("STATION_NAME_ID"),
    )
    op.create_table(
        "NTNDP_TECHNICAL_DATA",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(
            "UNIT", sa.String(length=45, collation="utf8_bin"), nullable=True
        ),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("FIRST_RUN", mysql.SMALLINT(display_width=6), nullable=True),
        sa.Column("AUX_LOAD", mysql.TINYINT(display_width=4), nullable=True),
        sa.Column(
            "HOT_DAY_DERATE", sa.DECIMAL(precision=4, scale=2), nullable=True
        ),
        sa.Column(
            "ROCUP_START", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "ROCUP_NORM", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "ROCDOWN_START", mysql.SMALLINT(display_width=6), nullable=True
        ),
        sa.Column(
            "ROCDOWN_NORM", mysql.MEDIUMINT(display_width=9), nullable=True
        ),
        sa.Column(
            "THERMAL_EFFICIENCY", mysql.TINYINT(display_width=4), nullable=True
        ),
        sa.ForeignKeyConstraint(["DUID"], ["DUID.ID"],),
        sa.PrimaryKeyConstraint("ID"),
    )
    op.create_index(
        op.f("ix_NTNDP_TECHNICAL_DATA_DUID"),
        "NTNDP_TECHNICAL_DATA",
        ["DUID"],
        unique=False,
    )
    op.create_table(
        "RET_BASELINE",
        sa.Column("ID", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column("BASELINE", mysql.INTEGER(display_width=11), nullable=False),
        sa.ForeignKeyConstraint(["ID"], ["DUID.ID"],),
    )
    op.create_index(
        op.f("ix_RET_BASELINE_ID"), "RET_BASELINE", ["ID"], unique=False
    )
    op.create_table(
        "TECHNOLOGY_TYPES",
        sa.Column("ID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "TECHNOLOGY_TYPE",
            sa.String(length=60, collation="utf8_bin"),
            nullable=True,
        ),
        sa.Column(
            "TECHNOLOGY_CATEGORY_ID",
            mysql.TINYINT(display_width=4),
            nullable=True,
        ),
        sa.ForeignKeyConstraint(
            ["TECHNOLOGY_CATEGORY_ID"], ["TECHNOLOGY_CATEGORY.ID"],
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("TECHNOLOGY_TYPE"),
    )
    op.create_index(
        op.f("ix_TECHNOLOGY_TYPES_TECHNOLOGY_CATEGORY_ID"),
        "TECHNOLOGY_TYPES",
        ["TECHNOLOGY_CATEGORY_ID"],
        unique=False,
    )
    op.create_table(
        "REGISTER",
        sa.Column("ID", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column("DUID", mysql.SMALLINT(display_width=6), nullable=False),
        sa.Column(
            "PARTICIPANT_ID", mysql.SMALLINT(display_width=6), nullable=False
        ),
        sa.Column(
            "STATION_NAME_ID", mysql.SMALLINT(display_width=6), nullable=False
        ),
        sa.Column("REGIONID", mysql.TINYINT(display_width=4), nullable=False),
        sa.Column(
            "DISPATCH_TYPE_ID", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.Column(
            "CATEGORY_ID", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.Column(
            "CLASSIFICATION_ID", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.Column(
            "FUEL_SOURCE_ID", mysql.TINYINT(display_width=4), nullable=False
        ),
        sa.Column(
            "TECHNOLOGY_TYPE_ID",
            mysql.TINYINT(display_width=4),
            nullable=False,
        ),
        sa.Column("UNIT_NO", mysql.VARCHAR(length=50), nullable=True),
        sa.Column(
            "UNIT_SIZE", sa.DECIMAL(precision=7, scale=3), nullable=True
        ),
        sa.Column("MAX_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("REG_CAP", sa.DECIMAL(precision=7, scale=3), nullable=True),
        sa.Column("MAX_ROC", sa.DECIMAL(precision=4, scale=0), nullable=True),
        sa.Column("DATE", sa.Date(), nullable=False),
        sa.ForeignKeyConstraint(["CATEGORY_ID"], ["CATEGORY.ID"],),
        sa.ForeignKeyConstraint(["CLASSIFICATION_ID"], ["CLASSIFICATION.ID"],),
        sa.ForeignKeyConstraint(["DISPATCH_TYPE_ID"], ["DISPATCH_TYPE.ID"],),
        sa.ForeignKeyConstraint(["DUID"], ["DUID.ID"],),
        sa.ForeignKeyConstraint(["FUEL_SOURCE_ID"], ["FUEL_SOURCES.ID"],),
        sa.ForeignKeyConstraint(["PARTICIPANT_ID"], ["PARTICIPANTS.ID"],),
        sa.ForeignKeyConstraint(["REGIONID"], ["REGIONID.id"],),
        sa.ForeignKeyConstraint(["STATION_NAME_ID"], ["STATION_NAMES.ID"],),
        sa.ForeignKeyConstraint(
            ["TECHNOLOGY_TYPE_ID"], ["TECHNOLOGY_TYPES.ID"],
        ),
        sa.PrimaryKeyConstraint("ID"),
        sa.UniqueConstraint("ID"),
    )
    op.create_index(
        op.f("ix_REGISTER_CATEGORY_ID"),
        "REGISTER",
        ["CATEGORY_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_REGISTER_CLASSIFICATION_ID"),
        "REGISTER",
        ["CLASSIFICATION_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_REGISTER_DATE"), "REGISTER", ["DATE"], unique=False
    )
    op.create_index(
        op.f("ix_REGISTER_DISPATCH_TYPE_ID"),
        "REGISTER",
        ["DISPATCH_TYPE_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_REGISTER_DUID"), "REGISTER", ["DUID"], unique=False
    )
    op.create_index(
        op.f("ix_REGISTER_FUEL_SOURCE_ID"),
        "REGISTER",
        ["FUEL_SOURCE_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_REGISTER_PARTICIPANT_ID"),
        "REGISTER",
        ["PARTICIPANT_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_REGISTER_REGIONID"), "REGISTER", ["REGIONID"], unique=False
    )
    op.create_index(
        op.f("ix_REGISTER_STATION_NAME_ID"),
        "REGISTER",
        ["STATION_NAME_ID"],
        unique=False,
    )
    op.create_index(
        op.f("ix_REGISTER_TECHNOLOGY_TYPE_ID"),
        "REGISTER",
        ["TECHNOLOGY_TYPE_ID"],
        unique=False,
    )
    op.create_index(
        "uniq",
        "REGISTER",
        ["DATE", "DUID", "UNIT_SIZE", "UNIT_NO"],
        unique=True,
    )
    # ### end Alembic commands ###


def downgrade_nemweb_meta():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("uniq", table_name="REGISTER")
    op.drop_index(
        op.f("ix_REGISTER_TECHNOLOGY_TYPE_ID"), table_name="REGISTER"
    )
    op.drop_index(op.f("ix_REGISTER_STATION_NAME_ID"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_REGIONID"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_PARTICIPANT_ID"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_FUEL_SOURCE_ID"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_DUID"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_DISPATCH_TYPE_ID"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_DATE"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_CLASSIFICATION_ID"), table_name="REGISTER")
    op.drop_index(op.f("ix_REGISTER_CATEGORY_ID"), table_name="REGISTER")
    op.drop_table("REGISTER")
    op.drop_index(
        op.f("ix_TECHNOLOGY_TYPES_TECHNOLOGY_CATEGORY_ID"),
        table_name="TECHNOLOGY_TYPES",
    )
    op.drop_table("TECHNOLOGY_TYPES")
    op.drop_index(op.f("ix_RET_BASELINE_ID"), table_name="RET_BASELINE")
    op.drop_table("RET_BASELINE")
    op.drop_index(
        op.f("ix_NTNDP_TECHNICAL_DATA_DUID"), table_name="NTNDP_TECHNICAL_DATA"
    )
    op.drop_table("NTNDP_TECHNICAL_DATA")
    op.drop_table("NTNDP_EMISSIONS")
    op.drop_index(
        op.f("ix_INTERCONNECTORID_TO_REGIONID"), table_name="INTERCONNECTORID"
    )
    op.drop_index(
        op.f("ix_INTERCONNECTORID_FROM_REGIONID"),
        table_name="INTERCONNECTORID",
    )
    op.drop_table("INTERCONNECTORID")
    op.drop_index(
        op.f("ix_FUEL_TECH_MAPPING_TECHNOLOGY_CATEGORY_ID"),
        table_name="FUEL_TECH_MAPPING",
    )
    op.drop_index(
        op.f("ix_FUEL_TECH_MAPPING_FUEL_TECH_ID"),
        table_name="FUEL_TECH_MAPPING",
    )
    op.drop_index(
        op.f("ix_FUEL_TECH_MAPPING_FUEL_CATEGORY_ID"),
        table_name="FUEL_TECH_MAPPING",
    )
    op.drop_table("FUEL_TECH_MAPPING")
    op.drop_index(
        op.f("ix_FUEL_SOURCES_FUEL_CATEGORY_ID"), table_name="FUEL_SOURCES"
    )
    op.drop_table("FUEL_SOURCES")
    op.drop_table("_MAPPING_TECH_FUEL")
    op.drop_table("_MAPPING_TECHNOLOGY_TYPE")
    op.drop_table("_MAPPING_FUEL_SOURCE")
    op.drop_table("TECHNOLOGY_CATEGORY")
    op.drop_table("STATION_SUMMARY")
    op.drop_table("STATION_NAMES")
    op.drop_table("STANDARDISED_REGISTER")
    op.drop_table("REGISTERED_GENERATORS")
    op.drop_table("REGION_SUMMARY")
    op.drop_table("REGIONID")
    op.drop_table("PARTICIPANTS")
    op.drop_table("NEM_EMISSION_INTENSITY")
    op.drop_table("LAST_REGISTERED_DATE")
    op.drop_table("GENERATOR_TECHNICAL_DATA")
    op.drop_table("FULL_REGISTER")
    op.drop_table("FUEL_TECHS")
    op.drop_table("FUEL_CATEGORY")
    op.drop_table("DUID_EFFICIENCY")
    op.drop_table("DUID")
    op.drop_table("DISPATCH_TYPE")
    op.drop_table("CURRENT_REGISTER_DATE")
    op.drop_table("CURRENT_REGISTER")
    op.drop_table("CLASSIFICATION")
    op.drop_table("CATEGORY")
    # ### end Alembic commands ###
