Skip to content

Instantly share code, notes, and snippets.

@BrockHerion
Created April 11, 2024 12:05
Show Gist options
  • Select an option

  • Save BrockHerion/8ac673879022dcf2db60f37bb1cc92d4 to your computer and use it in GitHub Desktop.

Select an option

Save BrockHerion/8ac673879022dcf2db60f37bb1cc92d4 to your computer and use it in GitHub Desktop.
Example of a Drizzle schema with TypeScript regions
import { pgTable, serial, text, varchar, integer } from 'drizzle-orm/pg-core';
//#region Users
export const user = pgTable("user", {
id: serial('id').primaryKey(),
email: varchar("email", { length: 255 }).unique().notNull(),
password: varchar("password", { length: 255 }).notNull()
});
export const useProfile = pgTable("user_profile", {
id: serial('id').primaryKey(),
name: varchar("name", { length: 128 }).notNull(),
bio: text("bio"),
avatar: text("avatar"),
userId: integer("user_id").notNull().references(() => user.id)
});
//#endregion
//#region Teams
export const team = pgTable("team", {
id: serial('id').primaryKey(),
name: varchar("name", { length: 128 }).notNull(),
// other fields/relations
});
//#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment