-- Content hash of the stored original, for per-gallery duplicate detection on
-- upload. NULL means "not hashed yet" — rows predating this migration, until
-- `photo-api backfill-checksums` runs. NULLs are distinct under a unique
-- index, so those rows never collide with each other.
-- (No semicolons in these comments: the migration runner splits on them.)
ALTER TABLE photos_photos ADD COLUMN IF NOT EXISTS checksum varchar(64);

CREATE UNIQUE INDEX IF NOT EXISTS photos_photos_gallery_checksum_idx ON photos_photos (gallery_id, checksum);
