Files
klz-cables.com/scripts/seed-payload.ts
Marc Mintel 30eb2e6e0e
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m44s
Build & Deploy / 🏗️ Build (push) Successful in 5m49s
Build & Deploy / 🚀 Deploy (push) Failing after 20s
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / ♿ WCAG (push) Has been skipped
Build & Deploy / 🛡️ Quality Gates (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 4s
feat: persistent payload storage and automated db migrations
2026-02-24 22:24:01 +01:00

42 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { getPayload } from 'payload';
import configPromise from '../payload.config';
async function seed() {
console.log('🌱 Starting PayloadCMS seed process...');
try {
const payload = await getPayload({ config: configPromise });
// Check if any users exist
const { totalDocs } = await payload.find({
collection: 'users',
limit: 1,
});
if (totalDocs === 0) {
console.log('👤 No users found. Creating default admin user...');
await payload.create({
collection: 'users',
data: {
email: 'admin@mintel.me',
password: 'klz-admin-setup',
firstName: 'KLZ',
lastName: 'Admin',
role: 'admin',
},
});
console.log('✅ Default admin user created successfully.');
} else {
console.log(` Database already contains ${totalDocs} users. Skipping user creation.`);
}
console.log('✅ PayloadCMS seed completed successfully!');
process.exit(0);
} catch (error) {
console.error('❌ Failed to seed PayloadCMS database:', error);
process.exit(1);
}
}
seed();