Add notification success to database

This commit is contained in:
JonnyWong16 2017-04-19 19:32:35 -07:00
parent fc37a8afa3
commit 006e7c214d
5 changed files with 68 additions and 19 deletions

View file

@ -481,7 +481,7 @@ def dbcheck():
'CREATE TABLE IF NOT EXISTS notify_log (id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp INTEGER, '
'session_key INTEGER, rating_key INTEGER, parent_rating_key INTEGER, grandparent_rating_key INTEGER, '
'user_id INTEGER, user TEXT, notifier_id INTEGER, agent_id INTEGER, agent_name TEXT, notify_action TEXT, '
'subject_text TEXT, body_text TEXT, script_args TEXT)'
'subject_text TEXT, body_text TEXT, script_args TEXT, success INTEGER DEFAULT 0)'
)
# library_sections table :: This table keeps record of the servers library sections
@ -958,6 +958,18 @@ def dbcheck():
'ALTER TABLE notify_log ADD COLUMN notifier_id INTEGER'
)
# Upgrade notify_log table from earlier versions
try:
c_db.execute('SELECT send_success FROM notify_log')
except sqlite3.OperationalError:
logger.debug(u"Altering database. Updating database table notify_log.")
c_db.execute(
'ALTER TABLE notify_log ADD COLUMN success INTEGER DEFAULT 0'
)
c_db.execute(
'UPDATE notify_log SET success = 1'
)
# Upgrade library_sections table from earlier versions (remove UNIQUE constraint on section_id)
try:
result = c_db.execute('SELECT SQL FROM sqlite_master WHERE type="table" AND name="library_sections"').fetchone()