Skip to content

Commit

Permalink
update studyuser model
Browse files Browse the repository at this point in the history
  • Loading branch information
jthrilly committed Mar 4, 2022
1 parent f942c42 commit ff48f99
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 36 deletions.
14 changes: 3 additions & 11 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ model ProtocolRevision {
stages Stage[]
interviews Interview[]
entities ProtocolEntity[]
ego ProtocolEgoEntity?
egoAttributes ProtocolEgoAttribute[]
}

model Stage {
Expand All @@ -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())
Expand Down Expand Up @@ -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[]
}
Expand Down
68 changes: 43 additions & 25 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}
})

Expand All @@ -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,
},
},
]
});
});

Expand All @@ -105,6 +122,7 @@ async function main() {
skipDuplicates: true,
});

console.log('Seeding ')
}

main()
Expand Down

0 comments on commit ff48f99

Please sign in to comment.