CREATE TABLE IF NOT EXISTS tag_classes(
    id INTEGER PRIMARY KEY,
    tag_class TEXT,
    description TEXT
);

CREATE TABLE IF NOT EXISTS tags (
  id INTEGER PRIMARY KEY,
  name TEXT,
  class TEXT,
  tag TEXT,
  description TEXT,
  data_type TEXT,
  change_threshold REAL,
  guarantee_sec INTEGER,
  map_function TEXT,
  units TEXT,
  minExpected REAL,
  maxExpected REAL,
  dateAdded TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  deleted INTEGER DEFAULT 0
);

CREATE TABLE IF NOT EXISTS tag_vals (
  id INTEGER PRIMARY KEY,
  tagID INTEGER,
  val REAL,
  dtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS config (
  id INTEGER PRIMARY KEY,
  parameter TEXT,
  val TEXT,
  dateAdded TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO tag_classes (id, tag_class, description) VALUES (1, 'stroke', 'Stroke Information');
INSERT INTO tag_classes (id, tag_class, description) VALUES (2, 'history', 'Historical Data');
INSERT INTO tag_classes (id, tag_class, description) VALUES (3, 'gaugeoff', 'Gauge Off Data');
INSERT INTO tag_classes (id, tag_class, description) VALUES (4, 'welltest', 'Well Test Data');
INSERT INTO tag_classes (id, tag_class, description) VALUES (5, 'custom', 'Custom tags');
