mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 04:17:56 +00:00
The backend import package is now docsgpt, the name it will carry on PyPI; application was far too generic to install into anyone's site-packages. git mv plus a mechanical rewrite of every import, dotted string and path reference: 734 Python files, the compose files, Dockerfile, workflows, docs, setup scripts, devcontainer, k8s manifests, vscode config, pytest and coverage config, .gitignore. Behaviour is unchanged. Kept for one release: - A top-level application package whose meta-path finder resolves application.x.y to the already-imported docsgpt.x.y object, so old imports and entry points (celery -A application.app.celery, uvicorn application.asgi:asgi_app) keep working with a FutureWarning. - Celery registers every application.* task name as an alias of its docsgpt.* task on start-up, so messages queued by the previous release still run. The redbeat key prefix moves to redbeat:docsgpt:v2: so schedule entries the previous release wrote are left unread instead of firing twice. The backend image builds from the repository root (docker build -f docsgpt/Dockerfile .) so it can ship the alias package; a root .dockerignore allow-lists docsgpt/ and application/ and keeps caches, local data, .env files, the sample index files and the Dockerfile out. Compose and the image workflows point at the new context.
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
"""0011 scheduler — make schedules.agent_id / schedule_runs.agent_id nullable.
|
|
|
|
Agentless schedules (created from agentless chats via the dual-registered
|
|
``scheduler`` default chat tool) carry ``agent_id IS NULL``. Existing FK +
|
|
``ON DELETE CASCADE`` semantics on ``agents(id)`` are unaffected — Postgres
|
|
only cascades when the parent row is deleted, NULL rows aren't matched.
|
|
|
|
Revision ID: 0011_schedules_nullable_agent
|
|
Revises: 0010_schedules
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
|
|
|
|
revision: str = "0011_schedules_nullable_agent"
|
|
down_revision: Union[str, None] = "0010_schedules"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.execute("ALTER TABLE schedules ALTER COLUMN agent_id DROP NOT NULL;")
|
|
op.execute("ALTER TABLE schedule_runs ALTER COLUMN agent_id DROP NOT NULL;")
|
|
|
|
|
|
def downgrade() -> None:
|
|
# Destructive otherwise: agentless rows have agent_id IS NULL by design,
|
|
# so restoring NOT NULL must fail loudly if any exist.
|
|
op.execute(
|
|
"""
|
|
DO $$
|
|
DECLARE
|
|
sched_nulls INTEGER;
|
|
run_nulls INTEGER;
|
|
BEGIN
|
|
SELECT count(*) INTO sched_nulls
|
|
FROM schedules WHERE agent_id IS NULL;
|
|
SELECT count(*) INTO run_nulls
|
|
FROM schedule_runs WHERE agent_id IS NULL;
|
|
IF sched_nulls > 0 OR run_nulls > 0 THEN
|
|
RAISE EXCEPTION
|
|
'Cannot downgrade 0011: agentless rows present '
|
|
'(schedules=%, schedule_runs=%). '
|
|
'Delete or reassign them before retrying.',
|
|
sched_nulls, run_nulls;
|
|
END IF;
|
|
END$$;
|
|
"""
|
|
)
|
|
op.execute("ALTER TABLE schedule_runs ALTER COLUMN agent_id SET NOT NULL;")
|
|
op.execute("ALTER TABLE schedules ALTER COLUMN agent_id SET NOT NULL;")
|