# 26th October 2024 — Server-side database migration system [#68](https://github.com/nbarrett/ngx-ramblers/issues/68)
## [build 333](https://github.com/nbarrett/ngx-ramblers/actions/runs/18823789797) — [refs #68](https://github.com/nbarrett/ngx-ramblers/issues/68) — [commit 52ec96f](https://github.com/nbarrett/ngx-ramblers/commit/52ec96f)

A comprehensive server-side migration management system using [migrate-mongo](https://github.com/seppevs/migrate-mongo), allowing administrators to simulate, monitor, and control database migrations through the admin interface with persistent simulation mode, real-time WebSocket progress tracking, and protective route guards.

**Where to Find It**

- **Admin → Maintenance**: Migration management interface with simulation controls
- **Route Protection**: Automatic access blocking when migrations are pending or failed

**Benefits**
- **Safe Testing**: Simulation mode allows testing migrations without affecting production data
- **Real-Time Monitoring**: WebSocket integration provides live updates during execution
- **Automatic Protection**: Route guards prevent system access during migration issues
- **Persistent State**: Simulation state persists across server restarts for reliable testing
- **Health Integration**: System health checks reflect migration status


_View of successfully applied database migrations_


![](https://ngx-ramblers.org.uk/api/aws/s3/site-content/b5864df5-8051-4d58-84c4-2966ddd29c89.jpeg)

_View of simulation of failed database migrations_


![](https://ngx-ramblers.org.uk/api/aws/s3/site-content/282130a5-6da1-4091-9b20-9a1b30ab1412.jpeg)

_View of maintenance page from non-logged in  perspective_


![](https://ngx-ramblers.org.uk/api/aws/s3/site-content/f3c36638-e801-4e2c-aa6b-bbe297834429.jpeg)


## Centralise environment variables (refs [#68](https://github.com/nbarrett/ngx-ramblers/issues/68)) ([b93c69b](https://github.com/nbarrett/ngx-ramblers/commit/b93c69b))

Environment configuration refactored with type-safe enum, migration system enhancements for database-driven status, and improved health monitoring. Migration file detection now excludes TypeScript declaration files and provides consistent status across all environments.

**Benefits**

- **Type Safety**: Environment variables use TypeScript enums with IDE autocomplete
- **Deployment Reliability**: Server starts even when NODE_ENV not explicitly set (defaults to "development")
- **Consistent Migration Display**: Database-driven status shows same files locally and in production
- **Improved Monitoring**: Health checks accurately reflect migration state for automated alerts
- **Cleaner Logs**: TypeScript declaration files no longer incorrectly identified as migrations
- **Better Maintainability**: Centralised environment variable definitions
- **Database-Driven Status**: Migration state purely from database, independent of environment
- **Improved File Detection**: Filters exclude .d.ts and .d.js files, normalise .ts/.js handling
