40 lines · 1.6 KB · TypeScript
RawDownload
// ---------------------------------------------------------------------------// Cloud-specific identity & multi-tenancy tables// --------------------------------------------------------------------------- import { pgTable, text, timestamp, primaryKey } from "drizzle-orm/pg-core"; export const users = pgTable("users", {  id: text("id").primaryKey(),  email: text("email").notNull().unique(),  name: text("name"),  avatarUrl: text("avatar_url"),  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),}); export const teams = pgTable("teams", {  id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),  name: text("name").notNull(),  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),}); export const teamMembers = pgTable(  "team_members",  {    teamId: text("team_id").notNull(),    userId: text("user_id").notNull(),    role: text("role").notNull().$default(() => "member"),    createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),  },  (table) => [primaryKey({ columns: [table.teamId, table.userId] })],); export const invitations = pgTable("invitations", {  id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),  teamId: text("team_id").notNull(),  email: text("email").notNull(),  invitedBy: text("invited_by").notNull(),  status: text("status").notNull().$default(() => "pending"),  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),  expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t