package main

var (
	Sql_Table_Syscfg = `
CREATE TABLE IF NOT EXISTS syscfg (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  cfg_key TEXT UNIQUE,
  cfg_value TEXT NOT NULL
)`
	Sql_Values_Syscfg = `
INSERT OR IGNORE INTO syscfg VALUES
(NULL,'smtp_host','smtp.163.com'),
(NULL,'smtp_port','25'),
(NULL,'smtp_user',''),
(NULL,'smtp_pwd',''),
(NULL,'smtp_sender',''),
(NULL,'monitor_loop_interval','30'),
(NULL,'monitor_mail_interval','3600'),
(NULL,'log_kept_days','30')
`
	Sql_Table_Accounts = `
CREATE TABLE IF NOT EXISTS accounts (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  account TEXT UNIQUE,
  name TEXT NOT NULL,
  password TEXT NOT NULL,
  last_login INTEGER NOT NULL DEFAULT 0,
  is_super INTEGER NOT NULL DEFAULT 0,
  disabled INTEGER NOT NULL DEFAULT 0
)`
	Sql_Table_Rediscfg = `
CREATE TABLE IF NOT EXISTS rediscfg (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  address TEXT UNIQUE,
  remark TEXT NOT NULL DEFAULT '',
  password TEXT NOT NULL DEFAULT '',
  max_connect_wait INTEGER NOT NULL DEFAULT 5,
  max_status_failed INTEGER NOT NULL DEFAULT 1,
  min_memory_free INTEGER NOT NULL DEFAULT 0,
  step_memory_increase INTEGER NOT NULL DEFAULT 0,
  max_memory_usage INTEGER NOT NULL DEFAULT 16000000000,
  max_connection INTEGER NOT NULL DEFAULT 1000,
  max_evi_increased INTEGER NOT NULL DEFAULT 1,
  max_qps INTEGER NOT NULL DEFAULT 50000,
  mail_list TEXT NOT NULL DEFAULT '',
  disabled INTEGER NOT NULL DEFAULT 0
)`
	Sql_Table_Syslog = `
CREATE TABLE IF NOT EXISTS syslog (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  log_time INTEGER NOT NULL,
  log_level TEXT NOT NULL, 
  log_msg TEXT NOT NULL
)`
	Sql_Index_Syslog     = `CREATE INDEX IF NOT EXISTS idx_time ON syslog(log_time)`
	Sql_Table_Monitorlog = `
CREATE TABLE IF NOT EXISTS monitorlog (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  redis_id INTEGER NOT NULL,
  log_time INTEGER NOT NULL,
  query_status INTEGER NOT NULL DEFAULT 0,
  failed_count INTEGER NOT NULL DEFAULT 0,
  used_memory INTEGER NOT NULL DEFAULT 0,
  max_memory INTEGER NOT NULL DEFAULT 0,
  system_memory INTEGER NOT NULL DEFAULT 0,
  connection INTEGER NOT NULL DEFAULT 0,
  qps INTEGER NOT NULL DEFAULT 0,
  evicted_keys INTEGER NOT NULL DEFAULT 0,
  evi_increased INTEGER NOT NULL DEFAULT 0,
  UNIQUE (redis_id, log_time)
)`
	Sql_Table_Warnlog = `
CREATE TABLE IF NOT EXISTS warnlog (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  redis_id INTEGER NOT NULL,
  warn_time INTEGER NOT NULL,
  warn_msg TEXT NOT NULL
)`
	Sql_Index_Warnlog1   = `CREATE INDEX IF NOT EXISTS idx_redis ON warnlog(redis_id)`
	Sql_Index_Warnlog2   = `CREATE INDEX IF NOT EXISTS idx_time ON warnlog(warn_time)`
	Sql_Table_Processlog = `
CREATE TABLE IF NOT EXISTS processlog (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  redis_id INTEGER NOT NULL,
  process_time INTEGER NOT NULL,
  maxmemory_before INTEGER NOT NULL DEFAULT 0,
  maxmemory_after INTEGER NOT NULL DEFAULT 0,
  UNIQUE (redis_id, process_time)
)`
)
