fix: resolve foreign key constraint by ensuring system user exists in seed script
This commit is contained in:
+15
-1
@@ -11,6 +11,20 @@ const adapter = new PrismaPg(pool)
|
|||||||
const prisma = new PrismaClient({ adapter })
|
const prisma = new PrismaClient({ adapter })
|
||||||
|
|
||||||
async function main() {
|
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...')
|
console.log('Seeding initial maps from .canvas files...')
|
||||||
|
|
||||||
const rootDir = resolve(process.cwd())
|
const rootDir = resolve(process.cwd())
|
||||||
@@ -59,7 +73,7 @@ async function main() {
|
|||||||
data: {
|
data: {
|
||||||
id: xflowProject.id,
|
id: xflowProject.id,
|
||||||
name: xflowProject.name,
|
name: xflowProject.name,
|
||||||
ownerId: xflowProject.ownerId || ownerId,
|
ownerId: ownerId,
|
||||||
isPublic: true,
|
isPublic: true,
|
||||||
nodes: xflowProject.nodes as any,
|
nodes: xflowProject.nodes as any,
|
||||||
edges: xflowProject.edges as any
|
edges: xflowProject.edges as any
|
||||||
|
|||||||
Reference in New Issue
Block a user