Skip to content

Database Overview

MyEasyGuide uses two independent PostgreSQL databases, each owned by a separate application. They share the same Postgres instance but have no cross-database foreign keys or direct communication.

DatabaseApplicationSchema File
walkthroughnepalapi.myeasyguide.comprisma/schema.prisma
cms_myeasyguidecms-myeasyguideprisma/schema.prisma

Key Differences

AspectAPI DatabaseCMS Database
Models18 models + 9 enums8 models
DomainCommerce (activities, bookings, payments, suppliers, users)Content (posts, authors, categories, tags)
Shared modelsCity exists hereCity also exists here (separate table)
Migrations17 migration filesMultiple migration files
Prisma version7.17.8

Why Two Databases?

The CMS was originally part of the Express API. As the project evolved, content management was extracted into a standalone Next.js application with its own database. This provides:

  • Independent scaling — Content operations don't compete with commerce queries
  • Independent deployments — CMS can be updated without touching the API
  • Schema separation — CMS models (Post, Tag, GenerationBatch) are optimized for content workflows
  • Security isolation — CMS database credentials are separate from the API

Model Relationship Summary

API Database (walkthroughnepal)

Admin ──authors──> Activity <── references ── City
User  ──books──> Booking ──pays──> Payment
Supplier ──owns──> Activity <── reviews ── Review
Activity <── categorizes ── TripCategory
Activity <── types ── TripType
Activity <── located_in ── City / Region
Activity <── features ── FeaturedTag (M:N via ActivityFeaturedTag)
User <── saves ── Wishlist
User <── subscribes ── NewsletterSubscriber

CMS Database (cms_myeasyguide)

Post ──belongs_to──> PostCategory / SubCategory
Post ──written_by──> Author
Post ──located_in──> City / Country
Post <── tagged_with ── Tag
GenerationBatch ──generates──> Post

Editorial Migration Impact

As part of the editorial migration, the following models were removed from the API schema (tables remain in the database but are no longer managed by the API's Prisma):

Removed ModelReplaced By (CMS)
BlogPost
BlogCategoryPostCategory
AuthorAuthor (new table in CMS DB)
BlogGenerationImportGenerationBatch
BlogGenerationImportRow— (simplified in CMS)
BlogGenerationJob— (simplified in CMS)
BusinessLink— (feature removed)

Important: The database tables for these models still exist in walkthroughnepal. Running prisma migrate from the API would drop them. Do not run migrations until you are certain no data is needed from these tables. See the Editorial Migration page for details.

Built with VitePress