MCPcopy
hub / github.com/dnote/dnote / getSchema

Function getSchema

pkg/cli/migrate/migrate.go:82–98  ·  view source on GitHub ↗
(ctx context.DnoteCtx, schemaKey string)

Source from the content-addressed store, hash-verified

80}
81
82func getSchema(ctx context.DnoteCtx, schemaKey string) (int, error) {
83 var ret int
84
85 db := ctx.DB
86 err := db.QueryRow("SELECT value FROM system where key = ?", schemaKey).Scan(&ret)
87 if err == sql.ErrNoRows {
88 ret, err = initSchema(ctx, schemaKey)
89
90 if err != nil {
91 return ret, errors.Wrap(err, "initializing schema")
92 }
93 } else if err != nil {
94 return ret, errors.Wrap(err, "querying schema")
95 }
96
97 return ret, nil
98}
99
100func execute(ctx context.DnoteCtx, m migration, schemaKey string) error {
101 log.Debug("running migration %s\n", m.name)

Callers 1

RunFunction · 0.85

Calls 2

initSchemaFunction · 0.85
QueryRowMethod · 0.65

Tested by

no test coverage detected