Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/ schema ids #17

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 52 additions & 52 deletions drizzle/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,75 @@ import {
pgTable,
serial,
text,
} from "drizzle-orm/pg-core";
} from 'drizzle-orm/pg-core';

export const organizations = pgTable("organizations", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
slug: text("slug").notNull().unique(),
export const organizations = pgTable('organizations', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
slug: text('slug').notNull().unique(),
});

export const projects = pgTable("projects", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
slug: text("slug").notNull().unique(),
organizationId: serial("organization_id").references(() => organizations.id, {
onDelete: "cascade",
export const projects = pgTable('projects', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
slug: text('slug').notNull().unique(),
organizationId: serial('organization_id').references(() => organizations.id, {
onDelete: 'cascade',
}),
});

export const protocols = pgTable("protocols", {
id: serial("id").primaryKey(),
hash: text("hash").notNull().unique(),
name: text("name").notNull(),
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 protocols = pgTable('protocols', {
id: serial('id').primaryKey(),
hash: text('hash').notNull().unique(),
name: text('name').notNull(),
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",
export const protocolsAssets = pgTable('protocols_assets', {
protocolId: serial('protocol_id').references(() => protocols.id, {
onDelete: 'cascade',
}),
assetId: text("asset_id").references(() => assets.assetId, {
onDelete: "cascade",
assetId: serial('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 assets = pgTable('assets', {
key: text('key').primaryKey(),
assetId: serial('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",
export const interviews = pgTable('interviews', {
id: serial('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: serial('participant_id').references(() => participants.id, {
onDelete: 'cascade',
}),
protocolId: text("protocol_id").references(() => protocols.id, {
onDelete: "cascade",
protocolId: serial('protocol_id').references(() => protocols.id, {
onDelete: 'cascade',
}),
currentStep: integer("current_step").notNull().default(0),
stageMetadata: json("stage_metadata"),
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"),
export const participants = pgTable('participants', {
id: serial('id').primaryKey(),
identifier: text('identifier').notNull().unique(),
label: text('label'),
});
Loading