loadHistory method

Future<List<PostgresqlMigrationRecord>> loadHistory(
  1. SessionExecutor executor
)

Loads the full migration history ordered by application time.

Implementation

Future<List<PostgresqlMigrationRecord>> loadHistory(
  pg.SessionExecutor executor,
) async {
  await ensureHistoryTable(executor);
  final rows = await _query(executor, '''
       SELECT name, applied_at, statement_count, kind, target_name,
         provider, checksum, before_schema, after_schema,
         warnings, rebuild_required
      FROM "$historyTableName"
      ORDER BY applied_at ASC, name ASC
    ''');

  return rows
      .map(
        (row) => PostgresqlMigrationRecord(
          name: row['name'] as String,
          appliedAt: _asDateTime(row['applied_at'])!,
          statementCount: _asInt(row['statement_count']),
          kind: _parseRecordKind(row['kind'] as String? ?? 'apply'),
          warnings: decodeMigrationWarnings(row['warnings'] as String?),
          rebuildRequired: _asBool(row['rebuild_required']),
          targetName: row['target_name'] as String?,
          provider: row['provider'] as String?,
          checksum: row['checksum'] as String?,
          beforeSchema: row['before_schema'] as String?,
          afterSchema: row['after_schema'] as String?,
        ),
      )
      .toList(growable: false);
}