feat(photos): add square medium variant for sharp grid thumbnails
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
-- SQLite cannot alter a CHECK constraint, so recreate photo_objects with the
|
||||
-- extended role set (medium added) and copy the existing bindings across.
|
||||
CREATE TABLE photo_objects_new (
|
||||
photo_id TEXT NOT NULL REFERENCES photos(id) ON DELETE CASCADE,
|
||||
object_id TEXT NOT NULL REFERENCES objects(id) ON DELETE RESTRICT,
|
||||
role TEXT NOT NULL CHECK (role IN ('original', 'thumb', 'medium', 'preview')),
|
||||
PRIMARY KEY (photo_id, role)
|
||||
);
|
||||
|
||||
INSERT INTO photo_objects_new (photo_id, object_id, role)
|
||||
SELECT photo_id, object_id, role FROM photo_objects;
|
||||
|
||||
DROP TABLE photo_objects;
|
||||
|
||||
ALTER TABLE photo_objects_new RENAME TO photo_objects;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS photo_objects_object_idx ON photo_objects (object_id);
|
||||
|
||||
-- Regenerate variants for existing photos so they gain the medium variant and a
|
||||
-- square thumb.
|
||||
INSERT INTO variant_jobs (photo_id)
|
||||
SELECT id FROM photos
|
||||
WHERE 1
|
||||
ON CONFLICT (photo_id) DO NOTHING;
|
||||
Reference in New Issue
Block a user