"""empty message

Revision ID: ac840f4e3061
Revises: 
Create Date: 2023-12-30 16:44:56.996566

"""

import sqlalchemy as sa
from alembic import op

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


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "users",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("username", sa.Text(), nullable=True),
        sa.Column("balance", sa.Float(), server_default="0", nullable=False),
        sa.Column("spend", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("performer", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("favorite", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("last_checked_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("join_date", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.Column("updated_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "hosts",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.Text(), nullable=False),
        sa.Column("identifier", sa.Text(), nullable=True),
        sa.Column("password", sa.Text(), nullable=True),
        sa.Column("source", sa.Boolean(), server_default="True", nullable=False),
        sa.Column("active", sa.Boolean(), server_default="True", nullable=False),
        sa.PrimaryKeyConstraint("id"),
        schema="management",
    )
    op.create_table(
        "servers",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.Text(), nullable=False),
        sa.Column("ip", sa.Text(), nullable=False),
        sa.Column("mac_address", sa.Text(), nullable=False),
        sa.Column("job_limit", sa.SmallInteger(), server_default="10", nullable=False),
        sa.Column("active", sa.SmallInteger(), server_default="1", nullable=False),
        sa.PrimaryKeyConstraint("id"),
        schema="management",
    )
    op.create_table(
        "sites",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.Text(), nullable=False),
        sa.Column("db_name", sa.Text(), nullable=False),
        sa.Column("url", sa.Text(), nullable=False),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("size", sa.BigInteger(), server_default="0", nullable=False),
        sa.Column("user_id_checkpoint", sa.BigInteger(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        schema="management",
    )
    op.create_table(
        "users",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("username", sa.Text(), nullable=True),
        sa.Column("balance", sa.Float(), server_default="0", nullable=False),
        sa.Column("spend", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("performer", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("favorite", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("last_checked_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("join_date", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.Column("updated_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "bought_content",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("supplier_id", sa.BigInteger(), nullable=False),
        sa.Column("buyer_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["buyer_id"],
            ["fansly.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["supplier_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "favorite_users",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("notification", sa.Boolean(), server_default="true", nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id"),
        schema="fansly",
    )
    op.create_table(
        "histo_user_infos",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("promotion", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("post_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("media_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("image_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("video_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("audio_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("stream_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "archived_post_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column(
            "private_archived_post_count",
            sa.Integer(),
            server_default="0",
            nullable=False,
        ),
        sa.Column("favourited_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("favourites_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "subscribers_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column("size", sa.BigInteger(), server_default="0", nullable=False),
        sa.Column("location", sa.Text(), nullable=True),
        sa.Column("website", sa.Text(), nullable=True),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("now()"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "jobs",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("site_id", sa.BigInteger(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("user_username", sa.Text(), nullable=False),
        sa.Column("category", sa.Text(), nullable=False),
        sa.Column("server_id", sa.BigInteger(), nullable=False),
        sa.Column("host_id", sa.BigInteger(), nullable=True),
        sa.Column("skippable", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("priority", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("completed_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["host_id"],
            ["management.hosts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["server_id"],
            ["management.servers.id"],
        ),
        sa.ForeignKeyConstraint(
            ["site_id"],
            ["management.sites.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("site_id", "user_id", "category"),
        schema="fansly",
    )
    op.create_table(
        "mass_message_stats",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("media_count", sa.SmallInteger(), nullable=False),
        sa.Column("buyer_count", sa.SmallInteger(), nullable=False),
        sa.Column("sent_count", sa.Integer(), nullable=False),
        sa.Column("view_count", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "media",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("url", sa.Text(), nullable=True),
        sa.Column("size", sa.BigInteger(), server_default="0", nullable=False),
        sa.Column("category", sa.String(), nullable=True),
        sa.Column("preview", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "notifications",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=True),
        sa.Column("category", sa.String(), nullable=False),
        sa.Column("sent_discord", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "sent_telegram", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id", "category"),
        schema="fansly",
    )
    op.create_table(
        "remote_urls",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("host_id", sa.BigInteger(), nullable=False),
        sa.Column("url", sa.Text(), nullable=True),
        sa.Column("exists", sa.Boolean(), server_default="False", nullable=False),
        sa.Column("uploaded_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["host_id"],
            ["management.hosts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "socials",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("site", sa.String(), nullable=False),
        sa.Column("identifier", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "subscriptions",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("subscriber_id", sa.BigInteger(), nullable=False),
        sa.Column("paid_content", sa.Boolean(), server_default="0", nullable=False),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.Column("renewed_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("expires_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["subscriber_id"],
            ["fansly.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id", "subscriber_id"),
        schema="fansly",
    )
    op.create_table(
        "user_aliases",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("username", sa.String(length=50), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id", "username"),
        schema="fansly",
    )
    op.create_table(
        "user_auths",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("cookie", sa.Text(), nullable=True),
        sa.Column("x_bc", sa.Text(), nullable=True),
        sa.Column("authorization", sa.Text(), nullable=True),
        sa.Column("user_agent", sa.Text(), nullable=False),
        sa.Column("email", sa.Text(), nullable=True),
        sa.Column("password", sa.Text(), nullable=True),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("cookie", "authorization"),
        schema="fansly",
    )
    op.create_table(
        "user_infos",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("promotion", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("sex", sa.SmallInteger(), nullable=True),
        sa.Column("post_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("media_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("image_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("video_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("audio_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("stream_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "archived_post_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column(
            "private_archived_post_count",
            sa.Integer(),
            server_default="0",
            nullable=False,
        ),
        sa.Column("favourited_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("favourites_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "subscribers_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column("size", sa.BigInteger(), server_default="0", nullable=False),
        sa.Column("location", sa.Text(), nullable=True),
        sa.Column("website", sa.Text(), nullable=True),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("first_downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("uploaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id"),
        schema="fansly",
    )
    op.create_index(
        op.f("ix_fansly_user_infos_sex"),
        "user_infos",
        ["sex"],
        unique=False,
        schema="fansly",
    )
    op.create_table(
        "x_posts",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("text", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("deleted", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("archived", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("paid", sa.Boolean(), nullable=True),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "x_stories",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "bought_content",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("supplier_id", sa.BigInteger(), nullable=False),
        sa.Column("buyer_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["buyer_id"],
            ["onlyfans.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["supplier_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "favorite_users",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("notification", sa.Boolean(), server_default="true", nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id"),
        schema="onlyfans",
    )
    op.create_table(
        "histo_user_infos",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("promotion", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("post_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("media_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("image_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("video_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("audio_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("stream_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "archived_post_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column(
            "private_archived_post_count",
            sa.Integer(),
            server_default="0",
            nullable=False,
        ),
        sa.Column("favourited_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("favourites_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "subscribers_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column("size", sa.BigInteger(), server_default="0", nullable=False),
        sa.Column("location", sa.Text(), nullable=True),
        sa.Column("website", sa.Text(), nullable=True),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("now()"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "jobs",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("site_id", sa.BigInteger(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("user_username", sa.Text(), nullable=False),
        sa.Column("category", sa.Text(), nullable=False),
        sa.Column("server_id", sa.BigInteger(), nullable=False),
        sa.Column("host_id", sa.BigInteger(), nullable=True),
        sa.Column("skippable", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("priority", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("completed_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["host_id"],
            ["management.hosts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["server_id"],
            ["management.servers.id"],
        ),
        sa.ForeignKeyConstraint(
            ["site_id"],
            ["management.sites.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("site_id", "user_id", "category"),
        schema="onlyfans",
    )
    op.create_table(
        "mass_message_stats",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("media_count", sa.SmallInteger(), nullable=False),
        sa.Column("buyer_count", sa.SmallInteger(), nullable=False),
        sa.Column("sent_count", sa.Integer(), nullable=False),
        sa.Column("view_count", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "media",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("url", sa.Text(), nullable=True),
        sa.Column("size", sa.BigInteger(), server_default="0", nullable=False),
        sa.Column("category", sa.String(), nullable=True),
        sa.Column("preview", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "notifications",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=True),
        sa.Column("category", sa.String(), nullable=False),
        sa.Column("sent_discord", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "sent_telegram", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id", "category"),
        schema="onlyfans",
    )
    op.create_table(
        "remote_urls",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("host_id", sa.BigInteger(), nullable=False),
        sa.Column("url", sa.Text(), nullable=True),
        sa.Column("exists", sa.Boolean(), server_default="False", nullable=False),
        sa.Column("uploaded_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["host_id"],
            ["management.hosts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "socials",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("site", sa.String(), nullable=False),
        sa.Column("identifier", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "subscriptions",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("subscriber_id", sa.BigInteger(), nullable=False),
        sa.Column("paid_content", sa.Boolean(), server_default="0", nullable=False),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.Column("renewed_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("expires_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["subscriber_id"],
            ["onlyfans.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id", "subscriber_id"),
        schema="onlyfans",
    )
    op.create_table(
        "user_aliases",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("username", sa.String(length=50), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id", "username"),
        schema="onlyfans",
    )
    op.create_table(
        "user_auths",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("cookie", sa.Text(), nullable=True),
        sa.Column("x_bc", sa.Text(), nullable=True),
        sa.Column("authorization", sa.Text(), nullable=True),
        sa.Column("user_agent", sa.Text(), nullable=False),
        sa.Column("email", sa.Text(), nullable=True),
        sa.Column("password", sa.Text(), nullable=True),
        sa.Column("active", sa.Boolean(), server_default="true", nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("cookie", "authorization"),
        schema="onlyfans",
    )
    op.create_table(
        "user_infos",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("promotion", sa.Boolean(), server_default="true", nullable=False),
        sa.Column("sex", sa.SmallInteger(), nullable=True),
        sa.Column("post_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("media_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("image_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("video_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("audio_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("stream_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "archived_post_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column(
            "private_archived_post_count",
            sa.Integer(),
            server_default="0",
            nullable=False,
        ),
        sa.Column("favourited_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("favourites_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column(
            "subscribers_count", sa.Integer(), server_default="0", nullable=False
        ),
        sa.Column("size", sa.BigInteger(), server_default="0", nullable=False),
        sa.Column("location", sa.Text(), nullable=True),
        sa.Column("website", sa.Text(), nullable=True),
        sa.Column("downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("first_downloaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column("uploaded_at", sa.TIMESTAMP(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user_id"),
        schema="onlyfans",
    )
    op.create_index(
        op.f("ix_onlyfans_user_infos_sex"),
        "user_infos",
        ["sex"],
        unique=False,
        schema="onlyfans",
    )
    op.create_table(
        "x_posts",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("text", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("deleted", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("archived", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("paid", sa.Boolean(), nullable=True),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "x_stories",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "comments",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("post_id", sa.BigInteger(), nullable=False),
        sa.Column("reply_id", sa.BigInteger(), nullable=True),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("giphy_id", sa.String(), nullable=True),
        sa.Column("text", sa.String(), nullable=True),
        sa.Column("likes_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["fansly.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["reply_id"],
            ["fansly.comments.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "linked_posts",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("post_id", sa.BigInteger(), nullable=False),
        sa.Column("linked_post_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["linked_post_id"],
            ["fansly.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["fansly.x_posts.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "linked_users",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("post_id", sa.BigInteger(), nullable=False),
        sa.Column("linked_user_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["linked_user_id"],
            ["fansly.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["fansly.x_posts.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "media_detections",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("media_id", sa.BigInteger(), nullable=False),
        sa.Column("label", sa.Text(), nullable=False),
        sa.Column("face_female", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "female_genitalia_covered",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "female_genitalia_exposed",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "female_breast_covered",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "female_breast_exposed",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column("face_male", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "male_genitalia_exposed",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "male_breast_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "buttocks_covered", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "buttocks_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column("anus_covered", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("anus_exposed", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("feet_covered", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("feet_exposed", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "belly_covered", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "belly_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "armpits_covered", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "armpits_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column("score", sa.Float(), server_default="0", nullable=False),
        sa.Column("x_coord", sa.Integer(), nullable=True),
        sa.Column("y_coord", sa.Integer(), nullable=True),
        sa.Column("width", sa.Integer(), nullable=True),
        sa.Column("height", sa.Integer(), nullable=True),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["media_id"],
            ["fansly.media.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "x_mass_messages",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("statistic_id", sa.BigInteger(), nullable=True),
        sa.Column("text", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), nullable=False),
        sa.Column("expires_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["statistic_id"],
            ["fansly.mass_message_stats.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "comments",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("post_id", sa.BigInteger(), nullable=False),
        sa.Column("reply_id", sa.BigInteger(), nullable=True),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("giphy_id", sa.String(), nullable=True),
        sa.Column("text", sa.String(), nullable=True),
        sa.Column("likes_count", sa.Integer(), server_default="0", nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["onlyfans.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["reply_id"],
            ["onlyfans.comments.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "linked_posts",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("post_id", sa.BigInteger(), nullable=False),
        sa.Column("linked_post_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["linked_post_id"],
            ["onlyfans.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["onlyfans.x_posts.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "linked_users",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("post_id", sa.BigInteger(), nullable=False),
        sa.Column("linked_user_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["linked_user_id"],
            ["onlyfans.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["onlyfans.x_posts.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "media_detections",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("media_id", sa.BigInteger(), nullable=False),
        sa.Column("label", sa.Text(), nullable=False),
        sa.Column("face_female", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "female_genitalia_covered",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "female_genitalia_exposed",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "female_breast_covered",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "female_breast_exposed",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column("face_male", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "male_genitalia_exposed",
            sa.Boolean(),
            server_default="false",
            nullable=False,
        ),
        sa.Column(
            "male_breast_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "buttocks_covered", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "buttocks_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column("anus_covered", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("anus_exposed", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("feet_covered", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("feet_exposed", sa.Boolean(), server_default="false", nullable=False),
        sa.Column(
            "belly_covered", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "belly_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "armpits_covered", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column(
            "armpits_exposed", sa.Boolean(), server_default="false", nullable=False
        ),
        sa.Column("score", sa.Float(), server_default="0", nullable=False),
        sa.Column("x_coord", sa.Integer(), nullable=True),
        sa.Column("y_coord", sa.Integer(), nullable=True),
        sa.Column("width", sa.Integer(), nullable=True),
        sa.Column("height", sa.Integer(), nullable=True),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["media_id"],
            ["onlyfans.media.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "x_mass_messages",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("statistic_id", sa.BigInteger(), nullable=True),
        sa.Column("text", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), nullable=False),
        sa.Column("expires_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["statistic_id"],
            ["onlyfans.mass_message_stats.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "x_messages",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("receiver_id", sa.BigInteger(), nullable=True),
        sa.Column("queue_id", sa.BigInteger(), nullable=True),
        sa.Column("text", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("deleted", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("paid", sa.Boolean(), nullable=True),
        sa.Column("verified", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["queue_id"],
            ["fansly.x_mass_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["receiver_id"],
            ["fansly.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["fansly.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="fansly",
    )
    op.create_table(
        "x_messages",
        sa.Column("id", sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column("user_id", sa.BigInteger(), nullable=False),
        sa.Column("receiver_id", sa.BigInteger(), nullable=True),
        sa.Column("queue_id", sa.BigInteger(), nullable=True),
        sa.Column("text", sa.Text(), nullable=True),
        sa.Column("price", sa.Float(), server_default="0", nullable=False),
        sa.Column("deleted", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("paid", sa.Boolean(), nullable=True),
        sa.Column("verified", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(
            ["queue_id"],
            ["onlyfans.x_mass_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["receiver_id"],
            ["onlyfans.users.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["onlyfans.users.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        schema="onlyfans",
    )
    op.create_table(
        "content_media_asso",
        sa.Column("id", sa.BigInteger(), nullable=False),
        sa.Column("story_id", sa.BigInteger(), nullable=True),
        sa.Column("post_id", sa.BigInteger(), nullable=True),
        sa.Column("message_id", sa.BigInteger(), nullable=True),
        sa.Column("mass_message_id", sa.BigInteger(), nullable=True),
        sa.Column("media_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["mass_message_id"],
            ["fansly.x_mass_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["media_id"],
            ["fansly.media.id"],
        ),
        sa.ForeignKeyConstraint(
            ["message_id"],
            ["fansly.x_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["fansly.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["story_id"],
            ["fansly.x_stories.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("mass_message_id", "media_id"),
        sa.UniqueConstraint("message_id", "media_id"),
        sa.UniqueConstraint("post_id", "media_id"),
        sa.UniqueConstraint("story_id", "media_id"),
        schema="fansly",
    )
    op.create_table(
        "filepaths",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("filepath", sa.String(length=255), nullable=False),
        sa.Column("preview", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("downloaded", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("story_id", sa.BigInteger(), nullable=True),
        sa.Column("post_id", sa.BigInteger(), nullable=True),
        sa.Column("message_id", sa.BigInteger(), nullable=True),
        sa.Column("mass_message_id", sa.BigInteger(), nullable=True),
        sa.Column("media_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["mass_message_id"],
            ["fansly.x_mass_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["media_id"],
            ["fansly.media.id"],
        ),
        sa.ForeignKeyConstraint(
            ["message_id"],
            ["fansly.x_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["fansly.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["story_id"],
            ["fansly.x_stories.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("mass_message_id", "media_id"),
        sa.UniqueConstraint("message_id", "media_id"),
        sa.UniqueConstraint("post_id", "media_id"),
        sa.UniqueConstraint("story_id", "media_id"),
        schema="fansly",
    )
    op.create_table(
        "content_media_asso",
        sa.Column("id", sa.BigInteger(), nullable=False),
        sa.Column("story_id", sa.BigInteger(), nullable=True),
        sa.Column("post_id", sa.BigInteger(), nullable=True),
        sa.Column("message_id", sa.BigInteger(), nullable=True),
        sa.Column("mass_message_id", sa.BigInteger(), nullable=True),
        sa.Column("media_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["mass_message_id"],
            ["onlyfans.x_mass_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["media_id"],
            ["onlyfans.media.id"],
        ),
        sa.ForeignKeyConstraint(
            ["message_id"],
            ["onlyfans.x_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["onlyfans.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["story_id"],
            ["onlyfans.x_stories.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("mass_message_id", "media_id"),
        sa.UniqueConstraint("message_id", "media_id"),
        sa.UniqueConstraint("post_id", "media_id"),
        sa.UniqueConstraint("story_id", "media_id"),
        schema="onlyfans",
    )
    op.create_table(
        "filepaths",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("filepath", sa.String(length=255), nullable=False),
        sa.Column("preview", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("downloaded", sa.Boolean(), server_default="false", nullable=False),
        sa.Column("story_id", sa.BigInteger(), nullable=True),
        sa.Column("post_id", sa.BigInteger(), nullable=True),
        sa.Column("message_id", sa.BigInteger(), nullable=True),
        sa.Column("mass_message_id", sa.BigInteger(), nullable=True),
        sa.Column("media_id", sa.BigInteger(), nullable=False),
        sa.ForeignKeyConstraint(
            ["mass_message_id"],
            ["onlyfans.x_mass_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["media_id"],
            ["onlyfans.media.id"],
        ),
        sa.ForeignKeyConstraint(
            ["message_id"],
            ["onlyfans.x_messages.id"],
        ),
        sa.ForeignKeyConstraint(
            ["post_id"],
            ["onlyfans.x_posts.id"],
        ),
        sa.ForeignKeyConstraint(
            ["story_id"],
            ["onlyfans.x_stories.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("mass_message_id", "media_id"),
        sa.UniqueConstraint("message_id", "media_id"),
        sa.UniqueConstraint("post_id", "media_id"),
        sa.UniqueConstraint("story_id", "media_id"),
        schema="onlyfans",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("filepaths", schema="onlyfans")
    op.drop_table("content_media_asso", schema="onlyfans")
    op.drop_table("filepaths", schema="fansly")
    op.drop_table("content_media_asso", schema="fansly")
    op.drop_table("x_messages", schema="onlyfans")
    op.drop_table("x_messages", schema="fansly")
    op.drop_table("x_mass_messages", schema="onlyfans")
    op.drop_table("media_detections", schema="onlyfans")
    op.drop_table("linked_users", schema="onlyfans")
    op.drop_table("linked_posts", schema="onlyfans")
    op.drop_table("comments", schema="onlyfans")
    op.drop_table("x_mass_messages", schema="fansly")
    op.drop_table("media_detections", schema="fansly")
    op.drop_table("linked_users", schema="fansly")
    op.drop_table("linked_posts", schema="fansly")
    op.drop_table("comments", schema="fansly")
    op.drop_table("x_stories", schema="onlyfans")
    op.drop_table("x_posts", schema="onlyfans")
    op.drop_index(
        op.f("ix_onlyfans_user_infos_sex"), table_name="user_infos", schema="onlyfans"
    )
    op.drop_table("user_infos", schema="onlyfans")
    op.drop_table("user_auths", schema="onlyfans")
    op.drop_table("user_aliases", schema="onlyfans")
    op.drop_table("subscriptions", schema="onlyfans")
    op.drop_table("socials", schema="onlyfans")
    op.drop_table("remote_urls", schema="onlyfans")
    op.drop_table("notifications", schema="onlyfans")
    op.drop_table("media", schema="onlyfans")
    op.drop_table("mass_message_stats", schema="onlyfans")
    op.drop_table("jobs", schema="onlyfans")
    op.drop_table("histo_user_infos", schema="onlyfans")
    op.drop_table("favorite_users", schema="onlyfans")
    op.drop_table("bought_content", schema="onlyfans")
    op.drop_table("x_stories", schema="fansly")
    op.drop_table("x_posts", schema="fansly")
    op.drop_index(
        op.f("ix_fansly_user_infos_sex"), table_name="user_infos", schema="fansly"
    )
    op.drop_table("user_infos", schema="fansly")
    op.drop_table("user_auths", schema="fansly")
    op.drop_table("user_aliases", schema="fansly")
    op.drop_table("subscriptions", schema="fansly")
    op.drop_table("socials", schema="fansly")
    op.drop_table("remote_urls", schema="fansly")
    op.drop_table("notifications", schema="fansly")
    op.drop_table("media", schema="fansly")
    op.drop_table("mass_message_stats", schema="fansly")
    op.drop_table("jobs", schema="fansly")
    op.drop_table("histo_user_infos", schema="fansly")
    op.drop_table("favorite_users", schema="fansly")
    op.drop_table("bought_content", schema="fansly")
    op.drop_table("users", schema="onlyfans")
    op.drop_table("sites", schema="management")
    op.drop_table("servers", schema="management")
    op.drop_table("hosts", schema="management")
    op.drop_table("users", schema="fansly")
    # ### end Alembic commands ###
