Fix: conversation_artifacts missing for run_analysis_artifact
Summary
Resolved run_analysis_artifact failures caused by relation "conversation_artifacts" does not exist.
What changed
- Applied the required database migration directly:
services/backend/src/db/migrations/0034_conversation_artifacts_analysis_workflow.sqlservices/backend/src/db/migrations/0039_web_search_cache_knowledge_base.sql(kept schema in expected shape for related artifact/caching flows)
- Added backend guardrails in
services/backend/src/routes/bots/bots-chat-handlers.ts:listConversationArtifacts(...)now catches PostgreSQLundefined_table(42P01) forconversation_artifactsand returns an empty list with a warning instead of crashing the chat flow.loadCodeArtifact(...)now catches the same condition and throws an actionable error message instructing to run migration0034_conversation_artifacts_analysis_workflow.sql.- Added
isPgUndefinedTableError(...)helper to centralize this check.
Why
The runtime code expects conversation_artifacts to exist for loading/saving analysis artifacts. If a target Neon environment misses migration 0034, run_analysis_artifact fails with a raw SQL error. This change fixes current schema drift and improves resilience if drift reappears.
Validation
- Ran migration command path in project root and confirmed table exists.
- Verified relation:
SELECT to_regclass('public.conversation_artifacts');
-- conversation_artifacts
- Ran repository checks:
pnpm typecheckpnpm lint
Both completed successfully with existing non-blocking warnings (no new errors introduced by this change).
Notes
- Full migration runner (
pnpm migrate:neon) currently stops at an older non-idempotent migration (0007_exchange_credentials_and_orders.sql) in this environment due torelation "exchange_credentials" already exists. - Applied targeted migrations to unblock the production issue immediately.