Init creates metadata tables if they do not exist and runs idempotent migrations.
(ctx context.Context)
| 32 | |
| 33 | // Init creates metadata tables if they do not exist and runs idempotent migrations. |
| 34 | func (s *Store) Init(ctx context.Context) error { |
| 35 | db, err := s.open() |
| 36 | if err != nil { |
| 37 | return err |
| 38 | } |
| 39 | defer db.Close() |
| 40 | if _, err = db.ExecContext(ctx, schemaSQL); err != nil { |
| 41 | return fmt.Errorf("metadata: init schema: %w", err) |
| 42 | } |
| 43 | if err := s.runMigrations(ctx, db); err != nil { |
| 44 | return fmt.Errorf("metadata: migrations: %w", err) |
| 45 | } |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | // UpsertItem inserts or updates a metadata item by (kind, install_key). |
| 50 | func (s *Store) UpsertItem(ctx context.Context, item Item) error { |