Clean slate initialization of Goondex - a fast, local-first media indexer. Features: - SQLite database with WAL mode and foreign keys - Full schema for performers, studios, scenes, and tags - Many-to-many relationships via junction tables - CRUD stores for all entities with search capabilities - CLI with performer/studio/scene search commands - Pluggable scraper architecture with registry - TPDB client stub (ready for implementation) - Configuration system via YAML files - Comprehensive .gitignore and documentation Architecture: - cmd/goondex: CLI application with Cobra - cmd/goondexd: Daemon placeholder for v0.2.0 - internal/db: Database layer with stores - internal/model: Clean data models - internal/scraper: Scraper interface and TPDB client - config/: YAML configuration templates Database schema includes indexes on common query fields and uses RFC3339 timestamps for consistency. Built and tested successfully with Go 1.25.4. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
93 lines
2.5 KiB
Go
93 lines
2.5 KiB
Go
package db
|
|
|
|
const schema = `
|
|
-- Enable foreign keys
|
|
PRAGMA foreign_keys = ON;
|
|
|
|
-- Performers table
|
|
CREATE TABLE IF NOT EXISTS performers (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
aliases TEXT,
|
|
nationality TEXT,
|
|
country TEXT,
|
|
gender TEXT,
|
|
image_path TEXT,
|
|
image_url TEXT,
|
|
bio TEXT,
|
|
source TEXT,
|
|
source_id TEXT,
|
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
);
|
|
|
|
-- Studios table
|
|
CREATE TABLE IF NOT EXISTS studios (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
parent_id INTEGER,
|
|
image_path TEXT,
|
|
image_url TEXT,
|
|
description TEXT,
|
|
source TEXT,
|
|
source_id TEXT,
|
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
FOREIGN KEY (parent_id) REFERENCES studios(id) ON DELETE SET NULL
|
|
);
|
|
|
|
-- Tags table
|
|
CREATE TABLE IF NOT EXISTS tags (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
source TEXT,
|
|
source_id TEXT,
|
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
);
|
|
|
|
-- Scenes table
|
|
CREATE TABLE IF NOT EXISTS scenes (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
title TEXT NOT NULL,
|
|
code TEXT,
|
|
date TEXT,
|
|
studio_id INTEGER,
|
|
description TEXT,
|
|
image_path TEXT,
|
|
image_url TEXT,
|
|
director TEXT,
|
|
url TEXT,
|
|
source TEXT,
|
|
source_id TEXT,
|
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
FOREIGN KEY (studio_id) REFERENCES studios(id) ON DELETE SET NULL
|
|
);
|
|
|
|
-- Scene-Performer many-to-many junction table
|
|
CREATE TABLE IF NOT EXISTS scene_performers (
|
|
scene_id INTEGER NOT NULL,
|
|
performer_id INTEGER NOT NULL,
|
|
PRIMARY KEY (scene_id, performer_id),
|
|
FOREIGN KEY (scene_id) REFERENCES scenes(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (performer_id) REFERENCES performers(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Scene-Tag many-to-many junction table
|
|
CREATE TABLE IF NOT EXISTS scene_tags (
|
|
scene_id INTEGER NOT NULL,
|
|
tag_id INTEGER NOT NULL,
|
|
PRIMARY KEY (scene_id, tag_id),
|
|
FOREIGN KEY (scene_id) REFERENCES scenes(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Indexes for common queries (v0.1.0)
|
|
CREATE INDEX IF NOT EXISTS idx_performers_name ON performers(name);
|
|
CREATE INDEX IF NOT EXISTS idx_studios_name ON studios(name);
|
|
CREATE INDEX IF NOT EXISTS idx_scenes_title ON scenes(title);
|
|
CREATE INDEX IF NOT EXISTS idx_scenes_code ON scenes(code);
|
|
CREATE INDEX IF NOT EXISTS idx_tags_name ON tags(name);
|
|
`
|