feat: implement home page, business directory, and administrative management features with updated schema and API routes
Some checks failed
Build and Push App / build (push) Failing after 51s
Some checks failed
Build and Push App / build (push) Failing after 51s
This commit is contained in:
52
prisma/seed-categories.ts
Normal file
52
prisma/seed-categories.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import pg from 'pg';
|
||||
import { config } from 'dotenv';
|
||||
|
||||
config();
|
||||
config({ path: '.env.local', override: true });
|
||||
|
||||
const connectionString = process.env.DATABASE_URL!;
|
||||
const pool = new pg.Pool({ connectionString });
|
||||
const adapter = new PrismaPg(pool);
|
||||
const prisma = new PrismaClient({ adapter });
|
||||
|
||||
const CATEGORIES = [
|
||||
{ name: "Technologie & IT", slug: "technologie-it" },
|
||||
{ name: "Agriculture & Agrobusiness", slug: "agriculture-agrobusiness" },
|
||||
{ name: "Mode & Textile", slug: "mode-textile" },
|
||||
{ name: "Cosmétique & Beauté", slug: "cosmetique-beaute" },
|
||||
{ name: "Services aux entreprises", slug: "services-entreprises" },
|
||||
{ name: "Restauration & Alimentation", slug: "restauration-alimentation" },
|
||||
{ name: "Construction & BTP", slug: "construction-btp" },
|
||||
{ name: "Éducation & Formation", slug: "education-formation" },
|
||||
{ name: "Santé & Bien-être", slug: "sante-bien-etre" },
|
||||
{ name: "Artisanat & Déco", slug: "artisanat-deco" },
|
||||
{ name: "Tourisme & Loisirs", slug: "tourisme-loisirs" },
|
||||
{ name: "Finance & Assurance", slug: "finance-assurance" }
|
||||
];
|
||||
|
||||
async function main() {
|
||||
console.log('Seeding categories...');
|
||||
for (const cat of CATEGORIES) {
|
||||
await prisma.businessCategory.upsert({
|
||||
where: { name: cat.name },
|
||||
update: {},
|
||||
create: {
|
||||
name: cat.name,
|
||||
slug: cat.slug,
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log('Categories seeded!');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user