Schema: public_id + version columns with UNIQUE constraint, delete_timestamp for soft-delete. Tools: store_flashcard accepts optional public_id, update_flashcard creates a new version preserving history, delete_flashcard inserts a tombstone row and removes the Qdrant point. Qdrant: point ID is public_id (only latest version indexed).
19 lines
420 B
SQL
19 lines
420 B
SQL
-- +goose Up
|
|
CREATE TABLE IF NOT EXISTS flashcard (
|
|
_id INTEGER PRIMARY KEY,
|
|
public_id INTEGER NOT NULL,
|
|
version INTEGER NOT NULL DEFAULT 1,
|
|
note TEXT NOT NULL,
|
|
repos TEXT,
|
|
host TEXT,
|
|
tags TEXT,
|
|
"user" TEXT,
|
|
context TEXT,
|
|
delete_timestamp TEXT,
|
|
created TEXT NOT NULL DEFAULT (datetime('now')),
|
|
UNIQUE(public_id, version)
|
|
);
|
|
|
|
-- +goose Down
|
|
DROP TABLE IF EXISTS flashcard;
|