fix(events): stop mapping branding_logo_position onto hero_logo_position
Two settings with overlapping names but different value sets were being
conflated:
- branding_logo_position (header bar, horizontal): 'left'|'center'|'right'
- hero_logo_position (hero block, vertical): 'top'|'center'|'bottom'
getBrandingDefaults() copied the global branding value over the per-event
hero value when seeding new events. Any admin with branding logo set to
'left' (the most common choice) created events with hero_logo_position
= 'left' written to the DB. Subsequent PUTs to /admin/events/:id then
failed validation with "Invalid value (field: hero_logo_position)" — the
validator only accepts top/center/bottom.
Fix:
1. Drop the bogus mapping. branding_logo_position is no longer read by
getBrandingDefaults — it doesn't belong there. The fallback default
('top') is used unless the request body explicitly provides
hero_logo_position, which is independently validated.
2. Migration 084_fix_hero_logo_position normalises any existing rows
whose hero_logo_position is outside ('top','center','bottom') back
to 'top'. Without this, affected events would continue to 400 on
every save until the admin manually picks a valid option.
Reproduction: admin sets branding logo position to 'left' under global
branding, creates an event, opens the event detail page, clicks Save
without changing anything → 400. After this fix, save succeeds and new
events default to 'top' regardless of branding-bar position.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Heal events whose hero_logo_position contains a branding-style value
|
||||
* (left/right) caused by a prior bug in adminEvents.js getBrandingDefaults
|
||||
* that mapped branding_logo_position (left/center/right) onto
|
||||
* hero_logo_position (top/center/bottom). Any non-canonical value is
|
||||
* reset to 'top' so subsequent PUTs no longer fail validation.
|
||||
*/
|
||||
|
||||
exports.up = async function up(knex) {
|
||||
const hasColumn = await knex.schema.hasColumn('events', 'hero_logo_position');
|
||||
if (!hasColumn) return;
|
||||
|
||||
await knex('events')
|
||||
.whereNotIn('hero_logo_position', ['top', 'center', 'bottom'])
|
||||
.update({ hero_logo_position: 'top' });
|
||||
};
|
||||
|
||||
exports.down = async function down() {
|
||||
// Data correction is not reversible — the original (incorrect) values
|
||||
// are not preserved.
|
||||
};
|
||||
Reference in New Issue
Block a user