feat(intake): record the background-removal intent and the original path (#281)
Adds the two columns the background-removal feature (#281) is built on: item_drafts.remove_background (boolean, not null, default true) records the submitter's per-submission intent, and item_images.original_image_path (nullable text, no default) records where a cut-out photo came from so it can be restored. The default on remove_background is load-bearing — any row written by a path that does not mention the column behaves like the new default, so no backfill is needed. original_image_path stays null until a photo has actually been cut out, which doubles as the answer to "can this be restored?" rather than needing a separate flag. Also updates the Drizzle mirror in src/db-drizzle/schema.ts by hand (the local dev database was not running to re-pull from) and adds the integration test backgroundRemoval.integration.test.ts, including the exported seedSubmission helper that Task 3 will reuse. Closes #281 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
exports.up = (pgm) => {
|
||||
pgm.sql(`
|
||||
-- The submitter's intent, per submission, because that is how it is
|
||||
-- expressed: one checkbox above the send button, ticked by default.
|
||||
--
|
||||
-- The worker acts on it rather than the intake route. Removing inline
|
||||
-- would make the sender wait, would put a CPU-heavy model run in a path
|
||||
-- anyone holding a link can trigger — the surface #227 exists to bound —
|
||||
-- and would force a choice, when the sidecar is unreachable, between
|
||||
-- failing their submission and silently ignoring what they asked for.
|
||||
--
|
||||
-- NOT NULL DEFAULT true so a row written before this migration, or by any
|
||||
-- path that does not mention the column, behaves like the new default.
|
||||
ALTER TABLE item_drafts
|
||||
ADD COLUMN IF NOT EXISTS remove_background BOOLEAN NOT NULL DEFAULT true;
|
||||
|
||||
-- Where the photo came from, per image, because that is how it is undone.
|
||||
-- Null until a photo has been cut out, so it is also the answer to "can
|
||||
-- this be restored?" — one fact in one place rather than a flag that can
|
||||
-- disagree with a path.
|
||||
--
|
||||
-- Nullable and with no default: an existing image has no original other
|
||||
-- than itself, and claiming otherwise would offer a Restore that swapped a
|
||||
-- photo for a copy of itself.
|
||||
ALTER TABLE item_images
|
||||
ADD COLUMN IF NOT EXISTS original_image_path TEXT;
|
||||
`);
|
||||
};
|
||||
|
||||
exports.down = (pgm) => {
|
||||
pgm.sql(`
|
||||
ALTER TABLE item_drafts DROP COLUMN IF EXISTS remove_background;
|
||||
ALTER TABLE item_images DROP COLUMN IF EXISTS original_image_path;
|
||||
`);
|
||||
};
|
||||
Reference in New Issue
Block a user