summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-02-03 08:11:09 +0100
committerRory& <root@rory.gay>2026-02-03 08:11:09 +0100
commit44b6043099a4650afb5273fcd282f0ad87c97d63 (patch)
treedaf72fcda0e0060c7bc6ecc1918430f0f807d67a
parentUpdate schemas for profile customisation (diff)
downloadserver-ts-44b6043099a4650afb5273fcd282f0ad87c97d63.tar.xz
Env var to disable db migrations, nix: drop pre-start service
-rw-r--r--nix/modules/default/default.nix30
-rw-r--r--src/util/util/Database.ts6
2 files changed, 6 insertions, 30 deletions
diff --git a/nix/modules/default/default.nix b/nix/modules/default/default.nix

index 5632bf7a..ea541b97 100644 --- a/nix/modules/default/default.nix +++ b/nix/modules/default/default.nix
@@ -235,32 +235,8 @@ in # } ]; - systemd.services.spacebar-apply-migrations = makeServerTsService { - description = "Spacebar Server - Apply DB migrations"; - # after = lib.optional config.services.postgresql.enable "postgresql.service"; - # requires = lib.optional config.services.postgresql.enable "postgresql.service"; - environment = builtins.mapAttrs (_: val: builtins.toString val) ( - cfg.extraEnvironment - // { - # things we force... - CONFIG_PATH = configFile; - CONFIG_READONLY = 1; - } - ); - serviceConfig = { - ExecStart = "${cfg.package}/bin/apply-migrations"; - Type = "oneshot"; - RemainAfterExit = true; - TimeoutStartSec = 45; - RestartSec = 1; - StartLimitBurst = 10; - }; - }; - systemd.services.spacebar-api = makeServerTsService { description = "Spacebar Server - API"; - after = [ "spacebar-apply-migrations.service" ]; - requires = [ "spacebar-apply-migrations.service" ]; environment = builtins.mapAttrs (_: val: builtins.toString val) ( { # things we set by default... @@ -283,8 +259,6 @@ in systemd.services.spacebar-gateway = makeServerTsService { description = "Spacebar Server - Gateway"; - after = [ "spacebar-apply-migrations.service" ]; - requires = [ "spacebar-apply-migrations.service" ]; environment = builtins.mapAttrs (_: val: builtins.toString val) ( { # things we set by default... @@ -298,6 +272,7 @@ in CONFIG_READONLY = 1; PORT = toString cfg.gatewayEndpoint.localPort; STORAGE_LOCATION = cfg.cdnPath; + APPLY_DB_MIGRATIONS = false; } ); serviceConfig = { @@ -307,8 +282,6 @@ in systemd.services.spacebar-cdn = lib.mkIf (!cfg.enableCdnCs) (makeServerTsService { description = "Spacebar Server - CDN"; - after = [ "spacebar-apply-migrations.service" ]; - requires = [ "spacebar-apply-migrations.service" ]; environment = builtins.mapAttrs (_: val: builtins.toString val) ( { # things we set by default... @@ -322,6 +295,7 @@ in CONFIG_READONLY = 1; PORT = toString cfg.cdnEndpoint.localPort; STORAGE_LOCATION = cfg.cdnPath; + APPLY_DB_MIGRATIONS = false; } ); serviceConfig = { diff --git a/src/util/util/Database.ts b/src/util/util/Database.ts
index 95ced311..13bcf3cc 100644 --- a/src/util/util/Database.ts +++ b/src/util/util/Database.ts
@@ -132,8 +132,10 @@ export async function initDatabase(): Promise<DataSource> { await qr.release(); } - console.log("[Database] Applying missing migrations, if any."); - await dbConnection.runMigrations(); + if (process.env.APPLY_DB_MIGRATIONS !== "false") { + console.log("[Database] Applying missing migrations, if any."); + await dbConnection.runMigrations(); + } console.log(`[Database] ${green("Connected")}`);