detectSchemaChanges method

bool detectSchemaChanges(
  1. List<SupabaseTableInfo> currentTables
)

Compares the current table list against the last known version.

Implementation

bool detectSchemaChanges(List<SupabaseTableInfo> currentTables) {
  final List<SupabaseTableInfo>? previousSchemaTables =
      previousSchemaStates[currentSchemaVersion];

  if (previousSchemaTables == null) {
    // No previous schema at the current version, so definitely changed (it's new or first load)
    return true;
  }

  // Simple comparison based on JSON representation
  final currentJson = JsonEncoder().convert(
    currentTables.map((t) => t.toJson()).toList(),
  );
  final previousJson = JsonEncoder().convert(
    previousSchemaTables.map((t) => t.toJson()).toList(),
  );

  if (currentJson != previousJson) {
    _logger.fine(
      'Schema JSON representation differs from previous version $currentSchemaVersion.',
    );
    // Add more detailed diff logging here if needed
    return true;
  }

  return false;
}