EENE Dashboard upload to Gitea
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
45
backend/scripts/seed-team-if-empty.ts
Normal file
45
backend/scripts/seed-team-if-empty.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 팀원이 0명일 때만 hr-data.json TEAM → team_members (업무는 건드리지 않음)
|
||||
*/
|
||||
import 'dotenv/config';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { mapHrTeamMembers } from '../prisma/mapHrProjects';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const count = await prisma.teamMember.count();
|
||||
if (count > 0) {
|
||||
console.log('✓ Team members exist — skip TEAM seed');
|
||||
return;
|
||||
}
|
||||
|
||||
const teamParsed = mapHrTeamMembers();
|
||||
if (teamParsed.length === 0) {
|
||||
console.log('✓ hr-data.json TEAM empty — skip');
|
||||
return;
|
||||
}
|
||||
|
||||
for (const tm of teamParsed) {
|
||||
await prisma.teamMember.create({
|
||||
data: {
|
||||
name: tm.name,
|
||||
rank: tm.rank,
|
||||
role: tm.role,
|
||||
cell: tm.cell,
|
||||
photoUrl: tm.photoUrl,
|
||||
sortOrder: tm.sortOrder,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`✅ Team members seeded: ${teamParsed.length}명 (hr-data.json TEAM)`);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user