34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
"""chat scoped repository bindings"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "0002_repository_bindings"
|
|
down_revision = "0001_initial"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"repository_bindings",
|
|
sa.Column("id", sa.Integer(), primary_key=True),
|
|
sa.Column("chat_id", sa.BigInteger(), nullable=False),
|
|
sa.Column("thread_id", sa.BigInteger(), nullable=True),
|
|
sa.Column("url", sa.String(length=2000), nullable=False),
|
|
sa.Column("branch", sa.String(length=255), nullable=False, server_default="HEAD"),
|
|
sa.Column("cache_path", sa.String(length=2000), nullable=False, unique=True),
|
|
sa.Column("commit", sa.String(length=64), nullable=False),
|
|
sa.Column("attached_by", sa.BigInteger(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
sa.Column("synced_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
)
|
|
op.create_index("ix_repository_bindings_chat_id", "repository_bindings", ["chat_id"])
|
|
op.create_index("ix_repository_bindings_thread_id", "repository_bindings", ["thread_id"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_repository_bindings_thread_id", table_name="repository_bindings")
|
|
op.drop_index("ix_repository_bindings_chat_id", table_name="repository_bindings")
|
|
op.drop_table("repository_bindings")
|