diff --git a/backend/src/app.ts b/backend/src/app.ts index fd92b80..1d4e086 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -117,7 +117,7 @@ const pool = databaseUrl password: postgresPassword, }); -const defaultCalibers = ['9mm', '.22 LR', '5.56 NATO', '.308 Win', '12 Gauge - Birdshot', '12 Gauge - Buckshot', '12 Gauge - Slug', '12 Gauge Sporting', '.45 ACP']; +const defaultCalibers = ['9mm', '.22 LR', '5.56 NATO', '.308 Win', '12 Gauge - Birdshot', '12 Gauge - Buckshot', '12 Gauge - Slug', '12 Gauge - Sporting', '.45 ACP']; const firearmCategories = ['Handgun', 'Rifle', 'Shotgun', 'PCC', 'Other']; const sessionHours = 24 * 7; @@ -386,7 +386,7 @@ const ensureSchema = async () => { const ensureProfileDefaults = async (profileId: string) => { await pool.query( `UPDATE calibers - SET name = '12 Gauge Sporting', + SET name = '12 Gauge - Sporting', is_default = TRUE WHERE profile_id = $1 AND name = '12 Gauge' @@ -394,7 +394,22 @@ const ensureProfileDefaults = async (profileId: string) => { SELECT 1 FROM calibers existing WHERE existing.profile_id = $1 - AND existing.name = '12 Gauge Sporting' + AND existing.name = '12 Gauge - Sporting' + )`, + [profileId], + ); + + await pool.query( + `UPDATE calibers + SET name = '12 Gauge - Sporting', + is_default = TRUE + WHERE profile_id = $1 + AND name = '12 Gauge Sporting' + AND NOT EXISTS ( + SELECT 1 + FROM calibers existing + WHERE existing.profile_id = $1 + AND existing.name = '12 Gauge - Sporting' )`, [profileId], ); diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index ad648da..f534e65 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -117,8 +117,8 @@ const ammoPageSelectionKey = 'arsenal-iq-ammo-page-calibers'; const ammoPageSelectionMigrationKey = 'arsenal-iq-ammo-page-calibers-v2'; const firearmCategories = ['Handgun', 'Rifle', 'Shotgun', 'PCC', 'Other']; const allFirearmCategoriesLabel = 'All categories'; -const defaultCaliberNames = ['9mm', '.22 LR', '5.56 NATO', '.308 Win', '12 Gauge - Birdshot', '12 Gauge - Buckshot', '12 Gauge - Slug', '12 Gauge Sporting', '.45 ACP']; -const boxTrackedCalibers = ['12 Gauge Sporting']; +const defaultCaliberNames = ['9mm', '.22 LR', '5.56 NATO', '.308 Win', '12 Gauge - Birdshot', '12 Gauge - Buckshot', '12 Gauge - Slug', '12 Gauge - Sporting', '.45 ACP']; +const boxTrackedCalibers = ['12 Gauge - Sporting']; const currency = new Intl.NumberFormat('en-US', { style: 'currency',