functionsOutOfSyncFromMeta function

bool functionsOutOfSyncFromMeta({
  1. required int? schemaVersion,
  2. required String? deployedHash,
  3. required String bundledHash,
})

Pure decision function, exposed for unit tests.

Given the deployed schema's version and the value of _schema_meta.functions_hash on the user's project, returns true when the Settings banner should prompt the user to redeploy.

Semantics:

  • version < 59 (or unknown): return false. The schema is not yet at the version that adds the functions_hash column; the incremental migration runner will catch it up shortly, and a banner at this point would trigger a dialog that immediately fails when it tries to write to a non-existent column.
  • version >= 59 and deployedHash is null or empty: return true. This is the legacy-BYO case — the user bootstrapped before this feature shipped, migration 059 has just added the column, but the hash has never been written because the user has never deployed Edge Functions through the new dialog.
  • version >= 59 and deployedHash != bundledHash: return true. Stale deployment from a previous app release.
  • version >= 59 and deployedHash == bundledHash: return false.

Implementation

bool functionsOutOfSyncFromMeta({
  required int? schemaVersion,
  required String? deployedHash,
  required String bundledHash,
}) {
  if (schemaVersion == null || schemaVersion < _functionsHashMinVersion) {
    return false;
  }
  if (deployedHash == null || deployedHash.isEmpty) return true;
  return deployedHash != bundledHash;
}