"""Add object_storage_meta table

Revision ID: 902837cf18b4
Revises: 32764dcd0fad
Create Date: 2025-08-25 05:41:10.014103

"""

import sqlalchemy as sa
from alembic import op

from ai.backend.manager.models.base import GUID

# revision identifiers, used by Alembic.
revision = "902837cf18b4"
down_revision = "32764dcd0fad"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "object_storage_meta",
        sa.Column("id", GUID(), server_default=sa.text("uuid_generate_v4()"), nullable=False),
        sa.Column("storage_id", GUID(), nullable=False),
        sa.Column("bucket", sa.String(), nullable=False),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_object_storage_meta")),
    )
    op.create_unique_constraint(
        "uq_storage_id_bucket", "object_storage_meta", ["storage_id", "bucket"]
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("uq_storage_id_bucket", "object_storage_meta", type_="unique")
    op.drop_table("object_storage_meta")
    # ### end Alembic commands ###
