mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-14 22:53:27 +08:00
feat(persistence): PostgreSQL assistant store, chat persist fixes, gateway scripts
- 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>
This commit is contained in:
parent
2b32d11f43
commit
d14e9d3596
103 changed files with 7574 additions and 1641 deletions
34
assistant_migrations/versions/001_assistant_pg_initial.py
Normal file
34
assistant_migrations/versions/001_assistant_pg_initial.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
"""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.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue