mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Add support SQL VACUUM for PostgeSQL (#28106)
* Add support SQL VACUUM for PostgeSQL VACUUM PostgreSQL DB if repack is true * Update tests
This commit is contained in:
parent
c2c9213e9b
commit
0226b76e0a
@ -34,8 +34,8 @@ def purge_old_data(instance, purge_days, repack):
|
|||||||
_LOGGER.debug("Deleted %s events", deleted_rows)
|
_LOGGER.debug("Deleted %s events", deleted_rows)
|
||||||
|
|
||||||
# Execute sqlite vacuum command to free up space on disk
|
# Execute sqlite vacuum command to free up space on disk
|
||||||
if repack and instance.engine.driver == "pysqlite":
|
if repack and instance.engine.driver in ("pysqlite", "postgresql"):
|
||||||
_LOGGER.debug("Vacuuming SQLite to free space")
|
_LOGGER.debug("Vacuuming SQL DB to free space")
|
||||||
instance.engine.execute("VACUUM")
|
instance.engine.execute("VACUUM")
|
||||||
|
|
||||||
except SQLAlchemyError as err:
|
except SQLAlchemyError as err:
|
||||||
|
@ -174,5 +174,5 @@ class TestRecorderPurge(unittest.TestCase):
|
|||||||
self.hass.data[DATA_INSTANCE].block_till_done()
|
self.hass.data[DATA_INSTANCE].block_till_done()
|
||||||
assert (
|
assert (
|
||||||
mock_logger.debug.mock_calls[3][1][0]
|
mock_logger.debug.mock_calls[3][1][0]
|
||||||
== "Vacuuming SQLite to free space"
|
== "Vacuuming SQL DB to free space"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user