From 7df4227f20eb8d39dbf4c6df25061c0262343fa4 Mon Sep 17 00:00:00 2001 From: Spencer Peace <47868304+Spencer6497@users.noreply.github.com> Date: Fri, 27 Dec 2024 14:17:56 +0100 Subject: [PATCH] BoxWithImage schema changes (#363) --- ...7T00.00.00.box-with-image-size-variants.js | 20 +++++++++++++++++++ src/components/page/box-with-image.json | 7 ++++++- types/generated/components.d.ts | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2024.12.27T00.00.00.box-with-image-size-variants.js diff --git a/database/migrations/2024.12.27T00.00.00.box-with-image-size-variants.js b/database/migrations/2024.12.27T00.00.00.box-with-image-size-variants.js new file mode 100644 index 0000000..18442a7 --- /dev/null +++ b/database/migrations/2024.12.27T00.00.00.box-with-image-size-variants.js @@ -0,0 +1,20 @@ +"use strict"; + +/** + * what this migration is doing: + Switches existing "ImgMTextL" variant BoxWithImage instances to their new equivalents + */ + +async function up(knex) { + try { + const result = await knex("components_page_box_with_images").whereNotNull('variant').update({ + variant: 'M' + }); + console.log(`Updated ${result.length} row(s)`); + } catch (error) { + console.log("error occured during migration. Skipping migration"); + console.log(error); + } +} + +module.exports = { up }; diff --git a/src/components/page/box-with-image.json b/src/components/page/box-with-image.json index ed8a859..2d9a612 100644 --- a/src/components/page/box-with-image.json +++ b/src/components/page/box-with-image.json @@ -42,7 +42,12 @@ "variant": { "type": "enumeration", "enum": [ - "ImgMTextL" + "XS", + "S", + "M", + "L", + "XL", + "XXL" ] } } diff --git a/types/generated/components.d.ts b/types/generated/components.d.ts index acda7e8..d57b7c4 100644 --- a/types/generated/components.d.ts +++ b/types/generated/components.d.ts @@ -476,7 +476,7 @@ export interface PageBoxWithImage extends Struct.ComponentSchema { image: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'> & Schema.Attribute.Required; outerBackground: Schema.Attribute.Component<'meta.background', false>; - variant: Schema.Attribute.Enumeration<['ImgMTextL']>; + variant: Schema.Attribute.Enumeration<['XS', 'S', 'M', 'L', 'XL', 'XXL']>; }; }