Migrations
Generating Migrations
# After modifying entities
npm run migration:generate:statuspages -- -n MigrationName
npm run migration:generate:alerting -- -n MigrationName
npm run migration:generate:synthetics -- -n MigrationName
Running Migrations
npm run migration:run:statuspages
npm run migration:run:alerting
npm run migration:run:synthetics
Reverting Migrations
npm run migration:revert:statuspages
SQL Migrations
For core schema or complex changes, use SQL files in migrations/:
-- migrations/009_create_users_table.sql
BEGIN;
CREATE TABLE IF NOT EXISTS core.users (...);
COMMIT;
Apply manually:
psql -h <host> -U statux_admin -d statux -f migrations/009_create_users_table.sql
Best Practices
- Test migrations locally before deploying
- Create database snapshot before production migrations
- Keep migrations idempotent (
IF NOT EXISTS,ON CONFLICT DO NOTHING)