Migration constructor
Migration({})
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.',
);
}
}