Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 298c44e9a9 Fix entrypoint to run pending TypeORM migrations before upgrade command
https://sonarly.com/issue/29608?type=bug

Self-hosted users upgrading from v1.21.0 to v2.0.0 via docker-compose hit an unrecoverable boot deadlock: the `upgrade` command queries the `isInitial` column on `upgradeMigration` which doesn't exist until a TypeORM migration runs, but the entrypoint never runs TypeORM migrations for existing databases.

Fix: Added `yarn database:migrate:prod --force --include-slow` to the Docker entrypoint before `yarn command:prod upgrade`. This ensures pending TypeORM migrations (including `AddIsInitialToUpgradeMigration1775909335324` which adds the `isInitial` column) and all instance commands are applied before the upgrade sequence runner queries the `upgradeMigration` table.

`database:migrate:prod` is aliased to `run-instance-commands` in package.json, which:
1. Runs all pending legacy TypeORM migrations (creates the `isInitial` column)
2. Runs all registered fast and slow instance commands in sequence

The `--force` flag bypasses the workspace version safety check that would otherwise fail for cross-version upgrades (v1.21 workspaces haven't completed v1.23 workspace commands). The `--include-slow` flag ensures slow instance commands (with data migrations) also run.

For databases already at v2.0.0 or later, this is a no-op — TypeORM migrations are already applied and instance commands are already recorded as completed.

This restores the behavior that existed before the cross-version upgrade refactor removed the bootstrap migration code from the upgrade command itself.
2026-04-21 23:17:46 +00:00
@@ -16,6 +16,7 @@ setup_and_migrate_db() {
yarn database:init:prod
fi
yarn database:migrate:prod --force --include-slow
yarn command:prod cache:flush
yarn command:prod upgrade
yarn command:prod cache:flush