synchronisation du contenu avec la DB et amélioration du CMS
- Migration du blog et des interviews des données mockées vers PostgreSQL (Prisma). - Refonte des pages publiques en Server Components pour de meilleures performances/SEO. - Intégration d'un éditeur de texte riche (React Quill) avec titres H1-H6 et séparateurs. - Correction des erreurs de validation Prisma liées aux paramètres asynchrones (Next.js 15+). - Correction des problèmes d'affichage des modales de suspension via React Portals. - Installation de @tailwindcss/typography et correction du débordement de texte (break-words). - Implémentation des actions de modération (suspension/révocation) pour les utilisateurs et boutiques.
This commit is contained in:
46
scripts/migrate-isactive.ts
Normal file
46
scripts/migrate-isactive.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import pg from 'pg';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config({ path: '.env.local' });
|
||||
dotenv.config();
|
||||
|
||||
const connectionString = process.env.DATABASE_URL!;
|
||||
const pool = new pg.Pool({ connectionString });
|
||||
const adapter = new PrismaPg(pool);
|
||||
const prisma = new PrismaClient({ adapter });
|
||||
|
||||
async function migrate() {
|
||||
console.log('--- Starting isActive Migration ---');
|
||||
|
||||
const businesses = await prisma.business.findMany();
|
||||
console.log(`Found ${businesses.length} businesses to check.`);
|
||||
|
||||
let updatedCount = 0;
|
||||
|
||||
for (const biz of businesses) {
|
||||
const isNameOk = biz.name && biz.name !== "Nouvelle Entreprise";
|
||||
const isDescOk = biz.description && biz.description.length >= 20;
|
||||
const isLocOk = biz.location && biz.location !== "Ma Ville";
|
||||
const isEmailOk = !!biz.contactEmail;
|
||||
const isPhoneOk = !!biz.contactPhone;
|
||||
|
||||
const newIsActive = !!(isNameOk && isDescOk && isLocOk && isEmailOk && isPhoneOk);
|
||||
|
||||
if (biz.isActive !== newIsActive) {
|
||||
await prisma.business.update({
|
||||
where: { id: biz.id },
|
||||
data: { isActive: newIsActive }
|
||||
});
|
||||
console.log(`Updated "${biz.name}" (ID: ${biz.id}): isActive ${biz.isActive} -> ${newIsActive}`);
|
||||
updatedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`--- Migration Complete: ${updatedCount} records updated ---`);
|
||||
}
|
||||
|
||||
migrate()
|
||||
.catch(console.error)
|
||||
.finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user