"""record model

Revision ID: 6c2a16b349b1
Revises: 2bafd0d01ae2
Create Date: 2021-11-20 18:51:45.427996

"""
import sqlalchemy as sa
import sqlmodel
import sqlmodel.sql.sqltypes
from alembic import op

# revision identifiers, used by Alembic.
revision = "6c2a16b349b1"
down_revision = "2bafd0d01ae2"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "records",
        sa.Column(
            "created_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.Column("problem_set_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
        sa.Column("problem_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
        sa.Column("user_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
        sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column("status", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
        sa.Column("score", sa.Integer(), nullable=True),
        sa.Column("time_ms", sa.Integer(), nullable=True),
        sa.Column("memory_kb", sa.Integer(), nullable=True),
        sa.Column("commit_id", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
        sa.ForeignKeyConstraint(["problem_id"], ["problems.id"], ondelete="SET NULL"),
        sa.ForeignKeyConstraint(
            ["problem_set_id"], ["problem_sets.id"], ondelete="SET NULL"
        ),
        sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="SET NULL"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_records_commit_id"), "records", ["commit_id"], unique=False
    )
    op.create_index(
        op.f("ix_records_created_at"), "records", ["created_at"], unique=False
    )
    op.create_index(op.f("ix_records_id"), "records", ["id"], unique=False)
    op.create_index(
        op.f("ix_records_memory_kb"), "records", ["memory_kb"], unique=False
    )
    op.create_index(op.f("ix_records_score"), "records", ["score"], unique=False)
    op.create_index(op.f("ix_records_status"), "records", ["status"], unique=False)
    op.create_index(op.f("ix_records_time_ms"), "records", ["time_ms"], unique=False)
    op.create_index(
        op.f("ix_records_updated_at"), "records", ["updated_at"], unique=False
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_records_updated_at"), table_name="records")
    op.drop_index(op.f("ix_records_time_ms"), table_name="records")
    op.drop_index(op.f("ix_records_status"), table_name="records")
    op.drop_index(op.f("ix_records_score"), table_name="records")
    op.drop_index(op.f("ix_records_memory_kb"), table_name="records")
    op.drop_index(op.f("ix_records_id"), table_name="records")
    op.drop_index(op.f("ix_records_created_at"), table_name="records")
    op.drop_index(op.f("ix_records_commit_id"), table_name="records")
    op.drop_table("records")
    # ### end Alembic commands ###

sqlmodel.sql.sqltypes.GUID sqlalchemy.ForeignKeyConstraint sqlalchemy.text sqlalchemy.DateTime alembic.op.drop_table alembic.op.f sqlalchemy.PrimaryKeyConstraint sqlalchemy.Integer sqlmodel.sql.sqltypes.AutoString
[((3269, 3293), 'alembic.op.drop_table', 'op.drop_table', (['"""records"""'], {}), "('records')\n", (3282, 3293), False, 'from alembic import op\n'), ((1521, 1598), 'sqlalchemy.ForeignKeyConstraint', 'sa.ForeignKeyConstraint', (["['problem_id']", "['problems.id']"], {'ondelete': '"""SET NULL"""'}), "(['problem_id'], ['problems.id'], ondelete='SET NULL')\n", (1544, 1598), True, 'import sqlalchemy as sa\n'), ((1608, 1698), 'sqlalchemy.ForeignKeyConstraint', 'sa.ForeignKeyConstraint', (["['problem_set_id']", "['problem_sets.id']"], {'ondelete': '"""SET NULL"""'}), "(['problem_set_id'], ['problem_sets.id'], ondelete=\n    'SET NULL')\n", (1631, 1698), True, 'import sqlalchemy as sa\n'), ((1725, 1796), 'sqlalchemy.ForeignKeyConstraint', 'sa.ForeignKeyConstraint', (["['user_id']", "['users.id']"], {'ondelete': '"""SET NULL"""'}), "(['user_id'], ['users.id'], ondelete='SET NULL')\n", (1748, 1796), True, 'import sqlalchemy as sa\n'), ((1806, 1835), 'sqlalchemy.PrimaryKeyConstraint', 'sa.PrimaryKeyConstraint', (['"""id"""'], {}), "('id')\n", (1829, 1835), True, 'import sqlalchemy as sa\n'), ((1872, 1900), 'alembic.op.f', 'op.f', (['"""ix_records_commit_id"""'], {}), "('ix_records_commit_id')\n", (1876, 1900), False, 'from alembic import op\n'), ((1976, 2005), 'alembic.op.f', 'op.f', (['"""ix_records_created_at"""'], {}), "('ix_records_created_at')\n", (1980, 2005), False, 'from alembic import op\n'), ((2073, 2094), 'alembic.op.f', 'op.f', (['"""ix_records_id"""'], {}), "('ix_records_id')\n", (2077, 2094), False, 'from alembic import op\n'), ((2158, 2186), 'alembic.op.f', 'op.f', (['"""ix_records_memory_kb"""'], {}), "('ix_records_memory_kb')\n", (2162, 2186), False, 'from alembic import op\n'), ((2253, 2277), 'alembic.op.f', 'op.f', (['"""ix_records_score"""'], {}), "('ix_records_score')\n", (2257, 2277), False, 'from alembic import op\n'), ((2335, 2360), 'alembic.op.f', 'op.f', (['"""ix_records_status"""'], {}), "('ix_records_status')\n", (2339, 2360), False, 'from alembic import op\n'), ((2419, 2445), 'alembic.op.f', 'op.f', (['"""ix_records_time_ms"""'], {}), "('ix_records_time_ms')\n", (2423, 2445), False, 'from alembic import op\n'), ((2514, 2543), 'alembic.op.f', 'op.f', (['"""ix_records_updated_at"""'], {}), "('ix_records_updated_at')\n", (2518, 2543), False, 'from alembic import op\n'), ((2737, 2766), 'alembic.op.f', 'op.f', (['"""ix_records_updated_at"""'], {}), "('ix_records_updated_at')\n", (2741, 2766), False, 'from alembic import op\n'), ((2808, 2834), 'alembic.op.f', 'op.f', (['"""ix_records_time_ms"""'], {}), "('ix_records_time_ms')\n", (2812, 2834), False, 'from alembic import op\n'), ((2876, 2901), 'alembic.op.f', 'op.f', (['"""ix_records_status"""'], {}), "('ix_records_status')\n", (2880, 2901), False, 'from alembic import op\n'), ((2943, 2967), 'alembic.op.f', 'op.f', (['"""ix_records_score"""'], {}), "('ix_records_score')\n", (2947, 2967), False, 'from alembic import op\n'), ((3009, 3037), 'alembic.op.f', 'op.f', (['"""ix_records_memory_kb"""'], {}), "('ix_records_memory_kb')\n", (3013, 3037), False, 'from alembic import op\n'), ((3079, 3100), 'alembic.op.f', 'op.f', (['"""ix_records_id"""'], {}), "('ix_records_id')\n", (3083, 3100), False, 'from alembic import op\n'), ((3142, 3171), 'alembic.op.f', 'op.f', (['"""ix_records_created_at"""'], {}), "('ix_records_created_at')\n", (3146, 3171), False, 'from alembic import op\n'), ((3213, 3241), 'alembic.op.f', 'op.f', (['"""ix_records_commit_id"""'], {}), "('ix_records_commit_id')\n", (3217, 3241), False, 'from alembic import op\n'), ((528, 554), 'sqlalchemy.DateTime', 'sa.DateTime', ([], {'timezone': '(True)'}), '(timezone=True)\n', (539, 554), True, 'import sqlalchemy as sa\n'), ((726, 752), 'sqlalchemy.DateTime', 'sa.DateTime', ([], {'timezone': '(True)'}), '(timezone=True)\n', (737, 752), True, 'import sqlalchemy as sa\n'), ((903, 931), 'sqlmodel.sql.sqltypes.GUID', 'sqlmodel.sql.sqltypes.GUID', ([], {}), '()\n', (929, 931), False, 'import sqlmodel\n'), ((981, 1009), 'sqlmodel.sql.sqltypes.GUID', 'sqlmodel.sql.sqltypes.GUID', ([], {}), '()\n', (1007, 1009), False, 'import sqlmodel\n'), ((1056, 1084), 'sqlmodel.sql.sqltypes.GUID', 'sqlmodel.sql.sqltypes.GUID', ([], {}), '()\n', (1082, 1084), False, 'import sqlmodel\n'), ((1126, 1154), 'sqlmodel.sql.sqltypes.GUID', 'sqlmodel.sql.sqltypes.GUID', ([], {}), '()\n', (1152, 1154), False, 'import sqlmodel\n'), ((1201, 1235), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (1233, 1235), False, 'import sqlmodel\n'), ((1280, 1292), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1290, 1292), True, 'import sqlalchemy as sa\n'), ((1339, 1351), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1349, 1351), True, 'import sqlalchemy as sa\n'), ((1400, 1412), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1410, 1412), True, 'import sqlalchemy as sa\n'), ((1461, 1495), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (1493, 1495), False, 'import sqlmodel\n'), ((583, 628), 'sqlalchemy.text', 'sa.text', (['"""TIMEZONE(\'utc\', CURRENT_TIMESTAMP)"""'], {}), '("TIMEZONE(\'utc\', CURRENT_TIMESTAMP)")\n', (590, 628), True, 'import sqlalchemy as sa\n'), ((781, 826), 'sqlalchemy.text', 'sa.text', (['"""TIMEZONE(\'utc\', CURRENT_TIMESTAMP)"""'], {}), '("TIMEZONE(\'utc\', CURRENT_TIMESTAMP)")\n', (788, 826), True, 'import sqlalchemy as sa\n')]