Use dotenv-cli for db:push, db:seed, db:studio, and migrate:deploy so they match the API (root .env). Load dotenv in seed.ts for direct runs. Document absolute DATABASE_URL in .env.example. Made-with: Cursor
90 lines
2.4 KiB
TypeScript
90 lines
2.4 KiB
TypeScript
import dotenv from 'dotenv';
|
|
import path from 'path';
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
|
|
|
|
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();
|
|
});
|