From ff48f991cd2df1aa10ca642a5ef59923b4850817 Mon Sep 17 00:00:00 2001 From: Joshua Melville Date: Fri, 4 Mar 2022 10:15:12 +0200 Subject: [PATCH] update studyuser model --- prisma/schema.prisma | 14 ++------- prisma/seed.ts | 68 ++++++++++++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 38606436..7afda090 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -74,7 +74,7 @@ model ProtocolRevision { stages Stage[] interviews Interview[] entities ProtocolEntity[] - ego ProtocolEgoEntity? + egoAttributes ProtocolEgoAttribute[] } model Stage { @@ -91,20 +91,12 @@ model ProtocolEntity { attributes ProtocolAttribute[] name String description String? - color Colors? + color Colors protocolRevision ProtocolRevision @relation(fields: [protocolRevisionId], references: [revision], onDelete: Cascade, onUpdate: Cascade) protocolRevisionId Int instances InterviewEntity[] } -model ProtocolEgoEntity { - id String @id @default(cuid()) - attributes ProtocolEgoAttribute[] - protocolRevision ProtocolRevision @relation(fields: [protocolRevisionId], references: [revision], onDelete: Cascade, onUpdate: Cascade) - protocolRevisionId Int -} - - // Instance of node/edge model InterviewEntity { id String @id @default(cuid()) @@ -132,7 +124,7 @@ model ProtocolEgoAttribute { type AttributeTypes validation Json? @default("{}") component InputComponents? - definedWithin ProtocolEgoEntity @relation(fields: [definedWithinId], references: [id], onDelete: Cascade, onUpdate: Cascade) + definedWithin ProtocolRevision @relation(fields: [definedWithinId], references: [id], onDelete: Cascade, onUpdate: Cascade) definedWithinId String usedIn InterviewEgoAttribute[] } diff --git a/prisma/seed.ts b/prisma/seed.ts index 77c28371..8ce08edc 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -47,6 +47,42 @@ async function main() { name: 'My Protocol', description: 'This is my protocol', protocolId, + entities: { + create: [ + { + name: 'Person', + description: 'Node type representing a person', + color: Colors.COLOR_1, + type: EntityType.NODE, + attributes: { + create: [ + { + id: cuid(), + name: 'name', + type: AttributeTypes.text, + validation: {}, + component: InputComponents.TextInput, + }, + { + id: cuid(), + name: 'age', + type: AttributeTypes.number, + validation: {}, + component: InputComponents.NumberInput, + } + ] + }, + }, + ] + }, + egoAttributes: { + create: { + id: cuid(), + name: 'name', + type: AttributeTypes.text, + component: InputComponents.TextInput, + }, + } } }) @@ -59,32 +95,13 @@ async function main() { type: StageTypes.Information, protocolRevisionId: 1, }, - ] - }); - - console.log("Seeding entity definitions..."); - const nodeId = cuid(); - const edgeId = cuid(); - const egoId = cuid(); - await prisma.protocolEntity.create({ - data: { - name: 'Person', - description: 'Node type representing a person', - color: Colors.COLOR_1, - type: EntityType.NODE, - protocolRevisionId: 1, - attributes: { - create: [ - { - id: cuid(), - name: 'name', - type: AttributeTypes.text, - validation: {}, - component: InputComponents.TextInput, - } - ] + { + id: cuid(), + name: 'Post-study', + type: StageTypes.Information, + protocolRevisionId: 1, }, - }, + ] }); }); @@ -105,6 +122,7 @@ async function main() { skipDuplicates: true, }); + console.log('Seeding ') } main()