47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
#!/usr/bin/env tsx
|
|
|
|
import { db } from '../lib/db';
|
|
import { settings } from '../lib/db/schema';
|
|
import { eq } from 'drizzle-orm';
|
|
|
|
async function seedBrandSettings() {
|
|
console.log('🌱 Seeding brand settings...');
|
|
|
|
const brandSettings = [
|
|
{ key: 'club_name', value: 'TT Club' },
|
|
{ key: 'sport_name', value: 'Table Tennis' },
|
|
{ key: 'app_title', value: 'Table Tennis Booking System' },
|
|
{ key: 'app_description', value: 'Book your table tennis court slots with ease' },
|
|
];
|
|
|
|
for (const setting of brandSettings) {
|
|
try {
|
|
// Check if setting exists
|
|
const existing = await db.select().from(settings).where(eq(settings.key, setting.key)).limit(1);
|
|
|
|
if (existing.length === 0) {
|
|
// Insert new setting
|
|
await db.insert(settings).values({
|
|
id: crypto.randomUUID(),
|
|
key: setting.key,
|
|
value: setting.value,
|
|
updatedAt: new Date(),
|
|
});
|
|
console.log(`✅ Added setting: ${setting.key} = ${setting.value}`);
|
|
} else {
|
|
console.log(`⚠️ Setting already exists: ${setting.key}`);
|
|
}
|
|
} catch (error) {
|
|
console.error(`❌ Error adding setting ${setting.key}:`, error);
|
|
}
|
|
}
|
|
|
|
console.log('✅ Brand settings seeded successfully!');
|
|
process.exit(0);
|
|
}
|
|
|
|
seedBrandSettings().catch((error) => {
|
|
console.error('❌ Error seeding brand settings:', error);
|
|
process.exit(1);
|
|
});
|