Create Relay Bot MVP

This commit is contained in:
Emil
2026-07-24 22:36:04 +03:00
commit d6dc624301
51 changed files with 2226 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
"""initial schema"""
from alembic import op
from app.database.models import Base
revision = "0001_initial"
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
bind = op.get_bind()
Base.metadata.create_all(
bind,
tables=[
table for table in Base.metadata.sorted_tables if table.name != "repository_bindings"
],
)
def downgrade() -> None:
Base.metadata.drop_all(op.get_bind())
@@ -0,0 +1,33 @@
"""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")