uup
This commit is contained in:
54
prisma/settingsSeed.ts
Normal file
54
prisma/settingsSeed.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user