add method

dynamic add(
  1. SqliteMigration migration
)

Implementation

add(SqliteMigration migration) {
  assert(
      migrations.isEmpty || migrations.last.toVersion < migration.toVersion);

  final down = migration.downMigration;
  if (down != null) {
    if (migrations.isEmpty) {
      if (down.toVersion != 0) {
        throw MigrationError(
            'Down migration for first migration must have toVersion = 0');
      }
    } else {
      if (down.toVersion > migrations.last.toVersion) {
        throw MigrationError(
            'Down migration for ${migration.toVersion} must have a toVersion <= ${migrations.last.toVersion}');
      }
    }
  }

  migrations.add(migration);
}