- Add lib/db (schema, postgres.js client, enums, seed, migrations) on Drizzle - Rewrite all lib and admin action queries from Prisma to Drizzle - Keep existing table/column names so no data migration is needed - Preserve signed-cookie admin auth unchanged - Map unique-violation handling from Prisma P2002 to SQLSTATE 23505 - Swap deps, scripts, Makefile, and Dockerfile from Prisma to Drizzle
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// Shared enum values + types. NO server/ORM imports here — this file is safe to
|
||||
// import from client components (replaces the old `@prisma/client` enum imports).
|
||||
//
|
||||
// Defined as `const object + union type` (the same shape Prisma generated) rather
|
||||
// than a TS `enum`, so bare string literals like "IMAGE" stay assignable and
|
||||
// `z.nativeEnum(...)` keeps working.
|
||||
|
||||
export const PortfolioSectionType = {
|
||||
RICH_TEXT: "RICH_TEXT",
|
||||
GALLERY: "GALLERY",
|
||||
STATS: "STATS",
|
||||
DELIVERABLES: "DELIVERABLES",
|
||||
LINK: "LINK",
|
||||
} as const;
|
||||
export type PortfolioSectionType = (typeof PortfolioSectionType)[keyof typeof PortfolioSectionType];
|
||||
|
||||
export const PortfolioAssetKind = {
|
||||
IMAGE: "IMAGE",
|
||||
DOCUMENT: "DOCUMENT",
|
||||
} as const;
|
||||
export type PortfolioAssetKind = (typeof PortfolioAssetKind)[keyof typeof PortfolioAssetKind];
|
||||
|
||||
export const PortfolioProjectViewMode = {
|
||||
GRID: "GRID",
|
||||
STORY: "STORY",
|
||||
CASE_STUDY: "CASE_STUDY",
|
||||
} as const;
|
||||
export type PortfolioProjectViewMode =
|
||||
(typeof PortfolioProjectViewMode)[keyof typeof PortfolioProjectViewMode];
|
||||
|
||||
export const MediaSource = {
|
||||
UPLOAD: "UPLOAD",
|
||||
EXTERNAL: "EXTERNAL",
|
||||
} as const;
|
||||
export type MediaSource = (typeof MediaSource)[keyof typeof MediaSource];
|
||||
|
||||
export const MediaKind = {
|
||||
IMAGE: "IMAGE",
|
||||
DOCUMENT: "DOCUMENT",
|
||||
} as const;
|
||||
export type MediaKind = (typeof MediaKind)[keyof typeof MediaKind];
|
||||
|
||||
export const MediaUsageType = {
|
||||
PORTFOLIO_COVER: "PORTFOLIO_COVER",
|
||||
PORTFOLIO_SECTION: "PORTFOLIO_SECTION",
|
||||
PORTFOLIO_ASSET: "PORTFOLIO_ASSET",
|
||||
GENERIC: "GENERIC",
|
||||
} as const;
|
||||
export type MediaUsageType = (typeof MediaUsageType)[keyof typeof MediaUsageType];
|
||||
|
||||
// Helper: enum-object -> tuple of its string values, for Drizzle pgEnum(...).
|
||||
// Preserves the literal union (not widened to `string`) so pgEnum columns infer
|
||||
// as the exact union type.
|
||||
export function enumValues<T extends Record<string, string>>(e: T): [T[keyof T], ...T[keyof T][]] {
|
||||
return Object.values(e) as [T[keyof T], ...T[keyof T][]];
|
||||
}
|
||||
Reference in New Issue
Block a user