54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function seedSettings() {
|
|
console.log('🌱 Seeding settings...');
|
|
|
|
const defaultSettings = [
|
|
{
|
|
key: 'dateFormat',
|
|
value: 'ar-SA',
|
|
description: 'Date format locale (ar-SA or en-US)'
|
|
},
|
|
{
|
|
key: 'currency',
|
|
value: 'JOD',
|
|
description: 'Currency code (JOD, USD, EUR, etc.)'
|
|
},
|
|
{
|
|
key: 'numberFormat',
|
|
value: 'ar-SA',
|
|
description: 'Number format locale (ar-SA or en-US)'
|
|
},
|
|
{
|
|
key: 'currencySymbol',
|
|
value: 'د.أ',
|
|
description: 'Currency symbol display'
|
|
},
|
|
{
|
|
key: 'dateDisplayFormat',
|
|
value: 'dd/MM/yyyy',
|
|
description: 'Date display format pattern'
|
|
}
|
|
];
|
|
|
|
for (const setting of defaultSettings) {
|
|
await prisma.settings.upsert({
|
|
where: { key: setting.key },
|
|
update: {},
|
|
create: setting
|
|
});
|
|
}
|
|
|
|
console.log('✅ Settings seeded successfully');
|
|
}
|
|
|
|
seedSettings()
|
|
.catch((e) => {
|
|
console.error('❌ Error seeding settings:', e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
}); |