|
1 | 1 | -- Drop legacy request and response tables and their foreign key constraints |
2 | | --- These tables were used before ClickHouse migration and are no longer needed |
3 | | --- All data is now stored in ClickHouse (request_response_rmt table) |
4 | | --- Note: Avoiding CASCADE to prevent performance issues with large datasets |
| 2 | +-- ============================================================================ |
5 | 3 | -- |
6 | | --- IMPORTANT: The following code files have been updated to work without these tables: |
7 | | --- - valhalla/jawn/src/lib/stores/request/VersionedRequestStore.ts (deprecated putPropertyAndBumpVersion) |
8 | | --- - valhalla/jawn/src/managers/request/RequestManager.ts (updated waitForRequestAndResponse to use ClickHouse) |
9 | | --- - valhalla/jawn/src/lib/stores/ScoreStore.ts (deprecated bumpRequestVersion) |
10 | | --- - valhalla/jawn/src/managers/inputs/InputsManager.ts (removed request/response table joins) |
| 4 | +-- CONTEXT: These tables were used before the ClickHouse migration (2023-2024). |
| 5 | +-- All new request/response data is now stored exclusively in ClickHouse's |
| 6 | +-- request_response_rmt table. No new inserts have been happening to these |
| 7 | +-- Postgres tables for months. |
11 | 8 | -- |
12 | | --- WARNING: The following files may still reference these tables and may need updates: |
13 | | --- - valhalla/jawn/src/lib/stores/experimentStore.ts |
14 | | --- - valhalla/jawn/src/lib/stores/request/request.ts (getRequests function - likely unused) |
15 | | --- - valhalla/jawn/src/managers/dataset/DatasetManager.ts |
16 | | --- - valhalla/jawn/src/managers/experiment/ExperimentV2Manager.ts |
17 | | --- Monitor for errors after deployment and update these files if needed. |
| 9 | +-- TABLES BEING DROPPED: |
| 10 | +-- 1. request, response - Legacy request/response storage (replaced by ClickHouse) |
| 11 | +-- MAY CONTAIN OLD DATA on production, but it's no longer being read or written |
| 12 | +-- 2. asset, cache_hits, feedback - Related legacy tables |
| 13 | +-- 3. prompt_input_record - Part of DEPRECATED PromptManager system |
| 14 | +-- (marked DEPRECATED at valhalla/jawn/src/managers/prompt/PromptManager.ts:805-806) |
| 15 | +-- New system uses prompts_2025_inputs instead |
| 16 | +-- Legacy prompt UI (?legacy=true) will break but this is acceptable |
| 17 | +-- |
| 18 | +-- SAFETY: |
| 19 | +-- - Tables contain only legacy/deprecated data that is no longer accessed |
| 20 | +-- - All FK constraints are explicitly dropped first (no CASCADE operations) |
| 21 | +-- - Code has been updated to use ClickHouse or new prompt system |
| 22 | +-- - No active reads or writes to these tables |
| 23 | +-- |
| 24 | +-- ROLLBACK PLAN: |
| 25 | +-- If issues are found after deployment: |
| 26 | +-- 1. Restore tables from backup |
| 27 | +-- 2. Revert code changes in VersionedRequestStore.ts, RequestManager.ts, ScoreStore.ts |
| 28 | +-- 3. Re-run old migration to recreate tables and constraints |
| 29 | +-- |
| 30 | +-- CODE CHANGES MADE: |
| 31 | +-- - valhalla/jawn/src/lib/stores/request/VersionedRequestStore.ts |
| 32 | +-- (fixed addPropertyToRequest to use ClickHouse) |
| 33 | +-- - valhalla/jawn/src/managers/request/RequestManager.ts |
| 34 | +-- (updated waitForRequestAndResponse to use ClickHouse) |
| 35 | +-- - valhalla/jawn/src/lib/stores/ScoreStore.ts |
| 36 | +-- (fixed array mapping bug, deprecated bumpRequestVersion) |
| 37 | +-- |
| 38 | +-- KNOWN LIMITATIONS: |
| 39 | +-- - Legacy prompt UI (?legacy=true) will no longer work |
| 40 | +-- - Some experiment-related code may reference these tables but is likely unused |
18 | 41 |
|
19 | 42 | -- First, drop any legacy views that might reference these tables |
20 | 43 | DROP VIEW IF EXISTS response_and_request; |
|
0 commit comments