calls2_9.3.5.sql 2.7 KB

1234567891011121314151617181920212223242526
  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. answered INTEGER DEFAULT '1');
  18. CREATE TABLE sqlite_sequence(name,seq);
  19. CREATE INDEX date_index on call(date);
  20. 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;
  21. 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;
  22. 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;
  23. 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;
  24. 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;
  25. 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;
  26. 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;