
# ATTACH DATABASE "/Users/mzinner/Library/Application Support/MySQL/DocLibrary/mysqldoclib_usr.sqlite" AS usr

CREATE TABLE IF NOT EXISTS page_rating (
  id_page_rating INTEGER PRIMARY KEY AUTOINCREMENT,
  id_manual_type INTEGER NOT NULL,
  title TEXT NOT NULL,
  rating INTEGER
)
             
CREATE INDEX IF NOT EXISTS idx_page_rating ON page_rating(title);
            

CREATE TABLE IF NOT EXISTS page_view (
  id_page_view INTEGER PRIMARY KEY AUTOINCREMENT,
  path TEXT NOT NULL,
  hits INTEGER
);
            
CREATE INDEX IF NOT EXISTS idx_page_view ON page_view(path);


CREATE TABLE IF NOT EXISTS lib_search (
  id_lib_search INTEGER PRIMARY KEY AUTOINCREMENT,
  search_text TEXT NOT NULL,
  hits INTEGER
);
            
CREATE INDEX IF NOT EXISTS idx_lib_search ON lib_search(search_text);

CREATE TABLE IF NOT EXISTS lib_status (
  id_lib_file INTEGER PRIMARY KEY AUTOINCREMENT,
  id_lib INTEGER,
  downloaded INTEGER,
  is_selected INTEGER
);

INSERT INTO lib_status(id_lib, downloaded, is_selected) VALUES (1, 1, 1);
