Fixed report_summart view

This commit is contained in:
Rhet Turnbull
2022-07-23 16:33:24 -07:00
parent 7484c7b994
commit 2e85f9be89

View File

@@ -237,7 +237,14 @@ class ReportWriterSQLite(ReportWriterABC):
datetime TEXT
);"""
)
self._conn.commit()
# migrate report table to add report_id if needed (#731)
if "report_id" not in sqlite_columns(self._conn, "report"):
self._conn.cursor().execute("ALTER TABLE report ADD COLUMN report_id TEXT;")
self._conn.commit()
# create report_summary view
c.execute(
"""
CREATE VIEW IF NOT EXISTS report_summary AS
@@ -259,12 +266,6 @@ class ReportWriterSQLite(ReportWriterABC):
FROM report
GROUP BY report_id;"""
)
self._conn.commit()
# migrate report table to add report_id if needed (#731)
if "report_id" not in sqlite_columns(self._conn, "report"):
self._conn.cursor().execute("ALTER TABLE report ADD COLUMN report_id TEXT;")
self._conn.commit()
def _generate_report_id(self) -> int: