CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
schema.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| fc1817a | 1 | import { |
| 2 | pgTable, | |
| 3 | text, | |
| 4 | timestamp, | |
| 5 | uuid, | |
| 6 | boolean, | |
| 7 | integer, | |
| 8 | uniqueIndex, | |
| 9 | } from "drizzle-orm/pg-core"; | |
| 10 | ||
| 11 | export const users = pgTable("users", { | |
| 12 | id: uuid("id").primaryKey().defaultRandom(), | |
| 13 | username: text("username").notNull().unique(), | |
| 14 | email: text("email").notNull().unique(), | |
| 15 | displayName: text("display_name"), | |
| 16 | passwordHash: text("password_hash").notNull(), | |
| 17 | avatarUrl: text("avatar_url"), | |
| 18 | bio: text("bio"), | |
| 19 | createdAt: timestamp("created_at").defaultNow().notNull(), | |
| 20 | updatedAt: timestamp("updated_at").defaultNow().notNull(), | |
| 21 | }); | |
| 22 | ||
| 06d5ffe | 23 | export const sessions = pgTable("sessions", { |
| 24 | id: uuid("id").primaryKey().defaultRandom(), | |
| 25 | userId: uuid("user_id") | |
| 26 | .notNull() | |
| 27 | .references(() => users.id, { onDelete: "cascade" }), | |
| 28 | token: text("token").notNull().unique(), | |
| 29 | expiresAt: timestamp("expires_at").notNull(), | |
| 30 | createdAt: timestamp("created_at").defaultNow().notNull(), | |
| 31 | }); | |
| 32 | ||
| fc1817a | 33 | export const repositories = pgTable( |
| 34 | "repositories", | |
| 35 | { | |
| 36 | id: uuid("id").primaryKey().defaultRandom(), | |
| 37 | name: text("name").notNull(), | |
| 38 | ownerId: uuid("owner_id") | |
| 39 | .notNull() | |
| 40 | .references(() => users.id), | |
| 41 | description: text("description"), | |
| 42 | isPrivate: boolean("is_private").default(false).notNull(), | |
| 43 | defaultBranch: text("default_branch").default("main").notNull(), | |
| 44 | diskPath: text("disk_path").notNull(), | |
| 45 | createdAt: timestamp("created_at").defaultNow().notNull(), | |
| 46 | updatedAt: timestamp("updated_at").defaultNow().notNull(), | |
| 47 | pushedAt: timestamp("pushed_at"), | |
| 48 | starCount: integer("star_count").default(0).notNull(), | |
| 49 | forkCount: integer("fork_count").default(0).notNull(), | |
| 50 | }, | |
| 51 | (table) => [uniqueIndex("repos_owner_name").on(table.ownerId, table.name)] | |
| 52 | ); | |
| 53 | ||
| 06d5ffe | 54 | export const stars = pgTable( |
| 55 | "stars", | |
| 56 | { | |
| 57 | id: uuid("id").primaryKey().defaultRandom(), | |
| 58 | userId: uuid("user_id") | |
| 59 | .notNull() | |
| 60 | .references(() => users.id, { onDelete: "cascade" }), | |
| 61 | repositoryId: uuid("repository_id") | |
| 62 | .notNull() | |
| 63 | .references(() => repositories.id, { onDelete: "cascade" }), | |
| 64 | createdAt: timestamp("created_at").defaultNow().notNull(), | |
| 65 | }, | |
| 66 | (table) => [uniqueIndex("stars_user_repo").on(table.userId, table.repositoryId)] | |
| 67 | ); | |
| 68 | ||
| fc1817a | 69 | export const sshKeys = pgTable("ssh_keys", { |
| 70 | id: uuid("id").primaryKey().defaultRandom(), | |
| 71 | userId: uuid("user_id") | |
| 72 | .notNull() | |
| 06d5ffe | 73 | .references(() => users.id, { onDelete: "cascade" }), |
| fc1817a | 74 | title: text("title").notNull(), |
| 75 | fingerprint: text("fingerprint").notNull(), | |
| 76 | publicKey: text("public_key").notNull(), | |
| 77 | lastUsedAt: timestamp("last_used_at"), | |
| 78 | createdAt: timestamp("created_at").defaultNow().notNull(), | |
| 79 | }); | |
| 80 | ||
| 81 | export type User = typeof users.$inferSelect; | |
| 82 | export type NewUser = typeof users.$inferInsert; | |
| 83 | export type Repository = typeof repositories.$inferSelect; | |
| 84 | export type NewRepository = typeof repositories.$inferInsert; | |
| 06d5ffe | 85 | export type Session = typeof sessions.$inferSelect; |
| 86 | export type Star = typeof stars.$inferSelect; | |
| 87 | export type SshKey = typeof sshKeys.$inferSelect; |