nixos-module: run db migrations on every activation, not just once

The .initial-migration marker file prevented `migrate --force` from ever
running again after the first activation, so migrations shipped by a later
invoiceninja version upgrade would never apply to an already-deployed
instance. `migrate` is idempotent (Laravel tracks applied migrations in the
DB), so just run it unconditionally on every activation instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 13:15:00 -04:00
co-authored by Claude Sonnet 5
parent bd112541e5
commit 2c9915699d
3 changed files with 15 additions and 8 deletions
+5 -2
View File
@@ -702,8 +702,11 @@ in
# We cannot link the cache folder only because bootstrap folder needs to be writeable.
ln -sf ${invoiceninja}/bootstrap-static/app.php ${cfg.runtimeDir}/app.php
# Perform the first migration
[[ ! -f ${cfg.dataDir}/.initial-migration ]] && invoiceninja-manage migrate --force && touch ${cfg.dataDir}/.initial-migration
# Run migrations on every activation, not just the first: `migrate` is idempotent
# (Laravel tracks applied migrations in the DB and only runs new ones), and gating this
# behind a marker file meant migrations shipped by a later invoiceninja version upgrade
# would never run.
invoiceninja-manage migrate --force
# Seed database with records
# Necessary for languages, currencies, countries, etc.