feat: implement core platform features including business directory, admin dashboard, authentication, and API infrastructure
Some checks failed
Build and Push App / build (push) Failing after 16m2s
Some checks failed
Build and Push App / build (push) Failing after 16m2s
This commit is contained in:
53
scratch/fix_db.ts
Normal file
53
scratch/fix_db.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import pg from 'pg';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config({ path: '.env.local' });
|
||||
|
||||
const connectionString = process.env.DATABASE_URL!;
|
||||
const pool = new pg.Pool({ connectionString });
|
||||
const adapter = new PrismaPg(pool);
|
||||
const prisma = new PrismaClient({ adapter });
|
||||
|
||||
async function fix() {
|
||||
console.log('--- Nettoyage et stabilisation des données vedettes ---');
|
||||
|
||||
// 1. Désactiver 'isFeatured' pour tout le monde par défaut
|
||||
await prisma.business.updateMany({
|
||||
data: { isFeatured: false }
|
||||
});
|
||||
|
||||
// 2. Activer isFeatured pour les 8 premiers (comme prévu dans le seed)
|
||||
// On va chercher les 8 premières entreprises créées
|
||||
const firstEight = await prisma.business.findMany({
|
||||
take: 8,
|
||||
orderBy: { createdAt: 'asc' }
|
||||
});
|
||||
|
||||
for (const biz of firstEight) {
|
||||
await prisma.business.update({
|
||||
where: { id: biz.id },
|
||||
data: {
|
||||
isFeatured: true,
|
||||
// On s'assure que le keyMetric est propre
|
||||
keyMetric: biz.keyMetric === 'susu land' ? '+50 Projets Livrés' : biz.keyMetric
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 3. Fix spécifique pour Ananas Export s'il n'est pas dans les 8
|
||||
await prisma.business.updateMany({
|
||||
where: { name: 'Ananas Export' },
|
||||
data: {
|
||||
keyMetric: 'Leader Export Fruits',
|
||||
isFeatured: true // On le garde en vedette car l'utilisateur l'aime bien apparemment
|
||||
}
|
||||
});
|
||||
|
||||
console.log('✅ Données stabilisées.');
|
||||
await prisma.$disconnect();
|
||||
await pool.end();
|
||||
}
|
||||
|
||||
fix();
|
||||
Reference in New Issue
Block a user