MigrationLog class final
A record of a single migration execution.
Each log entry captures the details of a migration step including the versions involved, timing, outcome, and any error information.
Example
final log = MigrationLog(
timestamp: DateTime.now(),
fromVersion: '1.0.0',
toVersion: '1.1.0',
outcome: MigrationOutcome.success,
durationMs: 1250,
);
// Serialize for storage
final json = log.toMap();
// Deserialize
final restored = MigrationLog.fromMap(json);
Constructors
-
MigrationLog({required DateTime timestamp, required String fromVersion, required String toVersion, required MigrationOutcome outcome, bool isUpgrade = true, int? durationMs, int? entitiesAffected, String? error, String? stackTrace, Map<
String, dynamic> ? metadata}) -
Creates a new migration log entry.
const
-
MigrationLog.failed({required String fromVersion, required String toVersion, required String error, String? stackTrace, int? durationMs, bool isUpgrade = true, Map<
String, dynamic> ? metadata}) -
Creates a log entry for a failed migration.
factory
-
MigrationLog.fromMap(Map<
String, dynamic> map) -
Deserializes a log entry from a map.
factory
- MigrationLog.skipped({required String fromVersion, required String toVersion, String? reason, bool isUpgrade = true})
-
Creates a log entry for a skipped migration.
factory
-
MigrationLog.success({required String fromVersion, required String toVersion, required int durationMs, int? entitiesAffected, bool isUpgrade = true, Map<
String, dynamic> ? metadata}) -
Creates a log entry for a successful migration.
factory
Properties
- durationMs → int?
-
Duration of the migration in milliseconds.
final
- entitiesAffected → int?
-
Number of entities affected by the migration.
final
- error → String?
-
Error message if the migration failed.
final
- fromVersion → String
-
The schema version before migration.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFailed → bool
-
Whether the migration failed.
no setter
- isSuccess → bool
-
Whether the migration was successful.
no setter
- isUpgrade → bool
-
Whether this was an upgrade (true) or downgrade (false).
final
-
metadata
→ Map<
String, dynamic> ? -
Additional metadata about the migration.
final
- outcome → MigrationOutcome
-
The outcome of the migration.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stackTrace → String?
-
Stack trace if the migration failed.
final
- timestamp → DateTime
-
When the migration was executed.
final
- toVersion → String
-
The schema version after migration.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> - Serializes this log entry to a map.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited