diff --git a/backend/database/src/index.ts b/backend/database/src/index.ts index 80e38e4..cd1da76 100644 --- a/backend/database/src/index.ts +++ b/backend/database/src/index.ts @@ -5,13 +5,7 @@ import { z } from "zod" import { and, eq, sql } from "drizzle-orm" import * as schema from "./schema" -import { - Sandbox, - sandbox, - sandboxLikes, - user, - usersToSandboxes, -} from "./schema" +import { Sandbox, sandbox, user, usersToSandboxes } from "./schema" export interface Env { DB: D1Database @@ -365,6 +359,16 @@ export default { const updateUserSchema = z.object({ id: z.string(), name: z.string().optional(), + bio: z.string().optional(), + personalWebsite: z.string().optional(), + links: z + .array( + z.object({ + url: z.string(), + platform: z.enum(schema.KNOWN_PLATFORMS), + }) + ) + .optional(), email: z.string().email().optional(), username: z.string().optional(), avatarUrl: z.string().optional(), diff --git a/backend/database/src/schema.ts b/backend/database/src/schema.ts index 33c86f3..c490a59 100644 --- a/backend/database/src/schema.ts +++ b/backend/database/src/schema.ts @@ -2,6 +2,26 @@ import { createId } from "@paralleldrive/cuid2" import { relations, sql } from "drizzle-orm" import { integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core" +export const KNOWN_PLATFORMS = [ + "github", + "twitter", + "instagram", + "bluesky", + "linkedin", + "youtube", + "twitch", + "discord", + "mastodon", + "threads", + "gitlab", + "generic", +] as const + +export type KnownPlatform = (typeof KNOWN_PLATFORMS)[number] +export type UserLink = { + url: string + platform: KnownPlatform +} // #region Tables export const user = sqliteTable("user", { id: text("id") @@ -16,6 +36,9 @@ export const user = sqliteTable("user", { sql`CURRENT_TIMESTAMP` ), generations: integer("generations").default(0), + bio: text("bio"), + personalWebsite: text("personalWebsite"), + links: text("links", { mode: "json" }).default("[]").$type(), tier: text("tier", { enum: ["FREE", "PRO", "ENTERPRISE"] }).default("FREE"), tierExpiresAt: integer("tierExpiresAt"), lastResetDate: integer("lastResetDate"),