alterTableModify method Null safety

String alterTableModify(
  1. FieldDeclaration current,
  2. FieldDeclaration latest
)

Implementation

String alterTableModify(FieldDeclaration current, FieldDeclaration latest) {
  if (latest.fieldType.toLowerCase().startsWith('varchar') &&
      current.fieldType.toLowerCase().startsWith('varchar')) {
    return 'ALTER TABLE "$tableName" ALTER COLUMN "${current.fieldName}" TYPE "${current.fieldType}";';
  } else {
    var commands = [];
    commands.add(alterTableDropColumn(current));
    commands.add(alterTableAddColumn(current));
    return commands.join('\n');
  }
}