/**
 * Registry Schema DDL
 *
 * All DDL statements for the registry database as plain string constants.
 * These are used to initialize and maintain the registry SQLite database.
 */
/**
 * PRAGMA expressions for registry database initialization.
 * Applied in order on every connection open via db.pragma().
 * Values are pragma bodies without the PRAGMA keyword prefix.
 */
export declare const REGISTRY_PRAGMAS: string[];
/**
 * Main databases table - tracks all known OCR databases
 */
export declare const CREATE_DATABASES_TABLE = "CREATE TABLE IF NOT EXISTS databases (\n  name TEXT PRIMARY KEY,\n  description TEXT,\n  status TEXT NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'archived')),\n  file_path TEXT NOT NULL,\n  created_at TEXT NOT NULL DEFAULT (datetime('now')),\n  last_accessed_at TEXT,\n  access_count INTEGER NOT NULL DEFAULT 0,\n  last_action TEXT,\n  size_bytes INTEGER NOT NULL DEFAULT 0,\n  document_count INTEGER NOT NULL DEFAULT 0,\n  chunk_count INTEGER NOT NULL DEFAULT 0,\n  embedding_count INTEGER NOT NULL DEFAULT 0,\n  archive_reason TEXT,\n  archived_at TEXT,\n  profile_json TEXT\n)";
/**
 * Tags associated with databases (many-to-many via composite PK)
 */
export declare const CREATE_DATABASE_TAGS_TABLE = "CREATE TABLE IF NOT EXISTS database_tags (\n  database_name TEXT NOT NULL,\n  tag TEXT NOT NULL,\n  PRIMARY KEY (database_name, tag),\n  FOREIGN KEY (database_name) REFERENCES databases(name) ON DELETE CASCADE ON UPDATE CASCADE\n)";
/**
 * Arbitrary key-value metadata for databases
 */
export declare const CREATE_DATABASE_METADATA_KV_TABLE = "CREATE TABLE IF NOT EXISTS database_metadata_kv (\n  database_name TEXT NOT NULL,\n  key TEXT NOT NULL,\n  value TEXT NOT NULL,\n  PRIMARY KEY (database_name, key),\n  FOREIGN KEY (database_name) REFERENCES databases(name) ON DELETE CASCADE ON UPDATE CASCADE\n)";
/**
 * Workspaces - named groups of databases
 */
export declare const CREATE_WORKSPACES_TABLE = "CREATE TABLE IF NOT EXISTS workspaces (\n  name TEXT PRIMARY KEY,\n  description TEXT,\n  created_at TEXT NOT NULL DEFAULT (datetime('now'))\n)";
/**
 * Workspace membership - links databases to workspaces
 */
export declare const CREATE_WORKSPACE_MEMBERS_TABLE = "CREATE TABLE IF NOT EXISTS workspace_members (\n  workspace_name TEXT NOT NULL,\n  database_name TEXT NOT NULL,\n  PRIMARY KEY (workspace_name, database_name),\n  FOREIGN KEY (workspace_name) REFERENCES workspaces(name) ON DELETE CASCADE,\n  FOREIGN KEY (database_name) REFERENCES databases(name) ON DELETE CASCADE ON UPDATE CASCADE\n)";
/**
 * Access log for tracking database usage patterns
 */
export declare const CREATE_ACCESS_LOG_TABLE = "CREATE TABLE IF NOT EXISTS access_log (\n  id INTEGER PRIMARY KEY AUTOINCREMENT,\n  database_name TEXT NOT NULL,\n  action TEXT NOT NULL,\n  accessed_at TEXT NOT NULL DEFAULT (datetime('now'))\n)";
/**
 * Index for efficient access log queries by database and time
 */
export declare const CREATE_ACCESS_LOG_INDEX = "CREATE INDEX IF NOT EXISTS idx_access_log_db_time ON access_log(database_name, accessed_at DESC)";
/**
 * FTS5 virtual table for full-text search across database names, descriptions, and tags
 */
export declare const CREATE_DATABASES_FTS = "CREATE VIRTUAL TABLE IF NOT EXISTS databases_fts USING fts5(name, description, tags, tokenize='porter unicode61')";
/**
 * Trigger: after inserting a database, populate FTS index
 */
export declare const TRIGGER_DATABASES_AI = "CREATE TRIGGER IF NOT EXISTS databases_ai AFTER INSERT ON databases BEGIN\n  INSERT INTO databases_fts(rowid, name, description, tags)\n  VALUES (NEW.rowid, NEW.name, COALESCE(NEW.description, ''), '');\nEND";
/**
 * Trigger: after updating a database, refresh FTS index with aggregated tags
 */
export declare const TRIGGER_DATABASES_AU = "CREATE TRIGGER IF NOT EXISTS databases_au AFTER UPDATE ON databases BEGIN\n  DELETE FROM databases_fts WHERE rowid = OLD.rowid;\n  INSERT INTO databases_fts(rowid, name, description, tags)\n  VALUES (NEW.rowid, NEW.name, COALESCE(NEW.description, ''),\n    COALESCE((SELECT GROUP_CONCAT(tag, ' ') FROM database_tags WHERE database_name = NEW.name), ''));\nEND";
/**
 * Trigger: after deleting a database, remove from FTS index
 */
export declare const TRIGGER_DATABASES_AD = "CREATE TRIGGER IF NOT EXISTS databases_ad AFTER DELETE ON databases BEGIN\n  DELETE FROM databases_fts WHERE rowid = OLD.rowid;\nEND";
/**
 * Trigger: after inserting a tag, fire database UPDATE trigger to refresh FTS tags
 */
export declare const TRIGGER_TAGS_AI = "CREATE TRIGGER IF NOT EXISTS tags_ai AFTER INSERT ON database_tags BEGIN\n  UPDATE databases SET name = name WHERE name = NEW.database_name;\nEND";
/**
 * Trigger: after deleting a tag, fire database UPDATE trigger to refresh FTS tags
 */
export declare const TRIGGER_TAGS_AD = "CREATE TRIGGER IF NOT EXISTS tags_ad AFTER DELETE ON database_tags BEGIN\n  UPDATE databases SET name = name WHERE name = OLD.database_name;\nEND";
//# sourceMappingURL=schema.d.ts.map