errorMessages property Null safety

List<String> errorMessages

Human-readable list of differences between expectedColumnNames and actualColumnNames.

Implementation

List<String> get errorMessages {
  if (expectedColumnNames.isEmpty && actualColumnNames.isNotEmpty) {
    return [
      "Multi-column unique constraint on table '$_tableName' "
          "should NOT exist, but is created by migration files."
    ];
  } else if (expectedColumnNames.isNotEmpty && actualColumnNames.isEmpty) {
    return [
      "Multi-column unique constraint on table '$_tableName' "
          "should exist, but it is NOT created by migration files."
    ];
  }

  if (hasDifferences) {
    var expectedColumns = expectedColumnNames.map((c) => "'$c'").join(", ");
    var actualColumns = actualColumnNames.map((c) => "'$c'").join(", ");

    return [
      "Multi-column unique constraint on table '$_tableName' "
          "is expected to be for properties $expectedColumns, but is actually $actualColumns"
    ];
  }

  return [];
}