MCPcopy Index your code
hub / github.com/dnote/dnote / Run

Function Run

pkg/cli/migrate/migrate.go:133–155  ·  view source on GitHub ↗

Run performs unrun migrations

(ctx context.DnoteCtx, migrations []migration, mode int)

Source from the content-addressed store, hash-verified

131
132// Run performs unrun migrations
133func Run(ctx context.DnoteCtx, migrations []migration, mode int) error {
134 schemaKey, err := getSchemaKey(mode)
135 if err != nil {
136 return errors.Wrap(err, "getting schema key")
137 }
138
139 schema, err := getSchema(ctx, schemaKey)
140 if err != nil {
141 return errors.Wrap(err, "getting the current schema")
142 }
143
144 log.Debug("%s: %d of %d\n", schemaKey, schema, len(migrations))
145
146 toRun := migrations[schema:]
147
148 for _, m := range toRun {
149 if err := execute(ctx, m, schemaKey); err != nil {
150 return errors.Wrap(err, "running migration")
151 }
152 }
153
154 return nil
155}

Callers 6

InitFunction · 0.92
generateSchemaFunction · 0.92
newRunFunction · 0.92
TestRun_nonfreshFunction · 0.85
TestRun_freshFunction · 0.85
TestRun_up_to_dateFunction · 0.85

Calls 4

DebugFunction · 0.92
getSchemaKeyFunction · 0.85
getSchemaFunction · 0.85
executeFunction · 0.85

Tested by 3

TestRun_nonfreshFunction · 0.68
TestRun_freshFunction · 0.68
TestRun_up_to_dateFunction · 0.68