// Example model schema from the Drizzle docs // https://orm.drizzle.team/docs/sql-schema-declaration import { pgTableCreator } from "drizzle-orm/pg-core"; import { serial, varchar, timestamp, integer, pgTable } from "drizzle-orm/pg-core"; import { sql } from "drizzle-orm"; /** * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same * database instance for multiple projects. * * @see https://orm.drizzle.team/docs/goodies#multi-project-schema */ export const createTable = pgTableCreator((name) => `hristudio_${name}`); export const studies = createTable( "study", { id: serial("id").primaryKey(), title: varchar("title", { length: 256 }).notNull(), description: varchar("description", { length: 1000 }), userId: varchar("user_id", { length: 256 }).notNull(), createdAt: timestamp("created_at", { withTimezone: true }) .default(sql`CURRENT_TIMESTAMP`) .notNull(), updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate( () => new Date() ), } ); export const participants = createTable( "participant", { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }).notNull(), studyId: integer("study_id").references(() => studies.id).notNull(), createdAt: timestamp("created_at", { withTimezone: true }) .default(sql`CURRENT_TIMESTAMP`) .notNull(), } );