Skip to content

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.

FieldTypeNotes
idString (cuid, PK)
titleString?
slugStringUnique only in combination with category/city/country
contentStringRich text/HTML from Tiptap
coverImageString?
statusStringDefault "draft"; also published, scheduled, trash
scheduledAtDateTime?Used by the scheduler
publishedAtDateTime?
viewsIntDefault 0
metaTitleString?SEO
metaDescriptionString?SEO
metaJson?Word count, reading time, focus keyphrase
tocJson?Table of contents
jsonLdSchemaJson?Structured data
tagsString?Comma-separated display tags (the Tag model is separate)
canonicalUrlString (unique)Full public path, e.g. /travel-guide/everest
urlHistoryString[]Previous canonical URLs
cityHandleString?Denormalised city slug for geo-tagging
blogCategoryIdString?FK → PostCategory
subCategoryIdString?FK → SubCategory
authorIdString?FK → Author
cityIdString?FK → City
countryIdString?FK → Country

Unique constraint: [countryId, cityId, blogCategoryId, slug]. Indexes cover [status, createdAt], [status, scheduledAt], and each FK.

Taxonomy ​

ModelFields
PostCategoryid, name, slug (unique), featureImage, secondaryImage, subtitle, content, metaTitle, metaDescription
SubCategorySame shape as PostCategory, separate table
Tagid, name (unique)

Places ​

ModelFields
Cityid, cityName, cityHandle (unique), cityImage, secondaryImage, subtitle, content, metaTitle, metaDescription
Countryid, 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.

FieldTypeNotes
idString (cuid, PK)
usernameString (unique)
nameString?Display name
emailString (unique)Login
passwordStringbcrypt hash
roleStringDefault "author"; super_admin grants full access
bioString?
imageString?
permissionsString[]Fine-grained grants for authors

AI generation ​

ModelFields
GenerationBatchid, 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 ​

FieldTypeNotes
idString (cuid, PK)
urlStringPublic URL
filenameString
altString?Accessibility text
captionString?
titleString?
descriptionString?
mimeTypeString?
fileSizeInt?Bytes
widthInt?
heightInt?

Uploads are stored on disk by the CMS; resize, blur placeholder, and caching happen at request time.

Redirect ​

FieldTypeNotes
idString (cuid, PK)
sourceString (unique)Path to match
destinationStringTarget path
typeStringDefault "permanent" (301); otherwise temporary (302)
activeBooleanDefault 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.

Built with VitePress