-
Notifications
You must be signed in to change notification settings - Fork 3.8k
improvement(db): contract workspace file sizes #7128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||||
| ALTER TABLE "workspace_files" | ||||||||||||||||
| ADD CONSTRAINT "workspace_files_size_bytes_not_null_check" | ||||||||||||||||
| CHECK ("size_bytes" IS NOT NULL) NOT VALID;--> statement-breakpoint | ||||||||||||||||
| ALTER TABLE "workspace_files" | ||||||||||||||||
| VALIDATE CONSTRAINT "workspace_files_size_bytes_not_null_check";--> statement-breakpoint | ||||||||||||||||
| -- migration-safe: contract of #7112 and #7123 — application reads and writes use size_bytes, the backfill is complete, and this PR must merge only after the compatibility release fully drains | ||||||||||||||||
|
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: When an existing database has rows from before (Based on your team's feedback about deployable schema/data migrations.) Prompt for AI agents
Suggested change
|
||||||||||||||||
| ALTER TABLE "workspace_files" ALTER COLUMN "size_bytes" SET NOT NULL;--> statement-breakpoint | ||||||||||||||||
| -- migration-safe: removes the temporary proof constraint created and validated above after PostgreSQL records the equivalent column-level NOT NULL invariant | ||||||||||||||||
| ALTER TABLE "workspace_files" | ||||||||||||||||
| DROP CONSTRAINT "workspace_files_size_bytes_not_null_check";--> statement-breakpoint | ||||||||||||||||
| DROP TRIGGER IF EXISTS "workspace_files_sync_size_columns" ON "workspace_files";--> statement-breakpoint | ||||||||||||||||
| DROP FUNCTION IF EXISTS "sync_workspace_file_size_columns"();--> statement-breakpoint | ||||||||||||||||
| -- migration-safe: contract of #7112 and #7123 — no deployed application reader or writer depends on size, and this PR must merge only after the compatibility release fully drains | ||||||||||||||||
| ALTER TABLE "workspace_files" DROP COLUMN "size"; | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: When a selected
workspace_filesrow still hassize_bytes = NULL, PostgreSQL ignores it insum, and thiscoalesceturns an all-NULL selection into zero, allowing quota admission to undercount copied bytes. Preserve the NULL-detection aggregate and make the 503 path handle a null total.(Based on your team's feedback about failing closed on missing
size_bytes.) [3f8e6e9d-39ca-4a4a-b8b4-0e6be9b461e0].Prompt for AI agents