feat: update backend schema and code for new profile UI
This commit is contained in:
parent
f800008487
commit
024e30bd99
@ -5,13 +5,7 @@ import { z } from "zod"
|
|||||||
|
|
||||||
import { and, eq, sql } from "drizzle-orm"
|
import { and, eq, sql } from "drizzle-orm"
|
||||||
import * as schema from "./schema"
|
import * as schema from "./schema"
|
||||||
import {
|
import { Sandbox, sandbox, user, usersToSandboxes } from "./schema"
|
||||||
Sandbox,
|
|
||||||
sandbox,
|
|
||||||
sandboxLikes,
|
|
||||||
user,
|
|
||||||
usersToSandboxes,
|
|
||||||
} from "./schema"
|
|
||||||
|
|
||||||
export interface Env {
|
export interface Env {
|
||||||
DB: D1Database
|
DB: D1Database
|
||||||
@ -365,6 +359,16 @@ export default {
|
|||||||
const updateUserSchema = z.object({
|
const updateUserSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
name: z.string().optional(),
|
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(),
|
email: z.string().email().optional(),
|
||||||
username: z.string().optional(),
|
username: z.string().optional(),
|
||||||
avatarUrl: z.string().optional(),
|
avatarUrl: z.string().optional(),
|
||||||
|
@ -2,6 +2,26 @@ import { createId } from "@paralleldrive/cuid2"
|
|||||||
import { relations, sql } from "drizzle-orm"
|
import { relations, sql } from "drizzle-orm"
|
||||||
import { integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core"
|
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
|
// #region Tables
|
||||||
export const user = sqliteTable("user", {
|
export const user = sqliteTable("user", {
|
||||||
id: text("id")
|
id: text("id")
|
||||||
@ -16,6 +36,9 @@ export const user = sqliteTable("user", {
|
|||||||
sql`CURRENT_TIMESTAMP`
|
sql`CURRENT_TIMESTAMP`
|
||||||
),
|
),
|
||||||
generations: integer("generations").default(0),
|
generations: integer("generations").default(0),
|
||||||
|
bio: text("bio"),
|
||||||
|
personalWebsite: text("personalWebsite"),
|
||||||
|
links: text("links", { mode: "json" }).default("[]").$type<UserLink[]>(),
|
||||||
tier: text("tier", { enum: ["FREE", "PRO", "ENTERPRISE"] }).default("FREE"),
|
tier: text("tier", { enum: ["FREE", "PRO", "ENTERPRISE"] }).default("FREE"),
|
||||||
tierExpiresAt: integer("tierExpiresAt"),
|
tierExpiresAt: integer("tierExpiresAt"),
|
||||||
lastResetDate: integer("lastResetDate"),
|
lastResetDate: integer("lastResetDate"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user