Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

1.9 KB
Raw Blame
"""store large remote authorization claims outside browser cookies

Revision ID: 20260725_0038
Revises: 20260725_0037
Create Date: 2026-07-25
"""

from __future__ import annotations

import sqlalchemy as sa
from alembic import op

revision = "20260725_0038"
down_revision = "20260725_0037"
branch_labels = None
depends_on = None


def _tables(bind) -> set[str]:
    return {
        str(row[0])
        for row in bind.exec_driver_sql(
            "select name from sqlite_master where type = 'table'"
        )
    }


def upgrade() -> None:
    if "remote_access_authorizations" not in _tables(op.get_bind()):
        op.create_table(
            "remote_access_authorizations",
            sa.Column("id", sa.String(), nullable=False),
            sa.Column("instance_id", sa.String(), nullable=False),
            sa.Column("subject", sa.String(), nullable=False),
            sa.Column("claims_json", sa.Text(), nullable=False),
            sa.Column("expires_at", sa.Integer(), nullable=False),
            sa.Column("created_at", sa.Integer(), nullable=False),
            sa.PrimaryKeyConstraint("id"),
        )
    # Outside the table guard on purpose -- this revision used to return early on
    # the table alone, which made the index unreachable in exactly the state that
    # needs it. A run interrupted between the two leaves the table present and the
    # index missing, and 20260819_0056 would then stamp over it permanently.
    op.create_index(
        "ix_remote_access_authorizations_expires",
        "remote_access_authorizations",
        ["expires_at"],
        if_not_exists=True,
    )


def downgrade() -> None:
    if "remote_access_authorizations" not in _tables(op.get_bind()):
        return
    op.drop_index(
        "ix_remote_access_authorizations_expires",
        table_name="remote_access_authorizations",
    )
    op.drop_table("remote_access_authorizations")