mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-03 20:12:55 +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.
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
"""One-shot bootstrap: run all Alembic migrations against POSTGRES_URI.
|
|
|
|
Intended use:
|
|
|
|
* local dev, after setting ``POSTGRES_URI`` in ``.env``::
|
|
|
|
python scripts/db/init_postgres.py
|
|
|
|
* CI, as a step before running the pytest suite.
|
|
|
|
* Docker image build or container start, if the operator wants the
|
|
migrations applied automatically on first boot.
|
|
|
|
This script is a thin wrapper around ``alembic upgrade head``. It exists
|
|
separately so the same command is discoverable from the repo root without
|
|
remembering the ``-c docsgpt/alembic.ini`` invocation.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from alembic import command
|
|
from alembic.config import Config
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
ALEMBIC_INI = REPO_ROOT / "docsgpt" / "alembic.ini"
|
|
|
|
|
|
def main() -> int:
|
|
"""Apply every pending migration up to ``head``.
|
|
|
|
Returns:
|
|
``0`` on success, ``1`` on failure. Non-zero is propagated as the
|
|
process exit code so CI jobs fail loudly.
|
|
"""
|
|
if not ALEMBIC_INI.exists():
|
|
print(f"alembic.ini not found at {ALEMBIC_INI}", file=sys.stderr)
|
|
return 1
|
|
|
|
cfg = Config(str(ALEMBIC_INI))
|
|
# Make `script_location` resolve correctly when invoked from any cwd.
|
|
cfg.set_main_option("script_location", str(ALEMBIC_INI.parent / "alembic"))
|
|
|
|
try:
|
|
command.upgrade(cfg, "head")
|
|
except Exception as exc: # noqa: BLE001 — surface everything to the operator
|
|
print(f"alembic upgrade failed: {exc}", file=sys.stderr)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|