readFunctionsHash method
Reads the deployed Edge Function bundle hash from _schema_meta.
Returns:
nullif the table/column does not exist (pre-migration-059 legacy) or if the column has not been written yet (fresh bootstrap before the provisioner records the hash, e.g. manual fallback users who never deployed functions).- The SHA-256 string otherwise.
The app compares this against schemaExpectedVersion's sibling
constant functionsBundleHash. A mismatch means the bundled app has
newer Edge Function source than what is deployed on the user's
project, and the Settings banner prompts the user to re-enter their
access token to redeploy.
Implementation
Future<String?> readFunctionsHash() async {
try {
final row = await _client
.from('_schema_meta')
.select('functions_hash')
.maybeSingle();
if (row == null) return null;
final value = row['functions_hash'];
if (value is String && value.isNotEmpty) return value;
return null;
} on PostgrestException catch (e) {
dev.log(
describePostgrestException(e),
name: 'SchemaMigrator.readFunctionsHash',
);
// 42703 = column missing (pre-migration-059 legacy). Table-missing
// cases are handled by the shared helper.
if (isMissingSchemaError(e) || e.code == '42703') return null;
rethrow;
}
}