ns::stats::SQLiteHistory method historySchema (protected)

 <instance of ns::stats::SQLiteHistory[i]> historySchema db

Defined in

Parameters:
db (required)

Testcases:
No testcase defined.
Source code:
foreach query {
    {CREATE TABLE IF NOT EXISTS ns_stats_meta (key TEXT PRIMARY KEY,value TEXT NOT NULL)}
    {CREATE TABLE IF NOT EXISTS ns_stats_topology (id TEXT PRIMARY KEY,payload TEXT NOT NULL)}
    {CREATE TABLE IF NOT EXISTS ns_stats_samples (at INTEGER PRIMARY KEY,instance TEXT NOT NULL,topology TEXT NOT NULL,payload TEXT NOT NULL)}
    {CREATE TABLE IF NOT EXISTS ns_stats_events (id INTEGER PRIMARY KEY,at INTEGER NOT NULL,first INTEGER NOT NULL,last INTEGER NOT NULL,n INTEGER NOT NULL,reason TEXT NOT NULL)}
} {
    ::ns::stats::sql $db $query
}
set version [::ns::stats::scalar $db {SELECT value FROM ns_stats_meta WHERE key='schemaVersion'}]
if {$version ne "" && $version ne "1"} {
    error "unsupported diagnostics history schema"
}
set source [::ns::stats::quote [list [ns_info hostname] [ns_info home]]]
set stored [::ns::stats::scalar $db {SELECT value FROM ns_stats_meta WHERE key='source'}]
if {$stored ne "" && [::ns::stats::quote $stored] ne $source} {
    error "history database belongs to another process installation"
}
::ns::stats::sql $db {INSERT OR IGNORE INTO ns_stats_meta VALUES('schemaVersion','1')}
::ns::stats::sql $db {INSERT OR IGNORE INTO ns_stats_meta VALUES('encoding','tcl-zlib-hex-v1')}
::ns::stats::sql $db "INSERT OR IGNORE INTO ns_stats_meta VALUES('source',$source)"
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: