- Introduced a new script for setting up a fresh database with ordered migration tasks. - Added a utility function to find media by filename, improving media handling in various scripts. - Updated preload scripts to utilize the new media fetching utility. - Refactored datenschutz, impressum, and mitglied-werden fields to use stable IDs and anchor IDs. - Enhanced home and network pages to accommodate new field structures. - Added new preload script for global CMS settings. - Improved code readability and organization across multiple files.
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import 'dotenv/config'
|
|
|
|
import config from '@payload-config'
|
|
import { getPayload } from 'payload'
|
|
import { mediaByFilename } from './mediaByFilename'
|
|
|
|
import { formularUploadContent } from '@/spa/formularUploadContent'
|
|
|
|
async function main() {
|
|
const payload = await getPayload({ config })
|
|
|
|
const pageResult = await payload.find({
|
|
collection: 'pages',
|
|
limit: 1,
|
|
pagination: false,
|
|
draft: true,
|
|
overrideAccess: true,
|
|
where: {
|
|
or: [{ spaPath: { equals: '/formular-hochladen' } }, { slug: { equals: 'formular-hochladen' } }, { slug: { equals: 'upload' } }],
|
|
},
|
|
})
|
|
|
|
const page = pageResult.docs[0]
|
|
if (!page) throw new Error('Formular upload page not found. Expected spaPath=/formular-hochladen or slug=formular-hochladen/upload.')
|
|
|
|
await payload.update({
|
|
collection: 'pages',
|
|
id: page.id,
|
|
overrideAccess: true,
|
|
context: { disableRevalidate: true },
|
|
data: {
|
|
formUpload: formularUploadContent,
|
|
} as never,
|
|
})
|
|
|
|
payload.logger.info(`Preloaded Formular upload CMS fields for page ${page.id}`)
|
|
process.exit(0)
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|