ManagerOS uses a staging-based development workflow where all development work happens in the staging branch. This workflow ensures that version increments and database migrations are properly managed before being deployed to production.
staging: Primary development branch where all feature work happensmain: Production branch that receives merges fromstaging- Feature branches: Optional, can be created from
stagingfor larger features
-
Create Feature Branch (optional):
git checkout staging git pull origin staging git checkout -b feature/my-feature
-
Make Changes: Implement your feature, including any necessary database schema changes
-
Create Database Migrations:
# After modifying prisma/schema.prisma bunx prisma migrate dev --name descriptive_migration_nameThis will:
- Create a new migration file in
prisma/migrations/ - Apply the migration to your local dev database
- Update the Prisma client
- Create a new migration file in
-
Version Bump (when adding features):
# Bump version as you add features bun run version:patch # For bug fixes and minor changes bun run version:minor # For new features bun run version:major # For breaking changes
Note: Version bumps happen during development in staging, not during release.
-
Commit and Push:
git add . git commit -m "feat: add new feature" git push origin feature/my-feature # or staging if working directly
-
Merge to Staging: Create a PR to merge your feature branch into
staging, or push directly tostagingif working there.
Version increments are automatically determined by release-it when merging staging to main. The system analyzes commit messages since the last release tag using the Conventional Commits specification:
- Major: Commits with
BREAKING CHANGE:or!(e.g.,feat!: remove API) - Minor: Commits with
feat:prefix (e.g.,feat: add dashboard) - Patch: Commits with
fix:or other types (e.g.,fix: resolve bug)
The highest increment type found determines the version bump. For example, if you have both feat: and fix: commits, it will bump the minor version.
No manual version bumping required: Simply use conventional commit messages, and release-it will handle version increments automatically.
Commit Message Guidelines:
- Patch: Use
fix:for bug fixes, orchore:,docs:,style:,refactor:,perf:,test:for other changes - Minor: Use
feat:for new features that are backward compatible - Major: Use
feat!:or includeBREAKING CHANGE:in the commit body for breaking changes
Example workflow:
# Working on a new feature
git checkout staging
# ... make changes ...
git add .
git commit -m "feat: add user dashboard" # Automatic minor version bump
git push origin stagingWhen staging is merged to main, release-it automatically:
- Analyzes all commits since the last release tag
- Determines the appropriate version bump based on commit types
- Updates
package.jsonwith the new version - Creates a release tag and GitHub release
- Generates a changelog from conventional commits
Then Vercel will build the production application.
Currently, migrations are not applied automatically.
All database migrations are created in the staging branch using Prisma's migration system:
# 1. Modify prisma/schema.prisma with your changes
# 2. Create and apply migration
bunx prisma migrate dev --name add_user_preferences
# This creates:
# - prisma/migrations/YYYYMMDDHHMMSS_add_user_preferences/migration.sql
# - Updates your local dev database- All migration files are committed to version control in
prisma/migrations/ - Migration files are included in both staging and production builds
- Migrations are applied in order based on their timestamp
- Environment: Staging uses the development database
- Configuration: Set via
DATABASE_URLenvironment variable in staging environment - Migrations: Applied during development using
prisma migrate dev
- Environment: Production uses the production database
- Configuration: Set via
DATABASE_URLenvironment variable in production environment - Migrations: Automatically applied during Vercel build using
prisma migrate deploy
When code is deployed to production (via Vercel), the build process automatically:
- Generates Prisma client:
bunx prisma generate - Applies pending migrations:
bunx prisma migrate deploy - Builds the application:
next build --turbo
Important: prisma migrate deploy is production-safe:
- Only applies migrations that haven't been applied yet
- Safe to run multiple times
- Designed specifically for production environments
- Will not create new migrations or modify existing ones
┌─────────────────────────────────────────────────────────┐
│ 1. Development in staging branch │
│ - Create migrations with prisma migrate dev │
│ - Use conventional commit messages (feat:, fix:) │
│ - Commit migration files and code │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ 2. Merge staging → main │
│ - Migration files included in merge │
│ - Version already bumped in staging │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ 3. GitHub Action triggers release │
│ - Creates release tag │
│ - Creates GitHub release │
│ - Pushes to main with "chore: release" commit │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ 4. Vercel builds production │
│ - bunx prisma generate │
│ - bunx prisma migrate deploy (applies migrations) │
│ - next build --turbo │
└─────────────────────────────────────────────────────────┘
- Always create migrations in staging: Never create migrations directly in production
- Test migrations locally: Ensure migrations work correctly in your dev environment
- Review migration files: Check the generated SQL in
prisma/migrations/before committing - Descriptive names: Use clear, descriptive names for migrations
- One feature per migration: Keep migrations focused on a single change when possible
- Bump as you develop: Increment version when adding features, not just at release time
- Use appropriate increment: Choose patch/minor/major based on the type of change
- Commit version with feature: Include version bump in the same commit as the feature
- Document breaking changes: If using major version, document what breaks
- Keep staging up to date: Regularly sync with main to avoid conflicts
- Test before merging: Ensure all migrations work and tests pass before merging to main
- Monitor production builds: Watch Vercel build logs to ensure migrations apply successfully
- Backup before major migrations: Consider backing up production database before large schema changes
Problem: Migration fails during production build
Solution:
- Check Vercel build logs for specific error
- Verify migration SQL is correct
- Ensure database connection is properly configured
- Test migration locally first
Problem: Migration already applied error
Solution: This is normal - prisma migrate deploy will skip already-applied migrations. No action needed.
Problem: Version already bumped when merging to main
Solution: This is expected behavior. The release workflow will handle the already-bumped version correctly.
- Database: Development database (configured in Vercel staging environment)
- Clerk: Development Clerk instance
- Purpose: Testing and development
- Database: Production database (configured in Vercel production environment)
- Clerk: Production Clerk instance
- Purpose: Live application
Both environments use the same codebase and migration files, but connect to different databases configured via environment variables.