╔══════════════════════════════════════════════════════════════════════╗ ║ TENANT MIGRATION - QUICK REFERENCE ║ ╚══════════════════════════════════════════════════════════════════════╝ 📍 LOCATION: /root/neo/backend ┌─────────────────────────────────────────────────────────────────────┐ │ COMMON COMMANDS │ └─────────────────────────────────────────────────────────────────────┘ Create Migration: $ npm run migrate:make add_my_feature Check Status: $ npm run migrate:status Test on One Tenant: $ npm run migrate:tenant acme-corp Apply to All Tenants: $ npm run migrate:all-tenants ┌─────────────────────────────────────────────────────────────────────┐ │ ALL AVAILABLE COMMANDS │ └─────────────────────────────────────────────────────────────────────┘ npm run migrate:make Create new migration file npm run migrate:status Check status across all tenants npm run migrate:tenant Migrate specific tenant npm run migrate:all-tenants Migrate all active tenants npm run migrate:latest Migrate default DB (rarely used) npm run migrate:rollback Rollback default DB (rarely used) ┌─────────────────────────────────────────────────────────────────────┐ │ TYPICAL WORKFLOW │ └─────────────────────────────────────────────────────────────────────┘ 1. Create: npm run migrate:make add_priority_field 2. Edit: vim migrations/tenant/20250127_*.js 3. Test: npm run migrate:tenant test-company 4. Status: npm run migrate:status 5. Deploy: npm run migrate:all-tenants ┌─────────────────────────────────────────────────────────────────────┐ │ ENVIRONMENT REQUIRED │ └─────────────────────────────────────────────────────────────────────┘ export DB_ENCRYPTION_KEY="your-32-character-secret-key!!" ┌─────────────────────────────────────────────────────────────────────┐ │ FILE LOCATIONS │ └─────────────────────────────────────────────────────────────────────┘ Scripts: backend/scripts/migrate-*.ts Migrations: backend/migrations/tenant/ Config: backend/knexfile.js Docs: TENANT_MIGRATION_GUIDE.md ┌─────────────────────────────────────────────────────────────────────┐ │ DOCUMENTATION │ └─────────────────────────────────────────────────────────────────────┘ Quick Guide: cat TENANT_MIGRATION_GUIDE.md Script Docs: cat backend/scripts/README.md Complete: cat TENANT_MIGRATION_IMPLEMENTATION_COMPLETE.md ┌─────────────────────────────────────────────────────────────────────┐ │ TROUBLESHOOTING │ └─────────────────────────────────────────────────────────────────────┘ Missing Prisma Client: $ npx prisma generate --schema=prisma/schema-central.prisma Check Scripts Available: $ npm run | grep migrate Connection Error: - Check DB_ENCRYPTION_KEY matches encryption key - Verify central database is accessible - Ensure tenant databases are online ╔══════════════════════════════════════════════════════════════════════╗ ║ For detailed help: cat TENANT_MIGRATION_GUIDE.md ║ ╚══════════════════════════════════════════════════════════════════════╝