feat: CheckSnapshots y UpdateSnapshot en fn_operations library
Añade UpdateTypeSnapshot al store, CheckSnapshots para comparar snapshots locales vs registry (up_to_date/outdated/missing), y UpdateSnapshot para re-snapshot con retorno de old/new para diffing.
This commit is contained in:
@@ -58,6 +58,20 @@ func (db *DB) InsertTypeSnapshot(ts *TypeSnapshot) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateTypeSnapshot replaces an existing snapshot with a new version.
|
||||
func (db *DB) UpdateTypeSnapshot(ts *TypeSnapshot) error {
|
||||
if ts.SnappedAt.IsZero() {
|
||||
ts.SnappedAt = time.Now().UTC()
|
||||
}
|
||||
_, err := db.conn.Exec(`
|
||||
UPDATE types_snapshot SET version=?, lang=?, algebraic=?, definition=?, description=?, snapped_at=?
|
||||
WHERE id=?`,
|
||||
ts.Version, ts.Lang, ts.Algebraic, ts.Definition, ts.Description,
|
||||
ts.SnappedAt.Format(time.RFC3339), ts.ID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
// GetTypeSnapshot returns a type snapshot by ID.
|
||||
func (db *DB) GetTypeSnapshot(id string) (*TypeSnapshot, error) {
|
||||
row := db.conn.QueryRow("SELECT id, version, lang, algebraic, definition, description, snapped_at FROM types_snapshot WHERE id = ?", id)
|
||||
|
||||
Reference in New Issue
Block a user