DocsBlogPricingPluginsDemo
Get Codapult

Build your SaaS. Launch your MVP.

Get Codapult

Product

  • Pricing
  • Architecture
  • Modules
  • AI platform
  • Plugins

Developers

  • MCP
  • CLI
  • Documentation
  • Launch your SaaS
  • Build a B2B SaaS

Resources

  • Blog
  • FAQ

Connect

  • Contact
  • GitHub

Compare

  • SaaS template comparison
  • Codapult vs Supastarter
  • Codapult vs Makerkit
  • Codapult vs ShipFast
  • Codapult vs SaaSBold
  • Codapult vs Gravity
  • Codapult vs Nextbase
  • Codapult vs BuilderKit

Featured on

Codapult on LaunchNestCodapult on LaunchNestbetterlaunch.cobetterlaunch.coFeatured on LaunchBuffFeatured on LaunchBuffCodapult on PeerPushCodapult on PeerPushFeatured on LaunchItFeatured on LaunchIt
© 2026 Codapult·All rights reserved·Privacy Policy·Terms of Service
Built-in AI · Team-ready SaaS · One-time purchase
All articles

Getting Started

  • Introduction
  • Quick Start
  • Your First 30 Minutes
  • Project Structure
  • License and Permitted Use
  • Starter Profiles and Recipes
  • Product Recipes

Configuration

  • Environment Variables
  • App Configuration
  • Which Modules Should I Enable?
  • Provider Matrix
  • Capability Coverage

Authentication

  • Authentication
  • OAuth Providers
  • Two-Factor & Passwordless
  • Enterprise SSO (SAML)

Database

  • Database
  • Database and Provider Guide
  • Database Migrations

Teams

  • Teams & Organizations
  • Permissions & RBAC
  • SCIM Provisioning

Deployment

  • Deployment
  • Enterprise E2E Evidence
  • Enterprise Production Readiness
  • Deployment, Backup, and Restore Runbook
  • Troubleshooting

Payments

  • Payments & Billing
  • Stripe Setup
  • LemonSqueezy Setup
  • Polar Setup
  • Payment Webhooks

Api

  • API Layer
  • tRPC
  • GraphQL

Ai

  • AI Features
  • AI Runtime Architecture and Evals
  • Streaming Chat
  • RAG and Semantic Search
  • Quotas and Memory

Email

  • Email
  • Email Templates

Infrastructure

  • Infrastructure
  • Self-Hosting
  • File Storage
  • Docker
  • Background Jobs
  • Terraform & Pulumi
  • Kubernetes

Ui

  • UI & Theming

I18n

  • Internationalization

Content Management

  • Content Management

Admin

  • Admin Panel

Security

  • Security
  • Data Retention Policy

Monitoring

  • Analytics & Monitoring

Modules

  • Module Architecture
  • Waitlist
  • Welcome Page
  • Audit Log
  • White-Labeling
  • Workflow Automation
  • A/B Testing
  • Referrals
  • GDPR Export and Deletion
  • Promotions
  • Outgoing Webhooks

Plugins

  • Product plugins
  • CRM Plugin
  • Helpdesk Plugin
  • Email Marketing Plugin

Upgrading

  • Upgrading Codapult

Developer Tools

  • AI Agents & IDEs
  • MCP Server
  • Testing
  • Build Your First Feature with Codapult MCP
  • Architecture Guardrails for AI Coding Agents
Database

Database Migrations

Generate, review, and apply Drizzle migrations in your Codapult project.

When to Use Migrations

Use pnpm db:push for a fresh or disposable development database when you do not need migration history. If you want migration history from the start, initialize an empty database with pnpm db:generate and pnpm db:migrate. Production databases should use migration history. For an existing database that was initialized with db:push, verify a baseline against its current schema before switching migration tracking on; do not apply a generated full initial migration as though the database were empty.

Generate and Apply a Migration

  1. Update the active Drizzle schema. Keep schema.ts and schema-pg.ts aligned if your project supports both providers.
  2. Run pnpm db:generate to compare the schema with the latest snapshot in your project's migration history.
  3. Review the generated SQL under src/lib/db/migrations/ for Turso/SQLite or src/lib/db/migrations-pg/ for PostgreSQL. Add explicit SQL for data transformations when required.
  4. Run pnpm db:migrate against the selected database.
  5. Commit the SQL and snapshot with the schema change.

The first migration can be generated in your project from its selected schema. Generated migrations and Drizzle snapshots form your project's migration history and anchor later schema diffs.

Provider Selection

DB_PROVIDER selects the schema and output directory in drizzle.config.ts:

ProviderSchemaMigration directory
Turso / SQLite (default)src/lib/db/schema.tssrc/lib/db/migrations/
PostgreSQLsrc/lib/db/schema-pg.tssrc/lib/db/migrations-pg/

Generate migrations for each provider your project supports, using the corresponding DB_PROVIDER value and configuration.

Review Data Changes

Generated SQL is a proposal based on the difference between Drizzle snapshots. Review table and column removals, type changes, constraints, and index changes before applying it to a database with data. A rename or data transformation may need a custom migration so existing values survive.

Rollback Strategy

Before applying a migration, review its SQL and take a database backup when the change can remove or rewrite data. Drizzle does not generate a safe reverse migration automatically. If an applied migration causes a problem, prefer a new forward migration that restores the intended schema or data. Keep applied migration files append-only; do not edit one to repair a database that has already recorded it as applied.

For production recovery, restore and validate a backup against an isolated database before switching traffic. See the deployment backup and restore runbook.

Schema Conflicts During Upgrades

When an upstream schema change overlaps with your project changes, resolve the schema conflict first and generate a migration from the merged schema:

  1. Merge upstream and project-owned table and column changes in the active schema. Preserve both sides' intent and include any required data transformation.
  2. Run pnpm db:generate and inspect the generated SQL for unexpected drops, type changes, or data loss.
  3. Apply and verify the migration in a development or staging database before applying it to production with pnpm db:migrate.

For the source merge and conflict-resolution process, see the Upgrading guide.

Database and Provider GuideTeams & Organizations