(ctx context.DnoteCtx, schemaKey string)
| 80 | } |
| 81 | |
| 82 | func 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 | |
| 100 | func execute(ctx context.DnoteCtx, m migration, schemaKey string) error { |
| 101 | log.Debug("running migration %s\n", m.name) |
no test coverage detected