PRAGMA journal_mode = PERSIST;
PRAGMA user_version = 1;

CREATE TABLE IF NOT EXISTS statistics (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  binpath TEXT NOT NULL,
  received BIGINT,
  sent BIGINT,
  time_stamp BIGINT,
  iftype INT,
  is_roaming INT,
  hw_net_protocol_type INT,
  ifname TEXT,
  subscriber_id TEXT,
  ground INT
);

CREATE TABLE IF NOT EXISTS restrictions (
  restriction_id INTEGER PRIMARY KEY AUTOINCREMENT,
  binpath TEXT,
  iftype INT,
  ifname TEXT,
  rst_state INT,
  roaming INT,
  subscriber_id TEXT NOT NULL,
  data_limit BIGINT,
  data_warn_limit BIGINT
);

CREATE INDEX IF NOT EXISTS restrictions_index ON restrictions (binpath, iftype, ifname);

CREATE TABLE IF NOT EXISTS counters (
  restriction_id INTEGER NOT NULL,
  data_counter BIGINT,
  PRIMARY KEY (restriction_id)
);
