Created
April 11, 2024 12:05
-
-
Save BrockHerion/8ac673879022dcf2db60f37bb1cc92d4 to your computer and use it in GitHub Desktop.
Example of a Drizzle schema with TypeScript regions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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