SchemaTableDifference constructor

SchemaTableDifference(
  1. SchemaTable? expectedTable,
  2. SchemaTable? actualTable
)

Creates a new instance that represents the difference between expectedTable and actualTable.

Implementation

SchemaTableDifference(this.expectedTable, this.actualTable) {
  if (expectedTable != null && actualTable != null) {
    for (final expectedColumn in expectedTable!.columns) {
      final actualColumn =
          actualTable != null ? actualTable![expectedColumn.name] : null;
      if (actualColumn == null) {
        _differingColumns.add(SchemaColumnDifference(expectedColumn, null));
      } else {
        final diff = expectedColumn.differenceFrom(actualColumn);
        if (diff.hasDifferences) {
          _differingColumns.add(diff);
        }
      }
    }

    _differingColumns.addAll(
      actualTable!.columns
          .where((t) => expectedTable![t.name] == null)
          .map((unexpectedColumn) {
        return SchemaColumnDifference(null, unexpectedColumn);
      }),
    );

    uniqueSetDifference =
        SchemaTableUniqueSetDifference(expectedTable!, actualTable!);
  }
}