MCPcopy Index your code
hub / github.com/docker/docker-agent / GetAppliedMigrations

Method GetAppliedMigrations

pkg/session/migrations.go:184–214  ·  view source on GitHub ↗

GetAppliedMigrations returns a list of applied migrations

(ctx context.Context)

Source from the content-addressed store, hash-verified

182
183// GetAppliedMigrations returns a list of applied migrations
184func (m *MigrationManager) GetAppliedMigrations(ctx context.Context) ([]Migration, error) {
185 rows, err := m.db.QueryContext(ctx, "SELECT id, name, description, applied_at FROM migrations ORDER BY id")
186 if err != nil {
187 return nil, err
188 }
189 defer rows.Close()
190
191 var migrations []Migration
192 for rows.Next() {
193 var migration Migration
194 var appliedAtStr string
195
196 err := rows.Scan(&migration.ID, &migration.Name, &migration.Description, &appliedAtStr)
197 if err != nil {
198 return nil, err
199 }
200
201 migration.AppliedAt, err = time.Parse(time.RFC3339, appliedAtStr)
202 if err != nil {
203 return nil, err
204 }
205
206 migrations = append(migrations, migration)
207 }
208
209 if err := rows.Err(); err != nil {
210 return nil, err
211 }
212
213 return migrations, nil
214}
215
216// getAllMigrations returns all available migrations in order
217func getAllMigrations() []Migration {

Calls 5

QueryContextMethod · 0.80
ParseMethod · 0.80
CloseMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65