From bc4fe9b7a2506e60592fc34770ca66f4e536af1b Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 6 Mar 2026 09:13:03 -0600 Subject: [PATCH] Update ISO field to integer --- src/db/migration.ts | 12 ++++++++++-- src/photo/query.ts | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/db/migration.ts b/src/db/migration.ts index c040d5b9..01c4e2d6 100644 --- a/src/db/migration.ts +++ b/src/db/migration.ts @@ -103,13 +103,19 @@ export const MIGRATIONS: Migration[] = [{ `), }, { label: '09: Image Dimensions', - table: 'photos', fields: ['width', 'height'], run: () => sql` ALTER TABLE photos ADD COLUMN IF NOT EXISTS width INTEGER, ADD COLUMN IF NOT EXISTS height INTEGER `, +}, { + label: '10: ISO', + fields: ['iso'], + run: () => query(` + ALTER TABLE photos + ALTER COLUMN iso TYPE INTEGER + `), }]; export const migrationForError = (e: any) => @@ -117,6 +123,8 @@ export const migrationForError = (e: any) => fields.some(field =>( // eslint-disable-next-line max-len new RegExp(`column "${field}" of relation "${table}" does not exist`, 'i').test(e.message) || - new RegExp(`column "${field}" does not exist`, 'i').test(e.message) + new RegExp(`column "${field}" does not exist`, 'i').test(e.message) || + // eslint-disable-next-line max-len + field === 'iso' && new RegExp('out of range for type smallint', 'i').test(e.message) )), ); diff --git a/src/photo/query.ts b/src/photo/query.ts index 68bb37b5..e9daa48a 100644 --- a/src/photo/query.ts +++ b/src/photo/query.ts @@ -59,7 +59,7 @@ export const createPhotosTable = () => lens_make VARCHAR(255), lens_model VARCHAR(255), f_number REAL, - iso SMALLINT, + iso INTEGER, exposure_time DOUBLE PRECISION, exposure_compensation REAL, location_name VARCHAR(255),