mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 07:03:15 +08:00
- Add SQLAlchemy Core repos, pg adapter/compat, assistant_store factory, Alembic bootstrap and migration/cutover scripts. - Harden chat_message writes (NUL scrub for PG), turn_uuid on attempt failure, WS turn_runner fallbacks and gateway executed_turn_uuid init. - start_gateway: log paths, PS7 stderr handling via cmd, background stdout/stderr redirect; runtime assistant_runtime_log_dir export. - Ops: clear_all_chat_sessions with PG-only --postgresql and env-gated wipe; clear_postgres_chat_sessions.ps1. - Tests: SA repos, pg compat, persist fallback, smoke env isolation; CI and docs touch-ups. Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
932 B
Python
34 lines
932 B
Python
"""Initial PostgreSQL schema for assistant store (from SQLite parity DDL)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from alembic import op
|
|
from sqlalchemy import text
|
|
|
|
revision = "001_assistant_pg_initial"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
bind = op.get_bind()
|
|
if bind.dialect.name != "postgresql":
|
|
return
|
|
root = Path(__file__).resolve().parents[2]
|
|
sql_path = root / "svc" / "persistence" / "ddl" / "postgresql_bootstrap.sql"
|
|
raw = sql_path.read_text(encoding="utf-8")
|
|
for part in raw.split(";"):
|
|
stmt = part.strip()
|
|
if not stmt or stmt.startswith("--"):
|
|
continue
|
|
op.execute(text(stmt))
|
|
|
|
|
|
def downgrade() -> None:
|
|
bind = op.get_bind()
|
|
if bind.dialect.name != "postgresql":
|
|
return
|
|
raise NotImplementedError("Assistant PG downgrade not supported; restore from backup.")
|