"""initial schema

Revision ID: 000000000000
Revises:
Create Date: 2025-11-19 12:53:20.486640

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '000000000000'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('list',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('address', sa.String(), nullable=False),
    sa.Column('from_addr', sa.String(), nullable=True),
    sa.Column('avoid_duplicates', sa.Boolean(), nullable=True),
    sa.Column('mode', sa.String(), nullable=False),
    sa.Column('only_subscribers_send', sa.Boolean(), nullable=True),
    sa.Column('allowed_senders', sa.JSON(), nullable=True),
    sa.Column('sender_auth', sa.JSON(), nullable=True),
    sa.Column('imap_host', sa.String(), nullable=False),
    sa.Column('imap_port', sa.Integer(), nullable=False),
    sa.Column('imap_user', sa.String(), nullable=False),
    sa.Column('imap_pass', sa.String(), nullable=False),
    sa.Column('deleted', sa.Boolean(), nullable=True),
    sa.Column('deleted_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('address')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=100), nullable=False),
    sa.Column('password', sa.String(), nullable=False),
    sa.Column('role', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('username')
    )
    op.create_table('message',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('list_id', sa.Integer(), nullable=True),
    sa.Column('message_id', sa.String(), nullable=False),
    sa.Column('subject', sa.String(), nullable=True),
    sa.Column('from_addr', sa.String(), nullable=True),
    sa.Column('headers', sa.Text(), nullable=False),
    sa.Column('raw', sa.Text(), nullable=True),
    sa.Column('received_at', sa.DateTime(), nullable=True),
    sa.Column('status', sa.String(), nullable=True),
    sa.Column('error_info', sa.JSON(), nullable=True),
    sa.ForeignKeyConstraint(['list_id'], ['list.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('message_id')
    )
    op.create_table('subscriber',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('list_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('comment', sa.String(), nullable=True),
    sa.Column('subscriber_type', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['list_id'], ['list.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('subscriber')
    op.drop_table('message')
    op.drop_table('user')
    op.drop_table('list')
    # ### end Alembic commands ###
