buildDescriptors static method

List<MigrationDescriptor> buildDescriptors(
  1. List<MigrationEntry> entries
)

Convert a list of entries to migration descriptors.

Migrations are sorted by their ID timestamp (oldest first), ensuring they run in the correct dependency order.

Implementation

static List<MigrationDescriptor> buildDescriptors(
  List<MigrationEntry> entries,
) {
  // Sort by timestamp (oldest first)
  final sorted = List<MigrationEntry>.from(entries)
    ..sort((a, b) => a.id.timestamp.compareTo(b.id.timestamp));

  return List.unmodifiable(
    sorted.map(
      (entry) => MigrationDescriptor.fromMigration(
        id: entry.id,
        migration: entry.migration,
      ),
    ),
  );
}