MCPcopy Index your code
hub / github.com/coder/coder / currentMigrationVersion

Function currentMigrationVersion

scripts/develop/dbrecovery.go:618–635  ·  view source on GitHub ↗
(ctx context.Context, db *sql.DB)

Source from the content-addressed store, hash-verified

616}
617
618func currentMigrationVersion(ctx context.Context, db *sql.DB) (int, bool, error) {
619 var version int
620 var dirty bool
621 err := db.QueryRowContext(ctx,
622 `SELECT version, dirty FROM schema_migrations LIMIT 1`,
623 ).Scan(&version, &dirty)
624 if err != nil {
625 if errors.Is(err, sql.ErrNoRows) {
626 return -1, false, nil
627 }
628 var pgErr *pq.Error
629 if xerrors.As(err, &pgErr) && pgErr.Code.Name() == "undefined_table" {
630 return -1, false, nil
631 }
632 return -1, false, xerrors.Errorf("query schema_migrations: %w", err)
633 }
634 return version, dirty, nil
635}
636
637func formatVersions(rollbacks []rollbackEntry) string {
638 var parts []string

Callers 2

checkAndRecoverFunction · 0.85
updateMigrationTrackingFunction · 0.85

Calls 6

QueryRowContextMethod · 0.80
AsMethod · 0.80
NameMethod · 0.65
ScanMethod · 0.45
IsMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected