canMigrateTo method

bool canMigrateTo(
  1. ColumnDefinition other
)

Whether this column can be altered in place to match other.

This method ignores the physical name of the column.

Implementation

bool canMigrateTo(ColumnDefinition other) {
  // It's ok to change column default or nullability.
  if (other.dartType != null &&
      dartType != null &&
      !_canMigrateType(dartType!, other.dartType!)) {
    return false;
  }

  // Vector dimension changes require dropping and recreating the column.
  if (vectorDimension != other.vectorDimension) {
    return false;
  }

  const jsonEquivalentTypes = {ColumnType.json, ColumnType.jsonb};
  if (jsonEquivalentTypes.contains(columnType) &&
      jsonEquivalentTypes.contains(other.columnType)) {
    return true;
  }

  return other.columnType == columnType;
}