Add mobile device last seen

This commit is contained in:
JonnyWong16 2017-12-08 22:05:44 -08:00
parent 019787b32d
commit ecd0a199f1
5 changed files with 61 additions and 22 deletions

View file

@ -540,7 +540,8 @@ def dbcheck():
# mobile_devices table :: This table keeps record of devices linked with the mobile app
c_db.execute(
'CREATE TABLE IF NOT EXISTS mobile_devices (id INTEGER PRIMARY KEY AUTOINCREMENT, '
'device_id TEXT NOT NULL UNIQUE, device_token TEXT, device_name TEXT, friendly_name TEXT)'
'device_id TEXT NOT NULL UNIQUE, device_token TEXT, device_name TEXT, friendly_name TEXT, '
'last_seen INTEGER)'
)
# tvmaze_lookup table :: This table keeps record of the TVmaze lookups
@ -1084,6 +1085,15 @@ def dbcheck():
logger.warn(u"Failed to recreate mobile_devices table.")
pass
# Upgrade mobile_devices table from earlier versions
try:
c_db.execute('SELECT last_seen FROM mobile_devices')
except sqlite3.OperationalError:
logger.debug(u"Altering database. Updating database table mobile_devices.")
c_db.execute(
'ALTER TABLE mobile_devices ADD COLUMN last_seen INTEGER'
)
# Upgrade notifiers table from earlier versions
try:
c_db.execute('SELECT custom_conditions FROM notifiers')