From 764bd28d08ceaef03cd4050f9568a62d77bbcfca Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 15 Jan 2026 03:37:44 +0000 Subject: Add repository history feature to store and suggest previously used repositories (#18) - Add repository_history table migration with repo_type, repo_path, use_count, last_used_at - Add RepositoryHistoryEntry model and CRUD database functions - Create API endpoints: GET/POST/DELETE /api/v1/repository-history, GET /api/v1/repository-history/suggestions - Update add_remote_repository and add_local_repository handlers to automatically track history - Update frontend API with repository history types and functions - Add Repository History section to Settings page with list of entries and delete functionality - Add suggestions dropdown to RepositoryPanel when entering new repository URL/path - Suggestions filter by repo type (remote vs local) and match on user input Test plan: - Add a remote repository to a contract - verify it appears in Settings history - Add a local repository to a contract - verify it appears in Settings history - Add same repository again - verify use_count increments, not duplicate - When adding new repository, verify suggestions appear based on history - Delete a history entry from Settings - verify it's removed - Verify suggestions only show matching type (remote for remote, local for local) Co-authored-by: Claude Opus 4.5 --- .../20250116000000_create_repository_history.sql | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 makima/migrations/20250116000000_create_repository_history.sql (limited to 'makima/migrations') diff --git a/makima/migrations/20250116000000_create_repository_history.sql b/makima/migrations/20250116000000_create_repository_history.sql new file mode 100644 index 0000000..7fb6920 --- /dev/null +++ b/makima/migrations/20250116000000_create_repository_history.sql @@ -0,0 +1,31 @@ +-- Repository history table for storing and suggesting previously used repositories +-- Used to track repositories across contracts and provide suggestions when adding new repos + +CREATE TABLE IF NOT EXISTS repository_history ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + owner_id UUID NOT NULL REFERENCES owners(id) ON DELETE CASCADE, + name VARCHAR(255) NOT NULL, + repository_url VARCHAR(512), -- For remote repos + local_path VARCHAR(512), -- For local repos + source_type VARCHAR(32) NOT NULL, -- 'remote' or 'local' + use_count INTEGER NOT NULL DEFAULT 1, + last_used_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Index for efficient owner lookups +CREATE INDEX idx_repository_history_owner_id ON repository_history(owner_id); + +-- Index for filtering by source type +CREATE INDEX idx_repository_history_source_type ON repository_history(source_type); + +-- Index for ordering by use_count and last_used_at +CREATE INDEX idx_repository_history_usage ON repository_history(owner_id, use_count DESC, last_used_at DESC); + +-- Unique constraint per owner + source_type + (url or path) +-- This prevents duplicates while allowing the same URL to be tracked by different owners +CREATE UNIQUE INDEX idx_repository_history_unique_remote + ON repository_history(owner_id, repository_url) WHERE source_type = 'remote' AND repository_url IS NOT NULL; + +CREATE UNIQUE INDEX idx_repository_history_unique_local + ON repository_history(owner_id, local_path) WHERE source_type = 'local' AND local_path IS NOT NULL; -- cgit v1.2.3