CMS Database Schema
Database: cms_myeasyguideORM: Prisma 7.8 IDs: String (cuid) generated by Prisma Purpose: Dedicated content database, independent from the commerce API database.
Models
Post
The core content entity. One row can be a blog post, travel guide, or scheduled article.
| Field | Type | Notes |
|---|---|---|
id | String (cuid, PK) | |
title | String? | |
slug | String | Unique only in combination with category/city/country |
content | String | Rich text/HTML from Tiptap |
coverImage | String? | |
status | String | Default "draft"; also published, scheduled, trash |
scheduledAt | DateTime? | Used by the scheduler |
publishedAt | DateTime? | |
views | Int | Default 0 |
metaTitle | String? | SEO |
metaDescription | String? | SEO |
meta | Json? | Word count, reading time, focus keyphrase |
toc | Json? | Table of contents |
jsonLdSchema | Json? | Structured data |
tags | String? | Comma-separated display tags (the Tag model is separate) |
canonicalUrl | String (unique) | Full public path, e.g. /travel-guide/everest |
urlHistory | String[] | Previous canonical URLs |
cityHandle | String? | Denormalised city slug for geo-tagging |
blogCategoryId | String? | FK → PostCategory |
subCategoryId | String? | FK → SubCategory |
authorId | String? | FK → Author |
cityId | String? | FK → City |
countryId | String? | FK → Country |
Unique constraint: [countryId, cityId, blogCategoryId, slug]. Indexes cover [status, createdAt], [status, scheduledAt], and each FK.
Taxonomy
| Model | Fields |
|---|---|
PostCategory | id, name, slug (unique), featureImage, secondaryImage, subtitle, content, metaTitle, metaDescription |
SubCategory | Same shape as PostCategory, separate table |
Tag | id, name (unique) |
Places
| Model | Fields |
|---|---|
City | id, cityName, cityHandle (unique), cityImage, secondaryImage, subtitle, content, metaTitle, metaDescription |
Country | id, countryName, countryCode (unique ISO), countryHandle (unique), plus the same editorial fields |
These are separate tables from Location/LocationType in the API database. Nothing links them at the database level.
Author
CMS user account. The role and permissions drive access in the admin UI and API.
| Field | Type | Notes |
|---|---|---|
id | String (cuid, PK) | |
username | String (unique) | |
name | String? | Display name |
email | String (unique) | Login |
password | String | bcrypt hash |
role | String | Default "author"; super_admin grants full access |
bio | String? | |
image | String? | |
permissions | String[] | Fine-grained grants for authors |
AI generation
| Model | Fields |
|---|---|
GenerationBatch | id, batchId (unique, Claude batch ID), topics[], focus?, status (pending, processing, completed, failed), error? |
Generated posts are written to Post; the batch row only tracks the Claude job.
Media
| Field | Type | Notes |
|---|---|---|
id | String (cuid, PK) | |
url | String | Public URL |
filename | String | |
alt | String? | Accessibility text |
caption | String? | |
title | String? | |
description | String? | |
mimeType | String? | |
fileSize | Int? | Bytes |
width | Int? | |
height | Int? |
Uploads are stored on disk by the CMS; resize, blur placeholder, and caching happen at request time.
Redirect
| Field | Type | Notes |
|---|---|---|
id | String (cuid, PK) | |
source | String (unique) | Path to match |
destination | String | Target path |
type | String | Default "permanent" (301); otherwise temporary (302) |
active | Boolean | Default true |
The public frontend's middleware reads this table through the CMS API and applies redirects before rendering. Post-level canonicalUrl/urlHistory redirects are handled by the frontend catch-all, not by this middleware.
Relationship summary
Post ──> PostCategory / SubCategory
Post ──> Author
Post ──> City / Country
Post ──? Tag (display tags stored on Post.tags; Tag model is a separate registry)
GenerationBatch ──writes──> Post
Redirect (standalone)
Media (standalone)Why the CMS has its own database
- Schema isolation — Content changes cannot break commerce tables.
- Separate credentials — A CMS compromise does not grant API database access.
- Independent deploys — Content tooling can ship without restarting the API.
- No cross-database keys — Each app owns its data and joins are done in application code.