Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions drizzle/0003_drop_chat_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP TABLE IF EXISTS "chat_messages" CASCADE;--> statement-breakpoint
DROP TABLE IF EXISTS "chat_threads" CASCADE;
Comment on lines +1 to +2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Irreversible data loss — confirm backup/retention policy before applying.

This migration permanently drops chat_messages and chat_threads (with CASCADE, also any dependent objects such as views/FKs). There is no rollback path once applied to production; all historical chat data will be unrecoverable from the application database.

A few things to confirm before this lands:

  • A recent verified backup (or logical export of the two tables) exists, in case product/legal needs the data later (e.g., user data export, GDPR/CCPA inquiries already in flight).
  • No remaining cross-references in the live DB (FKs, materialized views, triggers, replication subscriptions, search indexes, analytics pipelines) point at these tables — CASCADE will silently drop dependents.
  • Any background workers or external services (analytics, search indexers, embeddings store) that read these tables are stopped or updated first to avoid runtime errors during/after the migration.

If you'd like, the migration can be made a touch safer by archiving rows to a JSON column / side table first, or by guarding behind a feature flag with a follow-up cleanup migration. Otherwise, the SQL itself is correct.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@drizzle/0003_drop_chat_tables.sql` around lines 1 - 2, This migration drops
chat_messages and chat_threads with CASCADE which causes irreversible data loss;
before applying, add a safety step: export or back up the two tables (e.g.,
logical dump of chat_messages and chat_threads) and/or implement an archival
step that copies rows into an archive table or JSON column, remove or avoid
CASCADE if you need to preserve dependent objects, and ensure any consumers
(workers, analytics, search indexers) referencing chat_messages/chat_threads are
stopped or updated; update the migration to include the backup/archive operation
and an explicit confirmation gate (or feature-flagged cleanup) referencing
chat_messages and chat_threads so the destructive DROP TABLE IF EXISTS ...
CASCADE is only run once backups and consumer changes are verified.

Loading
Loading