- Added new newsletter subscription functionality to the participation page. - Created a new `NewsletterForm` component to handle user subscriptions. - Introduced `NewsletterSubscriptions` collection to manage subscriptions in the database. - Developed migration script to set up necessary database tables and fields for the newsletter feature. - Refactored participation content to remove deprecated newsletter phase data and integrate new structure. - Updated the `Participation` page to utilize the new newsletter form and handle different application phases.
121 lines
3.1 KiB
TypeScript
121 lines
3.1 KiB
TypeScript
import 'dotenv/config'
|
|
|
|
import config from '@payload-config'
|
|
import { spawnSync } from 'node:child_process'
|
|
import { getPayload } from 'payload'
|
|
|
|
const orderedScripts = [
|
|
{
|
|
label: 'Import media assets',
|
|
path: 'src/scripts/migrate-spa-media.ts',
|
|
},
|
|
{
|
|
label: 'Create base pages, posts, events, and Preisträger records',
|
|
path: 'src/scripts/migrate-spa-pages.ts',
|
|
},
|
|
{
|
|
label: 'Store header, footer, site settings, application phase, and newsletter form defaults',
|
|
path: 'src/scripts/preload-globals-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload detail page copy for blog posts',
|
|
path: 'src/scripts/preload-blog-detail-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload detail page copy for events',
|
|
path: 'src/scripts/preload-event-detail-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload detail page copy for Preisträger',
|
|
path: 'src/scripts/preload-preistraeger-detail-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload home page',
|
|
path: 'src/scripts/preload-home-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload about page',
|
|
path: 'src/scripts/preload-about-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload contact page',
|
|
path: 'src/scripts/preload-contact-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload Datenschutz page',
|
|
path: 'src/scripts/preload-datenschutz-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload formular upload page',
|
|
path: 'src/scripts/preload-formular-upload-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload Impressum page',
|
|
path: 'src/scripts/preload-impressum-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload Mitglied werden page',
|
|
path: 'src/scripts/preload-mitglied-werden-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload Netzwerk page',
|
|
path: 'src/scripts/preload-netzwerk-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload participation page',
|
|
path: 'src/scripts/preload-participation-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload participation awards and award posts',
|
|
path: 'src/scripts/preload-participation-awards-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload Preisträger index page',
|
|
path: 'src/scripts/preload-preistraeger-index-page-cms.ts',
|
|
},
|
|
{
|
|
label: 'Preload press index page',
|
|
path: 'src/scripts/preload-press-index-page-cms.ts',
|
|
},
|
|
]
|
|
|
|
async function initializeSchema() {
|
|
const payload = await getPayload({ config })
|
|
|
|
payload.logger.info(
|
|
`Initialized Payload schema for ${Object.keys(payload.collections).length} collections and ${
|
|
Object.keys(payload.globals.config).length
|
|
} globals.`,
|
|
)
|
|
|
|
await payload.destroy()
|
|
}
|
|
|
|
function runScript(scriptPath: string) {
|
|
const result = spawnSync('tsx', [scriptPath], {
|
|
env: process.env,
|
|
stdio: 'inherit',
|
|
})
|
|
|
|
if (result.error) throw result.error
|
|
if (result.status !== 0) throw new Error(`${scriptPath} failed with exit code ${result.status ?? 'unknown'}`)
|
|
}
|
|
|
|
async function main() {
|
|
console.log('Setting up a fresh Payload database...')
|
|
console.log('1. Initialize Payload tables')
|
|
await initializeSchema()
|
|
|
|
for (const [index, script] of orderedScripts.entries()) {
|
|
console.log(`${index + 2}. ${script.label}`)
|
|
runScript(script.path)
|
|
}
|
|
|
|
console.log('Fresh database setup complete.')
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|