export const SCHEMA = `
	CREATE TABLE IF NOT EXISTS threads (
		thread_id TEXT NOT NULL,
		account_id TEXT NOT NULL,
		subject TEXT NOT NULL,
		authors TEXT NOT NULL,
		total_messages INTEGER NOT NULL,
		tags TEXT NOT NULL DEFAULT '',
		timestamp INTEGER NOT NULL,
		updated_at TEXT NOT NULL DEFAULT (datetime('now')),
		PRIMARY KEY (thread_id, account_id)
	);

	CREATE TABLE IF NOT EXISTS messages (
		message_id TEXT PRIMARY KEY,
		thread_id TEXT NOT NULL,
		account_id TEXT NOT NULL,
		from_header TEXT NOT NULL,
		to_header TEXT NOT NULL,
		subject TEXT NOT NULL,
		date TEXT NOT NULL,
		in_reply_to TEXT NOT NULL DEFAULT '',
		body TEXT NOT NULL DEFAULT '',
		tags TEXT NOT NULL DEFAULT '',
		timestamp INTEGER NOT NULL,
		updated_at TEXT NOT NULL DEFAULT (datetime('now'))
	);

	CREATE INDEX IF NOT EXISTS idx_messages_thread ON messages(thread_id);
	CREATE INDEX IF NOT EXISTS idx_threads_account ON threads(account_id);
	CREATE INDEX IF NOT EXISTS idx_threads_timestamp ON threads(timestamp DESC);
`;
