Migration constructor

Migration({
  1. required int version,
  2. required String name,
  3. required Engine engine,
  4. required List<String> steps,
  5. required SchemaSnapshot snapshot,
  6. required String reviewedFingerprint,
})

Implementation

Migration({
  required this.version,
  required this.name,
  required this.engine,
  required List<String> steps,
  required SchemaSnapshot snapshot,
  required this.reviewedFingerprint,
}) : steps = List.unmodifiable(steps),
     snapshot = freezeSnapshot(snapshot) {
  if (version < 1 || name.trim().isEmpty) {
    throw ArgumentError('Migration needs a positive version and a name.');
  }
  if (engine != snapshot.engine) {
    throw ArgumentError('Migration and snapshot engines differ.');
  }
  if (steps.any((step) => step.trim().isEmpty)) {
    throw ArgumentError('Migration SQL steps must not be empty.');
  }
  if (fingerprint != reviewedFingerprint) {
    throw StateError(
      'Migration $version does not match its reviewed fingerprint.',
    );
  }
}