"""Add object_storages table

Revision ID: e38044633465
Revises: 42feff246198
Create Date: 2025-08-13 06:15:55.574744

"""

import sqlalchemy as sa
from alembic import op

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

# revision identifiers, used by Alembic.
revision = "e38044633465"
down_revision = "42feff246198"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "object_storages",
        sa.Column("id", GUID(), server_default=sa.text("uuid_generate_v4()"), nullable=False),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("host", sa.String(), nullable=False),
        sa.Column("access_key", sa.String(), nullable=False),
        sa.Column("secret_key", sa.String(), nullable=False),
        sa.Column("endpoint", sa.String(), nullable=False),
        sa.Column("region", sa.String(), nullable=True),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_object_storages")),
    )
    op.create_index(op.f("ix_object_storages_host"), "object_storages", ["host"], unique=False)
    op.create_index(op.f("ix_object_storages_name"), "object_storages", ["name"], unique=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_object_storages_name"), table_name="object_storages")
    op.drop_index(op.f("ix_object_storages_host"), table_name="object_storages")
    op.drop_table("object_storages")
    # ### end Alembic commands ###
