first commit
Made-with: Cursor
This commit is contained in:
85
backend/prisma/seed.ts
Normal file
85
backend/prisma/seed.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const relays = [
|
||||
{ url: 'wss://relay.damus.io', priority: 1 },
|
||||
{ url: 'wss://nos.lol', priority: 2 },
|
||||
{ url: 'wss://relay.nostr.band', priority: 3 },
|
||||
];
|
||||
|
||||
for (const relay of relays) {
|
||||
await prisma.relay.upsert({
|
||||
where: { url: relay.url },
|
||||
update: {},
|
||||
create: relay,
|
||||
});
|
||||
}
|
||||
|
||||
const settings = [
|
||||
{ key: 'site_title', value: 'Belgian Bitcoin Embassy' },
|
||||
{ key: 'site_tagline', value: 'Your gateway to Bitcoin in Belgium' },
|
||||
{ key: 'telegram_link', value: 'https://t.me/belgianbitcoinembassy' },
|
||||
{ key: 'nostr_link', value: '' },
|
||||
{ key: 'x_link', value: '' },
|
||||
{ key: 'youtube_link', value: '' },
|
||||
{ key: 'discord_link', value: '' },
|
||||
{ key: 'linkedin_link', value: '' },
|
||||
];
|
||||
|
||||
for (const setting of settings) {
|
||||
await prisma.setting.upsert({
|
||||
where: { key: setting.key },
|
||||
update: {},
|
||||
create: setting,
|
||||
});
|
||||
}
|
||||
|
||||
const categories = [
|
||||
{ name: 'Bitcoin', slug: 'bitcoin', sortOrder: 1 },
|
||||
{ name: 'Lightning', slug: 'lightning', sortOrder: 2 },
|
||||
{ name: 'Privacy', slug: 'privacy', sortOrder: 3 },
|
||||
{ name: 'Education', slug: 'education', sortOrder: 4 },
|
||||
{ name: 'Community', slug: 'community', sortOrder: 5 },
|
||||
];
|
||||
|
||||
for (const category of categories) {
|
||||
await prisma.category.upsert({
|
||||
where: { slug: category.slug },
|
||||
update: {},
|
||||
create: category,
|
||||
});
|
||||
}
|
||||
|
||||
const existingMeetup = await prisma.meetup.findFirst({
|
||||
where: { title: 'Monthly Bitcoin Meetup' },
|
||||
});
|
||||
|
||||
if (!existingMeetup) {
|
||||
await prisma.meetup.create({
|
||||
data: {
|
||||
title: 'Monthly Bitcoin Meetup',
|
||||
description:
|
||||
'Join us for our monthly Bitcoin meetup! We discuss the latest developments, share knowledge, and connect with fellow Bitcoiners in Belgium.',
|
||||
date: '2025-02-15',
|
||||
time: '19:00',
|
||||
location: 'Brussels, Belgium',
|
||||
link: 'https://meetup.com/example',
|
||||
status: 'UPCOMING',
|
||||
featured: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Seed completed successfully.');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user