Update ISO field to integer

This commit is contained in:
Sam Becker 2026-03-06 09:13:03 -06:00
parent 691a39c85c
commit bc4fe9b7a2
2 changed files with 11 additions and 3 deletions

View File

@ -103,13 +103,19 @@ export const MIGRATIONS: Migration[] = [{
`), `),
}, { }, {
label: '09: Image Dimensions', label: '09: Image Dimensions',
table: 'photos',
fields: ['width', 'height'], fields: ['width', 'height'],
run: () => sql` run: () => sql`
ALTER TABLE photos ALTER TABLE photos
ADD COLUMN IF NOT EXISTS width INTEGER, ADD COLUMN IF NOT EXISTS width INTEGER,
ADD COLUMN IF NOT EXISTS height 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) => export const migrationForError = (e: any) =>
@ -117,6 +123,8 @@ export const migrationForError = (e: any) =>
fields.some(field =>( fields.some(field =>(
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
new RegExp(`column "${field}" of relation "${table}" does not exist`, 'i').test(e.message) || 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)
)), )),
); );

View File

@ -59,7 +59,7 @@ export const createPhotosTable = () =>
lens_make VARCHAR(255), lens_make VARCHAR(255),
lens_model VARCHAR(255), lens_model VARCHAR(255),
f_number REAL, f_number REAL,
iso SMALLINT, iso INTEGER,
exposure_time DOUBLE PRECISION, exposure_time DOUBLE PRECISION,
exposure_compensation REAL, exposure_compensation REAL,
location_name VARCHAR(255), location_name VARCHAR(255),