feat(cms): MongoDB → PostgreSQL content transfer; fix two schema issues it found (MITHOME-136)
- scripts/transfer-content.ts: export (shared config + MongoDB adapter, locale 'all', drafts, upload files) and import (PostgreSQL, one transaction, refuses a non-empty target); pure helpers in src/lib/content-transfer.ts - LegalPages: the section anchor is its own field; as the array row id it was a table-wide primary key in PostgreSQL and the two pages collided - Products.status: own enumName; the default name equalled the drafts _status enum, so only draft/published were accepted - baseline migration regenerated Verified on a staging copy (disposable MongoDB + PostgreSQL on llmdev): counts match, all 14 public pages (hu/en) render identical text, partner logo loads, second import writes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e3ec6a9ac3
commit
a68fb94b61
@@ -17,9 +17,8 @@ import { legalValidationGroup } from './fields/legalValidation'
|
||||
* nem vezetünk be külön szerializációt egy még nem létező render-rétegért.
|
||||
*
|
||||
* MITHOME-112 lokalizáció: a cím, a dátumszöveg és a szakaszok címe/tartalma
|
||||
* lokalizált; a `slug` (URL-azonosító) és a szakasz-`id` közös, a `sections`
|
||||
* tömb maga is közös (sorrend nyelvenként azonos). A meglévő adatot a
|
||||
* src/migrations/20260929_localize_legal_pages.ts alakítja át.
|
||||
* lokalizált; a `slug` (URL-azonosító) és a szakasz-`anchor` közös, a `sections`
|
||||
* tömb maga is közös (sorrend nyelvenként azonos).
|
||||
*/
|
||||
export const LegalPages: CollectionConfig = {
|
||||
slug: 'legal-pages',
|
||||
@@ -53,7 +52,10 @@ export const LegalPages: CollectionConfig = {
|
||||
type: 'array',
|
||||
required: true,
|
||||
fields: [
|
||||
{ name: 'id', type: 'text', required: true },
|
||||
// MITHOME-136: the section anchor is its own field. It used to be the
|
||||
// array row `id`, which PostgreSQL stores as a table-wide primary key,
|
||||
// so two pages with the same anchor ("bevezetes") collided.
|
||||
{ name: 'anchor', type: 'text', required: true, admin: { description: 'A szakasz horgonya (pl. bevezetes), minden nyelven azonos.' } },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'content', type: 'textarea', required: true, localized: true },
|
||||
],
|
||||
|
||||
@@ -62,6 +62,10 @@ export const Products: CollectionConfig = {
|
||||
name: 'status',
|
||||
label: 'Életciklus-állapot',
|
||||
type: 'select',
|
||||
// MITHOME-136: own PostgreSQL enum name. The default "enum_products_status"
|
||||
// is also Payload's name for the drafts `_status` enum, so the two
|
||||
// collided and only draft/published were accepted.
|
||||
enumName: 'enum_products_lifecycle_status',
|
||||
required: true,
|
||||
defaultValue: 'draft',
|
||||
options: PRODUCT_STATUSES.map((value) => ({ label: PRODUCT_STATUS_LABELS[value], value })),
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import type { Field } from 'payload'
|
||||
import { bundleCounts, localeData, upgradeDoc } from './content-transfer'
|
||||
|
||||
const FIELDS: Field[] = [
|
||||
{ name: 'name', type: 'text' },
|
||||
{ name: 'title', type: 'text', localized: true },
|
||||
{
|
||||
name: 'hero',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', localized: true },
|
||||
{ name: 'icon', type: 'text' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'items',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{ name: 'label', type: 'text', localized: true },
|
||||
{ name: 'order', type: 'number' },
|
||||
],
|
||||
},
|
||||
{ name: 'paragraphs', type: 'array', localized: true, fields: [{ name: 'value', type: 'text' }] },
|
||||
{ type: 'row', fields: [{ name: 'result', type: 'text' }] },
|
||||
{ name: 'logo', type: 'upload', relationTo: 'media' },
|
||||
]
|
||||
|
||||
const DOC = {
|
||||
id: 'old-doc',
|
||||
_id: 'old-doc',
|
||||
__v: 0,
|
||||
_status: 'published',
|
||||
updatedAt: '2026-09-29T10:00:00.000Z',
|
||||
createdAt: '2026-09-01T08:00:00.000Z',
|
||||
name: 'mIT Start',
|
||||
title: { hu: 'Cím', en: 'Title' },
|
||||
hero: { title: { hu: 'Hős', en: 'Hero' }, icon: '🔥' },
|
||||
items: [{ id: 'row1', label: { hu: 'Egy', en: 'One' }, order: 1 }],
|
||||
paragraphs: { hu: [{ id: 'p1', value: 'Első' }, { id: 'p2', value: 'Második' }], en: [{ id: 'p3', value: 'First' }] },
|
||||
result: 'ok',
|
||||
logo: { id: 'old-media', filename: 'logo.png' },
|
||||
}
|
||||
|
||||
describe('content transfer (MITHOME-136)', () => {
|
||||
it('should split a locale-all document into Hungarian data', () => {
|
||||
expect(localeData(FIELDS, DOC, 'hu')).toEqual({
|
||||
name: 'mIT Start',
|
||||
title: 'Cím',
|
||||
hero: { title: 'Hős', icon: '🔥' },
|
||||
items: [{ id: 'row1', label: 'Egy', order: 1 }],
|
||||
paragraphs: [{ id: 'p1', value: 'Első' }, { id: 'p2', value: 'Második' }],
|
||||
result: 'ok',
|
||||
logo: 'old-media',
|
||||
createdAt: '2026-09-01T08:00:00.000Z',
|
||||
})
|
||||
})
|
||||
|
||||
it('should keep array row ids so the English update hits the same rows', () => {
|
||||
const en = localeData(FIELDS, DOC, 'en')
|
||||
expect(en.items).toEqual([{ id: 'row1', label: 'One', order: 1 }])
|
||||
expect(en.paragraphs).toEqual([{ id: 'p3', value: 'First' }])
|
||||
expect(en.title).toBe('Title')
|
||||
})
|
||||
|
||||
it('should map upload ids to the new documents', () => {
|
||||
const ids = new Map([['old-media', 'new-media']])
|
||||
expect(localeData(FIELDS, DOC, 'hu', ids).logo).toBe('new-media')
|
||||
})
|
||||
|
||||
it('should drop system fields and leave missing fields out', () => {
|
||||
const data = localeData(FIELDS, { name: 'x', _status: 'draft', globalType: 'home' }, 'hu')
|
||||
expect(data).toEqual({ name: 'x' })
|
||||
})
|
||||
|
||||
it('should count the documents of a bundle', () => {
|
||||
expect(
|
||||
bundleCounts({
|
||||
exportedAt: '',
|
||||
source: '',
|
||||
globals: { home: { published: {} } },
|
||||
collections: { partners: [{ published: {} }, { published: {} }] },
|
||||
files: {},
|
||||
}),
|
||||
).toEqual({ partners: 2, 'global:home': 1 })
|
||||
})
|
||||
|
||||
it('should move the legal section anchor out of the row id, unique per page', () => {
|
||||
const doc = { slug: 'adatvedelem', sections: [{ id: 'bevezetes', title: { hu: 'Bevezetés' } }] }
|
||||
expect(upgradeDoc('legal-pages', doc).sections).toEqual([
|
||||
{ id: 'adatvedelem-bevezetes', anchor: 'bevezetes', title: { hu: 'Bevezetés' } },
|
||||
])
|
||||
expect(upgradeDoc('legal-pages', upgradeDoc('legal-pages', doc))).toEqual(upgradeDoc('legal-pages', doc))
|
||||
expect(upgradeDoc('partners', doc)).toBe(doc)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* MITHOME-136: pure helpers of the one-off MongoDB → PostgreSQL content
|
||||
* transfer (scripts/transfer-content.ts).
|
||||
*
|
||||
* The export reads every document with `locale: 'all'`, so each localized
|
||||
* field arrives as `{ hu, en }`. Payload writes one locale at a time, so the
|
||||
* import splits a document into per-locale data using the field config:
|
||||
* localized fields take the locale's value, groups/unnamed rows recurse,
|
||||
* array rows keep their ids (the English update must hit the same rows), and
|
||||
* upload/relationship ids are mapped from the old to the new id.
|
||||
*/
|
||||
import type { Field } from 'payload'
|
||||
|
||||
export type Locale = 'hu' | 'en'
|
||||
type Data = Record<string, unknown>
|
||||
export type IdMap = Map<string, string>
|
||||
|
||||
const SYSTEM_KEYS = new Set(['id', '_id', '__v', 'globalType', 'updatedAt', '_status'])
|
||||
|
||||
const isObject = (value: unknown): value is Data =>
|
||||
typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
|
||||
function mapId(value: unknown, ids: IdMap): unknown {
|
||||
if (value === null || value === undefined) return value
|
||||
const id = isObject(value) ? value.id : value
|
||||
return typeof id === 'string' ? (ids.get(id) ?? id) : id
|
||||
}
|
||||
|
||||
function splitFields(fields: readonly Field[], source: Data, locale: Locale, ids: IdMap, out: Data): Data {
|
||||
for (const field of fields) {
|
||||
if (!('name' in field) || !field.name) {
|
||||
// row / collapsible: unnamed wrappers keep their fields on the same level
|
||||
if ('fields' in field) splitFields(field.fields, source, locale, ids, out)
|
||||
continue
|
||||
}
|
||||
if (!(field.name in source)) continue
|
||||
const raw = source[field.name]
|
||||
const value = 'localized' in field && field.localized && isObject(raw) ? raw[locale] : raw
|
||||
|
||||
if (field.type === 'group' && isObject(value)) {
|
||||
out[field.name] = splitFields(field.fields, value, locale, ids, {})
|
||||
} else if (field.type === 'array' && Array.isArray(value)) {
|
||||
out[field.name] = value.map((row) =>
|
||||
isObject(row) ? { ...(row.id ? { id: row.id } : {}), ...splitFields(field.fields, row, locale, ids, {}) } : row,
|
||||
)
|
||||
} else if (field.type === 'upload' || field.type === 'relationship') {
|
||||
out[field.name] = Array.isArray(value) ? value.map((v) => mapId(v, ids)) : mapId(value, ids)
|
||||
} else {
|
||||
out[field.name] = value
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* Shape changes between the MongoDB schema and the current one, applied to an
|
||||
* exported document before it is split by locale.
|
||||
* - legal-pages: the section anchor was the array row `id`; it is now the
|
||||
* `anchor` field, and the row id must be unique across all pages (it is a
|
||||
* table-wide primary key in PostgreSQL), so it becomes `<slug>-<anchor>`.
|
||||
*/
|
||||
export function upgradeDoc(collection: string, doc: Data): Data {
|
||||
if (collection !== 'legal-pages' || !Array.isArray(doc.sections)) return doc
|
||||
return {
|
||||
...doc,
|
||||
sections: doc.sections.map((section) =>
|
||||
isObject(section) && typeof section.id === 'string' && !('anchor' in section)
|
||||
? { ...section, id: `${doc.slug}-${section.id}`, anchor: section.id }
|
||||
: section,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/** The data of one locale, ready for `create`/`update` with that `locale`. */
|
||||
export function localeData(fields: readonly Field[], doc: Data, locale: Locale, ids: IdMap = new Map()): Data {
|
||||
const out = splitFields(fields, doc, locale, ids, {})
|
||||
for (const key of SYSTEM_KEYS) delete out[key]
|
||||
// Keep the original creation time (contact submission retention).
|
||||
if (typeof doc.createdAt === 'string') out.createdAt = doc.createdAt
|
||||
return out
|
||||
}
|
||||
|
||||
/** Count documents per collection/global in an export bundle. */
|
||||
export function bundleCounts(bundle: TransferBundle): Record<string, number> {
|
||||
const counts: Record<string, number> = {}
|
||||
for (const [slug, docs] of Object.entries(bundle.collections)) counts[slug] = docs.length
|
||||
for (const slug of Object.keys(bundle.globals)) counts[`global:${slug}`] = 1
|
||||
return counts
|
||||
}
|
||||
|
||||
export type BundleDoc = { published: Data; draft?: Data }
|
||||
|
||||
export type TransferBundle = {
|
||||
exportedAt: string
|
||||
source: string
|
||||
globals: Record<string, BundleDoc>
|
||||
collections: Record<string, BundleDoc[]>
|
||||
/** Upload files by filename, base64 — the bundle is self-contained. */
|
||||
files: Record<string, { mimeType: string; base64: string }>
|
||||
}
|
||||
@@ -4,14 +4,14 @@ const hu = {
|
||||
title: 'Adatvédelmi Tájékoztató',
|
||||
lastUpdated: '2026. augusztus 22.',
|
||||
sections: [
|
||||
{ id: 'bevezetes', title: '1. Bevezetés', content: 'A mozdIT Bt. mint adatkezelő…' },
|
||||
{ id: 'jogok', title: '5. Az érintettek jogai', content: 'Az érintettek bármikor…' },
|
||||
{ id: 'r1', anchor: 'bevezetes', title: '1. Bevezetés', content: 'A mozdIT Bt. mint adatkezelő…' },
|
||||
{ id: 'r2', anchor: 'jogok', title: '5. Az érintettek jogai', content: 'Az érintettek bármikor…' },
|
||||
],
|
||||
}
|
||||
const en = {
|
||||
title: 'Privacy Notice',
|
||||
lastUpdated: '22 August 2026',
|
||||
sections: [{ id: 'bevezetes', title: '1. Introduction', content: 'mozdIT Bt., as controller…' }],
|
||||
sections: [{ id: 'r1', anchor: 'bevezetes', title: '1. Introduction', content: 'mozdIT Bt., as controller…' }],
|
||||
}
|
||||
|
||||
describe('buildLegalValidationPrompt (MITHOME-113)', () => {
|
||||
@@ -34,7 +34,7 @@ describe('buildLegalValidationPrompt (MITHOME-113)', () => {
|
||||
})
|
||||
|
||||
it('should return undefined when there is no English text', () => {
|
||||
expect(buildLegalValidationPrompt(hu, { title: ' ', sections: [{ id: 'bevezetes', title: null, content: '' }] })).toBeUndefined()
|
||||
expect(buildLegalValidationPrompt(hu, { title: ' ', sections: [{ id: 'r1', anchor: 'bevezetes', title: null, content: '' }] })).toBeUndefined()
|
||||
expect(hasEnglishContent({})).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* document texts stay in their original languages.
|
||||
*/
|
||||
|
||||
export type LegalSection = { id?: string | null; title?: string | null; content?: string | null }
|
||||
export type LegalSection = { id?: string | null; anchor?: string | null; title?: string | null; content?: string | null }
|
||||
export type LegalText = { title?: string | null; lastUpdated?: string | null; sections?: LegalSection[] | null }
|
||||
|
||||
const MISSING = '(missing — report as high severity)'
|
||||
@@ -55,7 +55,7 @@ export function buildLegalValidationPrompt(hu: LegalText, en: LegalText): string
|
||||
const sections = (hu.sections ?? []).map((section, index) => {
|
||||
const english = enById.get(section.id) ?? {}
|
||||
return [
|
||||
`--- Section ${index + 1}${section.id ? ` (${section.id})` : ''} ---`,
|
||||
`--- Section ${index + 1}${section.anchor ? ` (${section.anchor})` : ''} ---`,
|
||||
block('HU', section.title, section.content),
|
||||
block('EN', english.title, english.content),
|
||||
].join('\n')
|
||||
|
||||
+37
-14
@@ -240,6 +240,12 @@
|
||||
"type": "varchar",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"anchor": {
|
||||
"name": "anchor",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
@@ -702,6 +708,12 @@
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"anchor": {
|
||||
"name": "anchor",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"_uuid": {
|
||||
"name": "_uuid",
|
||||
"type": "varchar",
|
||||
@@ -2139,7 +2151,7 @@
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "enum_products_status",
|
||||
"type": "enum_products_lifecycle_status",
|
||||
"typeSchema": "public",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
@@ -2571,7 +2583,7 @@
|
||||
},
|
||||
"version_status": {
|
||||
"name": "version_status",
|
||||
"type": "enum__products_v_version_status",
|
||||
"type": "enum_products_lifecycle_status",
|
||||
"typeSchema": "public",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
@@ -10696,12 +10708,15 @@
|
||||
"managed-service"
|
||||
]
|
||||
},
|
||||
"public.enum_products_status": {
|
||||
"name": "enum_products_status",
|
||||
"public.enum_products_lifecycle_status": {
|
||||
"name": "enum_products_lifecycle_status",
|
||||
"schema": "public",
|
||||
"values": [
|
||||
"draft",
|
||||
"published"
|
||||
"internal",
|
||||
"publishable",
|
||||
"active",
|
||||
"retired"
|
||||
]
|
||||
},
|
||||
"public.enum_products_pricing_billing_period": {
|
||||
@@ -10722,6 +10737,14 @@
|
||||
"approved"
|
||||
]
|
||||
},
|
||||
"public.enum_products_status": {
|
||||
"name": "enum_products_status",
|
||||
"schema": "public",
|
||||
"values": [
|
||||
"draft",
|
||||
"published"
|
||||
]
|
||||
},
|
||||
"public.enum__products_v_version_product_type": {
|
||||
"name": "enum__products_v_version_product_type",
|
||||
"schema": "public",
|
||||
@@ -10730,14 +10753,6 @@
|
||||
"managed-service"
|
||||
]
|
||||
},
|
||||
"public.enum__products_v_version_status": {
|
||||
"name": "enum__products_v_version_status",
|
||||
"schema": "public",
|
||||
"values": [
|
||||
"draft",
|
||||
"published"
|
||||
]
|
||||
},
|
||||
"public.enum__products_v_version_pricing_billing_period": {
|
||||
"name": "enum__products_v_version_pricing_billing_period",
|
||||
"schema": "public",
|
||||
@@ -10756,6 +10771,14 @@
|
||||
"approved"
|
||||
]
|
||||
},
|
||||
"public.enum__products_v_version_status": {
|
||||
"name": "enum__products_v_version_status",
|
||||
"schema": "public",
|
||||
"values": [
|
||||
"draft",
|
||||
"published"
|
||||
]
|
||||
},
|
||||
"public.enum__products_v_published_locale": {
|
||||
"name": "enum__products_v_published_locale",
|
||||
"schema": "public",
|
||||
@@ -11111,6 +11134,6 @@
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
},
|
||||
"id": "2ad18472-919a-4a92-9c5b-ca65521af234",
|
||||
"id": "4793a461-cb83-4303-aa78-0a07b81a2cdb",
|
||||
"prevId": "00000000-0000-0000-0000-000000000000"
|
||||
}
|
||||
+11
-7
@@ -19,13 +19,14 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
CREATE TYPE "public"."enum__partners_v_published_locale" AS ENUM('hu', 'en');
|
||||
CREATE TYPE "public"."enum_contact_submissions_status" AS ENUM('new', 'read', 'replied', 'archived');
|
||||
CREATE TYPE "public"."enum_products_product_type" AS ENUM('hosting', 'managed-service');
|
||||
CREATE TYPE "public"."enum_products_status" AS ENUM('draft', 'published');
|
||||
CREATE TYPE "public"."enum_products_lifecycle_status" AS ENUM('draft', 'internal', 'publishable', 'active', 'retired');
|
||||
CREATE TYPE "public"."enum_products_pricing_billing_period" AS ENUM('yearly', 'monthly', 'one-time');
|
||||
CREATE TYPE "public"."enum_products_en_translation_status" AS ENUM('none', 'ai-draft', 'approved');
|
||||
CREATE TYPE "public"."enum_products_status" AS ENUM('draft', 'published');
|
||||
CREATE TYPE "public"."enum__products_v_version_product_type" AS ENUM('hosting', 'managed-service');
|
||||
CREATE TYPE "public"."enum__products_v_version_status" AS ENUM('draft', 'published');
|
||||
CREATE TYPE "public"."enum__products_v_version_pricing_billing_period" AS ENUM('yearly', 'monthly', 'one-time');
|
||||
CREATE TYPE "public"."enum__products_v_version_en_translation_status" AS ENUM('none', 'ai-draft', 'approved');
|
||||
CREATE TYPE "public"."enum__products_v_version_status" AS ENUM('draft', 'published');
|
||||
CREATE TYPE "public"."enum__products_v_published_locale" AS ENUM('hu', 'en');
|
||||
CREATE TYPE "public"."enum_home_hero_cta_primary_link_type" AS ENUM('page', 'url');
|
||||
CREATE TYPE "public"."enum_home_hero_cta_primary_page" AS ENUM('home', 'about', 'services', 'hostingPlans', 'contact', 'privacy', 'terms');
|
||||
@@ -90,7 +91,8 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
CREATE TABLE "legal_pages_sections" (
|
||||
"_order" integer NOT NULL,
|
||||
"_parent_id" uuid NOT NULL,
|
||||
"id" varchar PRIMARY KEY NOT NULL
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"anchor" varchar
|
||||
);
|
||||
|
||||
CREATE TABLE "legal_pages_sections_locales" (
|
||||
@@ -133,6 +135,7 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
"_order" integer NOT NULL,
|
||||
"_parent_id" uuid NOT NULL,
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"anchor" varchar,
|
||||
"_uuid" varchar
|
||||
);
|
||||
|
||||
@@ -254,7 +257,7 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
"name" varchar,
|
||||
"slug" varchar,
|
||||
"product_type" "enum_products_product_type" DEFAULT 'hosting',
|
||||
"status" "enum_products_status" DEFAULT 'draft',
|
||||
"status" "enum_products_lifecycle_status" DEFAULT 'draft',
|
||||
"sort_order" numeric DEFAULT 0,
|
||||
"highlighted" boolean DEFAULT false,
|
||||
"pricing_net_amount" numeric,
|
||||
@@ -299,7 +302,7 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
"version_name" varchar,
|
||||
"version_slug" varchar,
|
||||
"version_product_type" "enum__products_v_version_product_type" DEFAULT 'hosting',
|
||||
"version_status" "enum__products_v_version_status" DEFAULT 'draft',
|
||||
"version_status" "enum_products_lifecycle_status" DEFAULT 'draft',
|
||||
"version_sort_order" numeric DEFAULT 0,
|
||||
"version_highlighted" boolean DEFAULT false,
|
||||
"version_pricing_net_amount" numeric,
|
||||
@@ -1499,13 +1502,14 @@ export async function down({ db, payload, req }: MigrateDownArgs): Promise<void>
|
||||
DROP TYPE "public"."enum__partners_v_published_locale";
|
||||
DROP TYPE "public"."enum_contact_submissions_status";
|
||||
DROP TYPE "public"."enum_products_product_type";
|
||||
DROP TYPE "public"."enum_products_status";
|
||||
DROP TYPE "public"."enum_products_lifecycle_status";
|
||||
DROP TYPE "public"."enum_products_pricing_billing_period";
|
||||
DROP TYPE "public"."enum_products_en_translation_status";
|
||||
DROP TYPE "public"."enum_products_status";
|
||||
DROP TYPE "public"."enum__products_v_version_product_type";
|
||||
DROP TYPE "public"."enum__products_v_version_status";
|
||||
DROP TYPE "public"."enum__products_v_version_pricing_billing_period";
|
||||
DROP TYPE "public"."enum__products_v_version_en_translation_status";
|
||||
DROP TYPE "public"."enum__products_v_version_status";
|
||||
DROP TYPE "public"."enum__products_v_published_locale";
|
||||
DROP TYPE "public"."enum_home_hero_cta_primary_link_type";
|
||||
DROP TYPE "public"."enum_home_hero_cta_primary_page";
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as migration_20260929_200306_initial from './20260929_200306_initial';
|
||||
import * as migration_20260929_202255_initial from './20260929_202255_initial';
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
up: migration_20260929_200306_initial.up,
|
||||
down: migration_20260929_200306_initial.down,
|
||||
name: '20260929_200306_initial'
|
||||
up: migration_20260929_202255_initial.up,
|
||||
down: migration_20260929_202255_initial.down,
|
||||
name: '20260929_202255_initial'
|
||||
},
|
||||
];
|
||||
|
||||
@@ -158,7 +158,8 @@ describe('Payload globals', () => {
|
||||
// MITHOME-112: `slug` is the shared URL identifier of LegalPages.
|
||||
// MITHOME-113: `result`/`notes` are legal-validation metadata, not copy.
|
||||
// MITHOME-130: a product `name` is a brand, the same in every language.
|
||||
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address', 'slug', 'result', 'notes', 'name'])
|
||||
// MITHOME-136: the legal section `anchor` (formerly its row `id`) is shared too.
|
||||
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'anchor', 'address', 'slug', 'result', 'notes', 'name'])
|
||||
|
||||
type Node = FieldLike & { localized?: boolean; fields?: Node[] }
|
||||
type Finding = { path: string; type?: string; localized: boolean }
|
||||
@@ -285,6 +286,13 @@ describe('MITHOME-130 hosting plans', () => {
|
||||
expect(slug).toMatchObject({ required: true, unique: true })
|
||||
})
|
||||
|
||||
it('should give the lifecycle status its own PostgreSQL enum (MITHOME-136)', () => {
|
||||
// Regression: the default enum name equals the drafts `_status` enum, and
|
||||
// PostgreSQL then only accepted draft/published.
|
||||
const status = findField(Products.fields, 'status') as unknown as { enumName?: string }
|
||||
expect(status.enumName).toBe('enum_products_lifecycle_status')
|
||||
})
|
||||
|
||||
it('should require a whole, non-negative net price and default to yearly billing', () => {
|
||||
const net = findField(group('pricing'), 'netAmount') as unknown as FieldLike & { validate: Validate }
|
||||
expect(net.required).toBe(true)
|
||||
|
||||
Reference in New Issue
Block a user