PRAGMA foreign_keys=OFF;
BEGIN;
CREATE TABLE api_keys (
    id TEXT PRIMARY KEY,
    name TEXT NOT NULL,
    key TEXT NOT NULL UNIQUE,
    description TEXT,
    expires_at DATETIME NOT NULL,
    last_used_at DATETIME,
    created_at DATETIME,
    user_id TEXT REFERENCES users(id) ON DELETE CASCADE
);

CREATE INDEX idx_api_keys_key ON api_keys(key);
COMMIT;
PRAGMA foreign_keys=ON;
