Skip to main content

Database Schema Updates - Turbo Cache Management

This guide explains how to properly handle database schema changes in the CONA monorepo to ensure Turbo doesn’t use stale cached builds.

πŸ”§ Auto-Invalidation Setup

The project is now configured to automatically detect schema changes and invalidate Turbo cache when needed.

What Gets Tracked

βœ… Schema file changes: packages/database/prisma/schema.prisma
βœ… Migration changes: packages/database/prisma/migrations/**
βœ… Generated Prisma client: .prisma/** and node_modules/.prisma/**
βœ… Database package builds: Any change triggers dependent package rebuilds

πŸš€ Quick Commands

When You Update the Schema

This command:
  1. Regenerates the Prisma client with latest schema
  2. Force rebuilds all dependent packages (@cona/core, @cona/temporal-workflows, etc.)
For migrations, run separately:

Alternative Commands

🎯 Automatic Cache Invalidation

With this configuration, Turbo will automatically:
  1. Detect schema changes when you modify prisma/schema.prisma
  2. Invalidate build cache for all packages that depend on @cona/database
  3. Rebuild dependent packages like @cona/core, @cona/temporal-workflows, @cona/webapp

πŸ§ͺ Testing Schema Changes

Before Schema Changes

After Schema Changes

⚠️ Important Notes

Environment Consistency

  • Ensure your .env.local files point to the correct database
  • Local development should use localhost:54322 (Docker)
  • Production uses remote Supabase connection

When Turbo Cache Issues Persist

Temporal Workers

After schema changes, always restart temporal workers: