"""empty message

Revision ID: c66f2c5b6cb1
Revises: 89081a00fc7d
Create Date: 2022-07-21 19:06:38.330239

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


# revision identifiers, used by Alembic.
revision = 'c66f2c5b6cb1'
down_revision = '89081a00fc7d'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('newsletter',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
    sa.Column('subject', sa.String(), nullable=False),
    sa.Column('html', sa.Text(), nullable=True),
    sa.Column('plain_text', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_newsletter_subject'), 'newsletter', ['subject'], unique=True)
    op.create_table('newsletter_user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('newsletter_id', sa.Integer(), nullable=True),
    sa.Column('sent_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.ForeignKeyConstraint(['newsletter_id'], ['newsletter.id'], ondelete='cascade'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('newsletter_user')
    op.drop_index(op.f('ix_newsletter_subject'), table_name='newsletter')
    op.drop_table('newsletter')
    # ### end Alembic commands ###
