fix: resolve foreign key constraint by ensuring system user exists in seed script

This commit is contained in:
2026-04-28 18:53:24 +05:00
parent 28bf677a0c
commit 7da3fc8ff4
+15 -1
View File
@@ -11,6 +11,20 @@ const adapter = new PrismaPg(pool)
const prisma = new PrismaClient({ adapter })
async function main() {
console.log('Ensuring system user exists...')
let systemUser = await prisma.user.findUnique({ where: { id: 'system' } })
if (!systemUser) {
systemUser = await prisma.user.create({
data: {
id: 'system',
username: 'system',
email: 'system@localhost',
password: 'none',
role: 'admin'
}
})
}
console.log('Seeding initial maps from .canvas files...')
const rootDir = resolve(process.cwd())
@@ -59,7 +73,7 @@ async function main() {
data: {
id: xflowProject.id,
name: xflowProject.name,
ownerId: xflowProject.ownerId || ownerId,
ownerId: ownerId,
isPublic: true,
nodes: xflowProject.nodes as any,
edges: xflowProject.edges as any