calls2_6.1.6.sql 2.9 KB

123456789101112131415161718192021222324252627282930313233
  1. CREATE TABLE _SqliteDatabaseProperties (key TEXT,
  2. value TEXT,
  3. UNIQUE(key));
  4. CREATE TABLE call (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  5. address TEXT,
  6. date INTEGER,
  7. duration INTEGER,
  8. flags INTEGER,
  9. id INTEGER,
  10. name TEXT,
  11. country_code TEXT,
  12. network_code TEXT,
  13. read INTEGER,
  14. assisted INTEGER,
  15. face_time_data BLOB,
  16. originalAddress TEXT);
  17. CREATE TABLE sqlite_sequence(name,seq);
  18. CREATE TABLE data (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  19. pdp_ip INTEGER,
  20. bytes_rcvd REAL,
  21. bytes_sent REAL,
  22. bytes_last_rcvd REAL,
  23. bytes_last_sent REAL,
  24. bytes_lifetime_rcvd REAL,
  25. bytes_lifetime_sent REAL);
  26. CREATE INDEX date_index on call(date);
  27. CREATE TRIGGER timer_last_trigger INSERT ON call WHEN (NEW.duration != 0) BEGIN UPDATE _SqliteDatabaseProperties SET value = (((NEW.duration + 59)/60)*60) WHERE key = 'timer_last'; END;
  28. CREATE TRIGGER timer_outgoing_trigger INSERT ON call WHEN (NEW.flags & (1 << 0) == 1) BEGIN UPDATE _SqliteDatabaseProperties SET value = (((((SELECT NEW.duration)+59)/60)*60) + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'timer_outgoing')) WHERE key = 'timer_outgoing'; END;
  29. CREATE TRIGGER timer_incoming_trigger INSERT ON call WHEN (NEW.flags & (1 << 0) == 0) BEGIN UPDATE _SqliteDatabaseProperties SET value = (((((SELECT NEW.duration)+59)/60)*60) + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'timer_incoming')) WHERE key = 'timer_incoming'; END;
  30. CREATE TRIGGER timer_all_trigger INSERT ON call WHEN (NEW.duration != 0) BEGIN UPDATE _SqliteDatabaseProperties SET value = (((((SELECT NEW.duration) + 59)/60)*60) + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'timer_all')) WHERE key = 'timer_all'; END;
  31. CREATE TRIGGER timer_lifetime_trigger INSERT ON call WHEN (NEW.duration != 0) BEGIN UPDATE _SqliteDatabaseProperties SET value = (((((SELECT NEW.duration) + 59)/60)*60) + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'timer_lifetime')) WHERE key = 'timer_lifetime'; END;
  32. CREATE TRIGGER data_up_trigger UPDATE ON _SqliteDatabaseProperties WHEN (NEW.key = 'data_up_last') BEGIN UPDATE _SqliteDatabaseProperties SET value = (SELECT NEW.value + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'data_up_all')) WHERE key = 'data_up_all'; UPDATE _SqliteDatabaseProperties SET value = (SELECT NEW.value + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'data_up_lifetime')) WHERE key = 'data_up_lifetime'; END;
  33. CREATE TRIGGER data_down_trigger UPDATE ON _SqliteDatabaseProperties WHEN (NEW.key = 'data_down_last') BEGIN UPDATE _SqliteDatabaseProperties SET value = (SELECT NEW.value + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'data_down_all')) WHERE key = 'data_down_all'; UPDATE _SqliteDatabaseProperties SET value = (SELECT NEW.value + (SELECT value FROM _SqliteDatabaseProperties WHERE key = 'data_down_lifetime')) WHERE key = 'data_down_lifetime'; END;