feat: Add metadata table for internal state storage
The other agent added a metadata table for storing internal state
like import hashes. This is separate from the config table which
is for user-facing configuration.
🤖 Generated by other agent
This commit is contained in:
@@ -72,6 +72,12 @@ CREATE TABLE IF NOT EXISTS config (
|
|||||||
value TEXT NOT NULL
|
value TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Metadata table (for storing internal state like import hashes)
|
||||||
|
CREATE TABLE IF NOT EXISTS metadata (
|
||||||
|
key TEXT PRIMARY KEY,
|
||||||
|
value TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
-- Dirty issues table (for incremental JSONL export)
|
-- Dirty issues table (for incremental JSONL export)
|
||||||
-- Tracks which issues have changed since last export
|
-- Tracks which issues have changed since last export
|
||||||
CREATE TABLE IF NOT EXISTS dirty_issues (
|
CREATE TABLE IF NOT EXISTS dirty_issues (
|
||||||
|
|||||||
@@ -662,6 +662,25 @@ func (s *SQLiteStorage) GetConfig(ctx context.Context, key string) (string, erro
|
|||||||
return value, err
|
return value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMetadata sets a metadata value (for internal state like import hashes)
|
||||||
|
func (s *SQLiteStorage) SetMetadata(ctx context.Context, key, value string) error {
|
||||||
|
_, err := s.db.ExecContext(ctx, `
|
||||||
|
INSERT INTO metadata (key, value) VALUES (?, ?)
|
||||||
|
ON CONFLICT (key) DO UPDATE SET value = excluded.value
|
||||||
|
`, key, value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMetadata gets a metadata value (for internal state like import hashes)
|
||||||
|
func (s *SQLiteStorage) GetMetadata(ctx context.Context, key string) (string, error) {
|
||||||
|
var value string
|
||||||
|
err := s.db.QueryRowContext(ctx, `SELECT value FROM metadata WHERE key = ?`, key).Scan(&value)
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
// Close closes the database connection
|
// Close closes the database connection
|
||||||
func (s *SQLiteStorage) Close() error {
|
func (s *SQLiteStorage) Close() error {
|
||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ type Storage interface {
|
|||||||
SetConfig(ctx context.Context, key, value string) error
|
SetConfig(ctx context.Context, key, value string) error
|
||||||
GetConfig(ctx context.Context, key string) (string, error)
|
GetConfig(ctx context.Context, key string) (string, error)
|
||||||
|
|
||||||
|
// Metadata (for internal state like import hashes)
|
||||||
|
SetMetadata(ctx context.Context, key, value string) error
|
||||||
|
GetMetadata(ctx context.Context, key string) (string, error)
|
||||||
|
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user