fix: distinct warning for destructive table recreate (#23)#153
Open
alvarogar4 wants to merge 1 commit into
Open
fix: distinct warning for destructive table recreate (#23)#153alvarogar4 wants to merge 1 commit into
alvarogar4 wants to merge 1 commit into
Conversation
Changing engine/orderBy/primaryKey/partitionBy/uniqueKey on an existing table generates a DROP TABLE + CREATE TABLE that destroys all rows, but the drop surfaced the same generic `drop_table_data_loss` warning as a deliberate drop, so a user approving a "change sort key" edit lost all data with only a generic message. Detect a recreate (a drop_table whose key is also created in the same migration) and surface a distinct `table_recreate_data_loss` warning that states all rows are deleted and the table recreated empty, and recommends migrating via a temporary table. Documented in the migrate and schema DSL reference pages. Verified with unit tests (mutation-checked) and a live e2e against the ObsessionDB test cluster: a structural change is blocked with the recreate warning and no data dropped. Refs NUM-7318. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vs5ZySdFPLkAz33L1TEEZk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
engine/orderBy/primaryKey/partitionBy/uniqueKeyon an existing table generates aDROP TABLE+CREATE TABLEthat destroys all rows, but the drop surfaced the same genericdrop_table_data_losswarning as a deliberate drop — so a user approving a "change sort key" edit lost all data with only a generic message (audit finding Fix workspace:* deps in published packages #23).drop_tablewhose key is also created in the same migration) and surface a distinct, loudertable_recreate_data_losswarning that states all rows are deleted and the table recreated empty, and recommends migrating via a temporary table. Documented incli/migrate.mdandschema/dsl-reference.md.Test plan
safety-markers.test.ts): recreate →table_recreate_data_loss; plain drop and drop-while-creating-a-different-table →drop_table_data_loss. Mutation-checked.recreate-warning.e2e.test.ts): a structural change is blocked (exit 3) with the recreate warning and no data dropped.typecheck+lintpass; docs site builds (30 pages).Part of NUM-7318 (Tier-3 safety/resilience polish). 4 of 4: #23. Note: the optional auto "safe recreate" path (rename → INSERT…SELECT → drop) is intentionally deferred; this PR documents the manual safe path and makes the data loss loud.
🤖 Generated with Claude Code