This guide helps you migrate between nself versions, covering new features, breaking changes, and step-by-step upgrade procedures. The current stable version is v0.4.8.
Before starting the migration, create a complete backup of your project and data. The migration process modifies configuration files and directory structure.
Expected migration time: 10-20 minutes for most projects
# Update to latest version
nself update
# Verify version
nself --version
# Should show v0.4.8 or later# Create complete project backup
cp -r /path/to/your/project /path/to/backup/project-backup
# Export database
nself db backup --name pre-migration-backup
# Backup configuration
cp .env .env.backupv0.4.7+ uses a new environment structure with .environments/ directory:
your-project/
├── .environments/ # NEW: Environment configurations
│ ├── dev/
│ │ └── .env # Development settings
│ ├── staging/
│ │ ├── .env # Staging settings
│ │ ├── .env.secrets # Staging secrets (git-ignored)
│ │ └── server.json # SSH connection details
│ └── prod/
│ ├── .env # Production settings
│ ├── .env.secrets # Production secrets (git-ignored)
│ └── server.json # SSH connection details
├── .env # Active configuration (git-ignored)
└── .env.example # Template# Initialize environments
nself env init
# Switch environments
nself env switch dev
nself env switch staging
nself env switch prod
# Generate secrets for staging/prod
nself staging secrets generate
nself prod secrets generateSome environment variables have been renamed or reorganized:
| v0.1.x | v0.2.0 | Notes |
|---|---|---|
| DB_PASSWORD | POSTGRES_PASSWORD | Renamed for clarity |
| HASURA_SECRET | HASURA_GRAPHQL_ADMIN_SECRET | Matches Hasura convention |
| SERVICES | NESTJS_SERVICES | Specific to NestJS |
| AUTO_MIGRATE | DB_AUTO_MIGRATE | Scoped to database |
v0.2.0 adds many new configuration options:
# Database management
DB_SEED_ON_INIT=true
DB_BACKUP_RETENTION=7
DB_CONFIRM_DESTRUCTIVE=true
# Service scaling
NESTJS_API_REPLICAS=2
BULLMQ_EMAIL_CONCURRENCY=5
PYTHON_ML_API_REPLICAS=1
# Performance tuning
POSTGRES_SHARED_BUFFERS=256MB
REDIS_MAXMEMORY=128MB
NGINX_WORKER_PROCESSES=autoThe migration tool attempts to generate a DBML schema from your existing database:
# If automatic generation fails, create manually
nself db generate:from-database
# Or start with a template
nself db init --template basic
# Edit the generated schema
nano database/schema.dbml# Generate initial migration from existing schema
nself db run --message "Initial migration from v0.1"
# This creates:
# database/migrations/001_initial_migration_from_v0.1.up.sql
# database/migrations/001_initial_migration_from_v0.1.down.sqlIf you had custom services in v0.1.x, update your configuration:
# Old format (v0.1.x)
SERVICES=api,webhooks
# New format (v0.2.0)
NESTJS_SERVICES=api,webhooks
NESTJS_VERSION=10.x
NESTJS_SWAGGER=true# Old format (v0.1.x)
WORKERS=email,image
# New format (v0.2.0)
BULLMQ_WORKERS=email-worker,image-processor
BULLMQ_EMAIL_CONCURRENCY=5
BULLMQ_IMAGE_CONCURRENCY=3Check the generated database/schema.dbml file:
# Validate the generated schema
nself db validate
# Make any necessary adjustments to schema.dbml
nano database/schema.dbml
# Regenerate migrations if needed
nself db run --message "Updated schema after migration"If you have custom services or functions, update them for v0.2.0 compatibility:
# Test database connectivity
nself db ping
# Check migration status
nself db migrate:status
# Apply any pending migrations
nself db migrate:up
# Test seeding
nself db seed --fresh# Rebuild with new configuration
nself build
# Start services
nself up
# Check service status
nself status
# Test API endpoints
curl http://localhost:8080/v1/graphql \
-H "Content-Type: application/json" \
-d '{"query": "query { __schema { queryType { name } } }"}'
# Test database connectivity
nself db ping# If automatic migration fails
nself migrate --force --from v0.1 --to v0.2
# Or manual migration
nself init --template minimal
# Then manually copy your settings# If schema generation fails
nself db generate:from-database --force
# Or create schema manually based on your existing tables
nself db init --template custom# Validate configuration
nself config validate
# Check for missing variables
nself config check --migration
# Compare with example
nself config generate --template .env.exampleIf migration fails or causes issues, you can rollback:
# Stop current services
nself down
# Restore backup
rm -rf ./*
cp -r /path/to/backup/* ./
# Downgrade nself CLI if needed
nself update --version v0.1.x
# Restore database from backup
nself db restore --name pre-migration-backupAfter successful migration, consider adopting new v0.2.0 features:
# Remove backup files after successful migration
rm .env.v0.1.backup
rm -rf project-v0.1-backup/
# Clean up old configurations
nself config clean --remove-deprecated
# Optimize configuration for v0.2.0
nself config optimizeIf you encounter issues during migration:
--debug flagmigration.log fileAfter migration, nself generates a report:
# View migration summary
cat MIGRATION.md
# Generate detailed report
nself migrate --report
# Export migration metrics
nself migrate --export-metrics migration-metrics.jsonAfter successful migration to v0.2.0:
The migration to v0.2.0 unlocks powerful new database management capabilities and enhanced developer experience. Take time to explore the new features and optimize your configuration.