MCPcopy
hub / github.com/modelcontextprotocol/registry / getAppliedMigrations

Method getAppliedMigrations

internal/database/migrate.go:51–69  ·  view source on GitHub ↗

getAppliedMigrations returns a map of already applied migration versions

(ctx context.Context)

Source from the content-addressed store, hash-verified

49
50// getAppliedMigrations returns a map of already applied migration versions
51func (m *Migrator) getAppliedMigrations(ctx context.Context) (map[int]bool, error) {
52 query := "SELECT version FROM schema_migrations ORDER BY version"
53 rows, err := m.conn.Query(ctx, query)
54 if err != nil {
55 return nil, fmt.Errorf("failed to query applied migrations: %w", err)
56 }
57 defer rows.Close()
58
59 applied := make(map[int]bool)
60 for rows.Next() {
61 var version int
62 if err := rows.Scan(&version); err != nil {
63 return nil, fmt.Errorf("failed to scan migration version: %w", err)
64 }
65 applied[version] = true
66 }
67
68 return applied, rows.Err()
69}
70
71// loadMigrations loads all migration files from the embedded filesystem
72func (m *Migrator) loadMigrations() ([]Migration, error) {

Callers 1

MigrateMethod · 0.95

Calls 2

QueryMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected