"""add messages

Revision ID: d2388da5bbfd
Revises: <PASSWORD>
Create Date: 2022-05-04 21:49:29.234380+00:00

"""
import sqlalchemy as sa
import sqlmodel
from alembic import op

from common.database.tables.types import TimeStamp

# revision identifiers, used by Alembic.
revision = "d2388da5bbfd"
down_revision = "3<PASSWORD>"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "messages",
        sa.Column(
            "created_at",
            TimeStamp(),
            server_default=sa.func.now(),
            nullable=False,
        ),
        sa.Column(
            "updated_at",
            TimeStamp(),
            server_default=sa.func.now(),
            nullable=False,
        ),
        sa.Column("sent", sa.Boolean(), nullable=False),
        sa.Column("subject", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("content", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "recipients",
        sa.Column("message_id", sa.Integer(), nullable=True),
        sa.Column(
            "group",
            sa.Enum(
                "EVERYONE",
                "APPLICATION_COMPLETE",
                "APPLICATION_INCOMPLETE",
                "STATUS_ACCEPTED",
                "STATUS_DENIED",
                "STATUS_PENDING",
                name="group",
            ),
            nullable=False,
        ),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(["message_id"], ["messages.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("recipients")
    op.drop_table("messages")
    # ### end Alembic commands ###

sqlmodel.sql.sqltypes.AutoString sqlalchemy.Integer common.database.tables.types.TimeStamp sqlalchemy.func.now alembic.op.drop_table sqlalchemy.PrimaryKeyConstraint sqlalchemy.Enum sqlalchemy.Boolean sqlalchemy.ForeignKeyConstraint
[((1885, 1912), 'alembic.op.drop_table', 'op.drop_table', (['"""recipients"""'], {}), "('recipients')\n", (1898, 1912), False, 'from alembic import op\n'), ((1917, 1942), 'alembic.op.drop_table', 'op.drop_table', (['"""messages"""'], {}), "('messages')\n", (1930, 1942), False, 'from alembic import op\n'), ((1076, 1105), 'sqlalchemy.PrimaryKeyConstraint', 'sa.PrimaryKeyConstraint', (['"""id"""'], {}), "('id')\n", (1099, 1105), True, 'import sqlalchemy as sa\n'), ((1638, 1714), 'sqlalchemy.ForeignKeyConstraint', 'sa.ForeignKeyConstraint', (["['message_id']", "['messages.id']"], {'ondelete': '"""CASCADE"""'}), "(['message_id'], ['messages.id'], ondelete='CASCADE')\n", (1661, 1714), True, 'import sqlalchemy as sa\n'), ((1724, 1753), 'sqlalchemy.PrimaryKeyConstraint', 'sa.PrimaryKeyConstraint', (['"""id"""'], {}), "('id')\n", (1747, 1753), True, 'import sqlalchemy as sa\n'), ((547, 558), 'common.database.tables.types.TimeStamp', 'TimeStamp', ([], {}), '()\n', (556, 558), False, 'from common.database.tables.types import TimeStamp\n'), ((698, 709), 'common.database.tables.types.TimeStamp', 'TimeStamp', ([], {}), '()\n', (707, 709), False, 'from common.database.tables.types import TimeStamp\n'), ((818, 830), 'sqlalchemy.Boolean', 'sa.Boolean', ([], {}), '()\n', (828, 830), True, 'import sqlalchemy as sa\n'), ((878, 912), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (910, 912), False, 'import sqlmodel\n'), ((960, 994), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (992, 994), False, 'import sqlmodel\n'), ((1037, 1049), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1047, 1049), True, 'import sqlalchemy as sa\n'), ((1188, 1200), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1198, 1200), True, 'import sqlalchemy as sa\n'), ((1270, 1411), 'sqlalchemy.Enum', 'sa.Enum', (['"""EVERYONE"""', '"""APPLICATION_COMPLETE"""', '"""APPLICATION_INCOMPLETE"""', '"""STATUS_ACCEPTED"""', '"""STATUS_DENIED"""', '"""STATUS_PENDING"""'], {'name': '"""group"""'}), "('EVERYONE', 'APPLICATION_COMPLETE', 'APPLICATION_INCOMPLETE',\n    'STATUS_ACCEPTED', 'STATUS_DENIED', 'STATUS_PENDING', name='group')\n", (1277, 1411), True, 'import sqlalchemy as sa\n'), ((1599, 1611), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1609, 1611), True, 'import sqlalchemy as sa\n'), ((587, 600), 'sqlalchemy.func.now', 'sa.func.now', ([], {}), '()\n', (598, 600), True, 'import sqlalchemy as sa\n'), ((738, 751), 'sqlalchemy.func.now', 'sa.func.now', ([], {}), '()\n', (749, 751), True, 'import sqlalchemy as sa\n')]