"""Make global column for files, require owner

Revision ID: a5e9ddfd39fc
Revises: 3759d5136235
Create Date: 2023-10-06 09:29:00.442800

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "a5e9ddfd39fc"
down_revision = "3759d5136235"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("DELETE FROM inference_embeddings")
    op.execute("DELETE FROM embeddings")
    op.execute("DELETE FROM documents")

    op.add_column("documents", sa.Column("is_global", sa.Boolean(), nullable=False))
    op.alter_column("documents", "owner_id", existing_type=sa.VARCHAR(), nullable=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column("documents", "owner_id", existing_type=sa.VARCHAR(), nullable=True)
    op.drop_column("documents", "is_global")
    # ### end Alembic commands ###
