Rebuild atomcms-next foundation on Prisma (align to habbo-next reference)

Replace the superseded Drizzle monorepo scaffold with a single-app Prisma 7
data layer, mirroring the proven habbo-next approach to the shared Arcturus
emulator DB (introspect/conform only, idempotent SQL migrations via a custom
runner; never migrate-diff).

- prisma/schema.prisma: User, UsersCurrency (composite PK), Ban, WebsiteSetting
  mapped to AtomCMS's default.sql columns; client generated to src/generated/prisma
- src/lib/prisma.ts: PrismaMariaDb adapter singleton; src/env.ts zod env
- src/lib/services: siteSettings (cached setting() equivalent) + CurrencyType enum
- prisma/migrations + scripts/apply-migrations.ts: idempotent CMS-table runner

Verified: prisma generate OK, tsc --noEmit exit 0, vitest 6/6 pass.
This commit is contained in:
Simo committed 2026-06-27 15:26:40 +02:00
1 parent 7bd4f2b28e
commit b5bc7f6daf
44 files changed
+1279 -511

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { z } from "zod";
// Minimal validated env for the foundation. When the Next.js app is added this
// will move to @t3-oss/env-nextjs (the habbo-next pattern), but the data layer
// only needs the DB connection + a couple of values today.
const schema = z.object({
NODE_ENV: z.enum(["development", "test", "production"]).default("development"),
DATABASE_URL: z.string().url(),
DATABASE_POOL_SIZE: z.coerce.number().int().positive().default(40),
DATABASE_IDLE_TIMEOUT_MS: z.coerce.number().int().positive().default(300_000),
HOTEL_NAME: z.string().default("Atom"),
});
type Env = z.infer<typeof schema>;
// SKIP_ENV_VALIDATION lets tooling (typecheck, tests that don't touch the DB)
// import modules transitively without a populated .env.
export const env: Env = process.env.SKIP_ENV_VALIDATION
? (process.env as unknown as Env)
: schema.parse(process.env);