Skip to content

Commit

Permalink
define protocol, asset, interview, and participant entities
Browse files Browse the repository at this point in the history
  • Loading branch information
buckhalt committed Jun 4, 2024
1 parent 446d288 commit 5749476
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions drizzle/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { pgTable, serial, text } from "drizzle-orm/pg-core";
import {
date,
integer,
json,
pgTable,
serial,
text,
} from "drizzle-orm/pg-core";

export const organizations = pgTable("organizations", {
id: serial("id").primaryKey(),
Expand All @@ -17,9 +24,56 @@ export const projects = pgTable("projects", {

export const protocols = pgTable("protocols", {
id: serial("id").primaryKey(),
hash: text("hash").notNull().unique(),
name: text("name").notNull(),
slug: text("slug").notNull().unique(),
schemaVersion: integer("schema_version").notNull(),
description: text("description"),
importedAt: date("imported_at").notNull().defaultNow(),
lastModified: date("last_modified").notNull(),
stages: json("stages").notNull(),
codebook: json("codebook").notNull(),
projectId: serial("project_id").references(() => projects.id, {
onDelete: "cascade",
}),
});

export const protocolsAssets = pgTable("protocols_assets", {
protocolId: serial("protocol_id").references(() => protocols.id, {
onDelete: "cascade",
}),
assetId: text("asset_id").references(() => assets.assetId, {
onDelete: "cascade",
}),
});

export const assets = pgTable("assets", {
key: text("key").primaryKey(),
assetId: text("asset_id").notNull().unique(),
name: text("name").notNull(),
type: text("type").notNull(),
url: text("url").notNull(),
size: integer("size").notNull(),
});

export const interviews = pgTable("interviews", {
id: text("id").primaryKey(),
startTime: date("start_time").notNull().defaultNow(),
finishTime: date("finish_time"),
exportTime: date("export_time"),
lastUpdated: date("last_updated").notNull().defaultNow(),
network: json("network").notNull(),
participantId: text("participant_id").references(() => participants.id, {
onDelete: "cascade",
}),
protocolId: text("protocol_id").references(() => protocols.id, {
onDelete: "cascade",
}),
currentStep: integer("current_step").notNull().default(0),
stageMetadata: json("stage_metadata"),
});

export const participants = pgTable("participants", {
id: text("id").primaryKey(),
identifier: text("identifier").notNull().unique(),
label: text("label"),
});

0 comments on commit 5749476

Please sign in to comment.