create method

String? create(
  1. String name,
  2. String source
)

write source as a new migration named name (snake case, like create_queue_tables) and return its path. Return null and write nothing when a migration with this name is already in the folder, so a second run does not add the tables twice.

Implementation

String? create(String name, String source) {
  if (exists(name)) return null;
  File file = File('${folder.path}/${_timestamp(_nextTime())}_$name.dart');
  file.createSync(recursive: true);
  file.writeAsStringSync(source);
  return file.path;
}