Go to file
dimitar d5e7a9a0b5 feat(schema): Phase 6 — VarChar bounds, updatedAt, key index, prisma seed
Schema hardening pass. After reading the onboarding/edit forms I
reconsidered the original 'migrate String? -> DateTime?' suggestion:
the bornDate/passedDate placeholders are 'нпр. 1960' and the column
deliberately accepts imprecise values like '1960', 'early 1990s',
'12 May 1960'. Forcing DateTime? would silently break that feature
and require users to enter exact dates they often don't know. The
responsible fix is to keep the free-text semantics but bound the
column length and document the intent in a schema comment. Future
structured-date queries should add a parallel DateTime? column.

Schema changes (prisma/schema.prisma):
- @db.VarChar bounds added to every string column, sized to match
  the existing client-side maxLength / app-constant caps:
    User.subdomain -> 32, User.title -> 100, User.description -> 2000,
    User.bornDate/passedDate -> 50, User.email -> 255, etc.
    Image.url/key -> 255, Image.id/userId -> 30.
    AdminUser.username -> 50, passwordHash -> 100.
    Code.code -> 12, usedByUserId -> 100 (matches Clerk userId scale).
- Image.key: added @@index('Image_key_idx') to support the
  /api/image lookup we tightened in Phase 1 (currently a scan).
- updatedAt added to Image, AdminUser, Code (previously only User).
- Inline schema comment on Code.createdById documenting the existing
  onDelete: Restrict behaviour (Prisma default) — the migration does
  not change it, just makes the audit-trail intent explicit.

Migration:
- 20260802000000_phase6_schema_hardening/migration.sql: explicit
  ALTER TABLE ... SET DATA TYPE VARCHAR(N) statements for every
  bounded column; ADD COLUMN updatedAt with DEFAULT CURRENT_TIMESTAMP
  (so existing rows back-fill immediately); CREATE INDEX for the
  Image.key column; a defensive LEFT() truncation UPDATE for any rows
  whose bornDate/passedDate exceed 50 chars (the inputs always capped
  at 50 on the client side, so this is belt-and-braces). Will be
  applied on next deploy via 'prisma migrate deploy'.

Seed:
- prisma/seed.ts: upserts the SUPER_ADMIN row from env
  SUPER_ADMIN_USERNAME + SUPER_ADMIN_PASSWORD_HASH. This resolves
  the Phase 1 problem where an env-only super-admin had no row in
  AdminUser, which meant the Code.createdById FK prevented them from
  ever creating codes. The seed is idempotent and safe to run on
  every boot (uses upsert).
- package.json: 'prisma.seed' wired to 'tsx prisma/seed.ts'.
- 'db:seed' npm script also added for manual provisioning.
- tsx added as devDependency (executes TypeScript straight from disk
  without pre-build).
2026-08-02 14:47:41 +02:00
.github/workflows chore(devops): Phase 5 — Dockerfile, .dockerignore, CI, deploy cleanup, error/loading UI 2026-08-02 13:20:10 +02:00
docs superAdmin and admin implemented 2026-08-01 23:42:42 +02:00
prisma feat(schema): Phase 6 — VarChar bounds, updatedAt, key index, prisma seed 2026-08-02 14:47:41 +02:00
public init 2026-06-20 18:17:30 +02:00
scripts feat(security): Phase 1 — harden auth, rate limiting, CSRF, upload validation 2026-08-02 10:24:28 +02:00
src chore(devops): Phase 5 — Dockerfile, .dockerignore, CI, deploy cleanup, error/loading UI 2026-08-02 13:20:10 +02:00
.dockerignore chore(devops): Phase 5 — Dockerfile, .dockerignore, CI, deploy cleanup, error/loading UI 2026-08-02 13:20:10 +02:00
.env.example feat(security): Phase 1 — harden auth, rate limiting, CSRF, upload validation 2026-08-02 10:24:28 +02:00
.gitignore chore(devops): Phase 5 — Dockerfile, .dockerignore, CI, deploy cleanup, error/loading UI 2026-08-02 13:20:10 +02:00
docker-compose.dev.yaml local dev setup 2026-07-29 16:52:54 +02:00
docker-compose.yaml t v3 2026-06-22 23:28:41 +02:00
Dockerfile chore(devops): Phase 5 — Dockerfile, .dockerignore, CI, deploy cleanup, error/loading UI 2026-08-02 13:20:10 +02:00
Dockerfile.dev local dev setup 2026-07-29 16:52:54 +02:00
eslint.config.mjs init 2026-06-20 18:17:30 +02:00
next.config.ts perf: Phase 3 — parallel uploads + security headers, powered-by-header off 2026-08-02 12:21:23 +02:00
package-lock.json feat(schema): Phase 6 — VarChar bounds, updatedAt, key index, prisma seed 2026-08-02 14:47:41 +02:00
package.json feat(schema): Phase 6 — VarChar bounds, updatedAt, key index, prisma seed 2026-08-02 14:47:41 +02:00
postcss.config.mjs init 2026-06-20 18:17:30 +02:00
tsconfig.json test: Phase 4 — vitest setup + unit tests for admin-session and rate-limit 2026-08-02 13:05:06 +02:00
vitest.config.ts test: Phase 4 — vitest setup + unit tests for admin-session and rate-limit 2026-08-02 13:05:06 +02:00

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.