This guide helps you migrate from nself v0.1.x to v0.2.0, which includes significant new features and some breaking changes. The migration process is largely automated, but requires your review and approval.
Before starting the migration, create a complete backup of your project and data. The migration process modifies configuration files and directory structure.
database/
directoryExpected migration time: 15-30 minutes for most projects
# Update to latest version
nself update
# Verify version
nself --version
# Should show v0.2.0 or later
# Create complete project backup
cp -r /path/to/your/project /path/to/backup/project-v0.1-backup
# Export database
nself db backup --name pre-migration-backup
# Backup configuration
cp .env.local .env.v0.1.backup
# Navigate to your project
cd /path/to/your/project
# Run migration (dry-run first to see what will change)
nself migrate --from v0.1 --to v0.2 --dry-run
# Review the proposed changes, then run actual migration
nself migrate --from v0.1 --to v0.2
# Alternative: Interactive migration with prompts
nself migrate --interactive
The migration creates several new files and directories:
your-project/
├── database/ # NEW: Database management
│ ├── schema.dbml # Your database schema
│ ├── migrations/ # Generated migrations
│ └── seeds/ # Seed data
│ ├── development/
│ ├── staging/
│ └── production/
├── .env.local # Updated with new variables
├── .env.v0.1.backup # Your original config
└── MIGRATION.md # Migration summary
Some 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=auto
The 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.sql
If 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=3
Check 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.example
If 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-backup
After 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 optimize
If 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.json
After 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.