MAI CALL - step 2
This commit is contained in:
parent
055d6e2a24
commit
e249a6f0b2
@ -18,7 +18,8 @@
|
|||||||
"PowerShell(corepack pnpm exec prisma migrate status --schema packages/db/prisma/schema.prisma 2>&1)",
|
"PowerShell(corepack pnpm exec prisma migrate status --schema packages/db/prisma/schema.prisma 2>&1)",
|
||||||
"PowerShell($env:npm_config_verify_deps_before_run = \"false\"; corepack pnpm exec prisma migrate status --schema packages/db/prisma/schema.prisma 2>&1 | Select-Object -Last 25)",
|
"PowerShell($env:npm_config_verify_deps_before_run = \"false\"; corepack pnpm exec prisma migrate status --schema packages/db/prisma/schema.prisma 2>&1 | Select-Object -Last 25)",
|
||||||
"Bash(pnpm --filter @repo/db exec prisma migrate dev --name add_maintenance_request)",
|
"Bash(pnpm --filter @repo/db exec prisma migrate dev --name add_maintenance_request)",
|
||||||
"Bash(pnpm --filter @repo/db exec prisma db execute --schema=prisma/schema.prisma --stdin)"
|
"Bash(pnpm --filter @repo/db exec prisma db execute --schema=prisma/schema.prisma --stdin)",
|
||||||
|
"Bash(docker exec *)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,14 @@ const prisma = new PrismaClient();
|
|||||||
const DEMO_TENANT_NAME = 'Demo Factory';
|
const DEMO_TENANT_NAME = 'Demo Factory';
|
||||||
const DEMO_ADMIN_EMAIL = 'admin@demo.local';
|
const DEMO_ADMIN_EMAIL = 'admin@demo.local';
|
||||||
|
|
||||||
|
const OPERATOR_EMAILS = ['op1@demo.local', 'op2@demo.local', 'op3@demo.local'];
|
||||||
|
|
||||||
|
const WORKSTATIONS = [
|
||||||
|
{ code: 'CTR04', name: 'Controlo 04', area: 'Montagem' },
|
||||||
|
{ code: 'QVN_RTL_2', name: 'Retificação Visual 2', area: 'Qualidade' },
|
||||||
|
{ code: 'MTG_01', name: 'Montagem 01', area: 'Montagem' },
|
||||||
|
];
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
// Idempotent: if a prior run created the demo tenant, wipe it and recreate.
|
// Idempotent: if a prior run created the demo tenant, wipe it and recreate.
|
||||||
// Cascade deletes on the relations handle the children.
|
// Cascade deletes on the relations handle the children.
|
||||||
@ -33,15 +41,20 @@ async function main() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await prisma.user.createMany({
|
||||||
|
data: OPERATOR_EMAILS.map((email) => ({
|
||||||
|
tenantId: tenant.id,
|
||||||
|
email,
|
||||||
|
role: UserRole.OPERATOR,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
await prisma.workstation.createMany({
|
await prisma.workstation.createMany({
|
||||||
data: [
|
data: WORKSTATIONS.map((ws) => ({ tenantId: tenant.id, ...ws })),
|
||||||
{ tenantId: tenant.id, code: 'WS-001', name: 'Assembly A', area: 'Floor 1' },
|
|
||||||
{ tenantId: tenant.id, code: 'WS-002', name: 'Packaging B', area: 'Floor 2' },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.warn(
|
console.warn(
|
||||||
`Seed complete — tenant=${tenant.id} (${tenant.name}), admin=${DEMO_ADMIN_EMAIL}, workstations=2`,
|
`Seed complete — tenant=${tenant.id} (${tenant.name}), admin=${DEMO_ADMIN_EMAIL}, operators=${OPERATOR_EMAILS.length}, workstations=${WORKSTATIONS.length}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user