Commit graph

92 commits

Author SHA1 Message Date
Erik Montnemery
466c4656ca
Refactor recorder migration (#80175)
* Refactor recorder migration

* Improve test coverage
2022-10-13 08:11:54 +02:00
Erik
4a1c40f09b Revert "Refactor recorder migration"
This reverts commit 69e10e5982.
2022-10-12 15:12:12 +02:00
Erik
69e10e5982 Refactor recorder migration 2022-10-12 15:00:28 +02:00
Erik Montnemery
577f7904b5
Minor improvements of recorder typing (#80165)
* Minor improvements of recorder typing

* Only allow specifying statistic_ids as lists
2022-10-12 14:59:10 +02:00
Erik Montnemery
0fdb7052e9
Add comment in recorder about dropping column (#79523)
Add comment in recorder
2022-10-03 11:40:11 +02:00
Erik Montnemery
2de273500e
Remove state_unit_of_measurement from metadata DB table (#79370)
* Remove state_unit_of_measurement from metadata DB table

* Adjust test
2022-10-01 18:55:00 +02:00
Erik Montnemery
dd20a7ea62
Display statistics in the source's unit (#78031) 2022-09-15 12:01:24 -04:00
Erik Montnemery
eb28d7188b
Fix DB migration to schema version 29 (#78037)
* Fix DB migration to schema version 29

* Fix misspelled constants
2022-09-09 08:06:14 +02:00
J. Nick Koston
20b6c4c48e
Fix recorder hanging at start (#75627) 2022-07-22 12:37:25 -05:00
Erik Montnemery
fd6ffef52f
Support non-live database migration (#72433)
* Support non-live database migration

* Tweak startup order, add test

* Address review comments

* Fix typo

* Clarify comment about promoting dependencies

* Tweak

* Fix merge mistake

* Fix some tests

* Fix additional test

* Fix additional test

* Adjust tests

* Improve test coverage
2022-07-22 15:11:34 +02:00
Erik Montnemery
5f2b4001f3
Separate recorder database schema from other classes (#72977)
* Separate recorder database schema from other classes

* fix logbook imports

* migrate new tests

* few more

* last one

* fix merge

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-07 14:41:43 +02:00
J. Nick Koston
cd590c79e2
Fix migration of MySQL data when InnoDB is not being used (#72893)
Fixes #72883
2022-06-02 14:01:06 +02:00
J. Nick Koston
856e1144c9
Ensure the statistics_meta table is using the dynamic row format (#72784) 2022-05-31 14:35:28 -07:00
Erik Montnemery
23bd64b7a2
Prevent duplication of statistics metadata (#71637)
* Prevent duplication of statistics metadata

* Add models_schema_28.py

* Handle entity renaming as a recorder job

* Improve tests
2022-05-24 15:34:46 +02:00
J. Nick Koston
a8aa0e1cca
Add Estimated Database Size to the recorder system health (#71463) 2022-05-07 21:02:54 -07:00
J. Nick Koston
eb77f8db85
Complete strict typing for recorder (#71274)
* Complete strict typing for recorder

* update tests

* Update tests/components/recorder/test_migrate.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/components/recorder/test_migrate.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Remove the asserts

* remove ignore comments

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-05-04 12:22:50 -05:00
J. Nick Koston
5db014666c
Avoid recording state_changed events in the events table (#71165)
* squash

fix mypy

* Update homeassistant/components/recorder/models.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* pass all columns

* fix commented out code

* reduce logbook query complexity

* merge

* comment

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-05-02 02:10:34 -05:00
J. Nick Koston
c23866e5e5
De-duplicate event data into a new event_data table (#71135) 2022-05-01 21:01:17 -05:00
J. Nick Koston
6ce768465f
Improve purge performance for non-sqlite databases (#70576) 2022-04-26 13:11:57 -07:00
Dmitry Katsubo
521579fc6a
Fixed syntax error in ALTER TABLE statement (#70304) (#70336) 2022-04-22 21:29:25 -10:00
Erik Montnemery
eb3458a3d2
Add MutexPool for recorder tests (#69410)
* Add MutexPool for recorder tests

* Fix get_schema_version

* Update test test_last_run_was_recently_clean

* Update test test_shutdown_before_startup_finishes

* Revert comments in test_write_lock_db

* Make the MutexPool lock a class variable

* Remove stale comment

* Move MutexPool

* Tweak debug prints
2022-04-12 07:41:46 -10:00
J. Nick Koston
d75f577b88
Additional strict typing for recorder (#68860) 2022-03-30 09:20:44 -07:00
J. Nick Koston
3c10ac308d
Fix migration to schema v25 with Postgresql (#68426) 2022-03-20 21:49:11 +01:00
J. Nick Koston
9215702388
Separate attrs into another table (reduces database size) (#68224) 2022-03-18 00:23:13 -10:00
Erik Montnemery
39ed628cca
Suppress unwanted error messages during recorder migration (#66004) 2022-02-07 15:46:40 -08:00
Erik Montnemery
1f8e8926fe
Only remove duplicated statistics on error (#65653) 2022-02-04 11:31:12 -08:00
Erik Montnemery
020953e943
Improve recorder migration for PostgreSQL when columns already exist (#65680) 2022-02-04 10:55:28 -08:00
Erik Montnemery
41ab12cb88
Don't use shared session during recorder migration (#65672) 2022-02-04 09:55:11 -08:00
Erik Montnemery
bceeaec2f8
Remove duplicated statistics rows (#61146)
* Remove duplicated statistics

* Fix misleading docstring

* Pylint knows best

* Correct test

* Oops

* Prevent insertion of duplicated statistics

* Tweak

* pylint

* Add models_schema_23.py

* Tweak
2021-12-13 14:15:36 +01:00
Erik Montnemery
d980ca7e04
Correct recorder migration._add_columns for PostgreSQL (#60547) 2021-11-29 18:33:25 +01:00
Erik Montnemery
2f3dea30e2
Correct migration to recorder schema 22 (#59048) 2021-11-04 10:29:10 +01:00
Erik Montnemery
f594bc353b
Add support for external statistics (#56607)
* Support external statistics

* Update tests

* Lint

* Adjust code after rebase

* Separate external statistic_id with :, add name to metadata

* Adjust tests

* Simplify get_metadata_with_session

* Address review comments

* Allow updating external statistics

* Validate input

* Adjust tests after rebase

* Pylint

* Adjust tests

* Improve test coverage
2021-10-26 10:26:50 +02:00
Erik Montnemery
e3534eec87
Report orphaned statistics in statistic validation (#57324) 2021-10-20 15:57:22 +02:00
Erik Montnemery
8337baa354
Correct migration to recorder schema 18 (#57165) 2021-10-06 13:29:42 +02:00
Erik Montnemery
dfb3a0c528
Correct database migration to schema version 22 (#56848) 2021-09-30 14:11:00 -07:00
Erik Montnemery
6af1a835e6
Optimize statistics generation (#56821)
* Optimize statistics generation

* pylint
2021-09-30 17:14:36 +02:00
Erik Montnemery
40ecf22bac
Remove automatic splitting of net meters from statistics (#56772) 2021-09-29 17:20:17 +02:00
Erik Montnemery
52e9f76f94
Tweak DB migration to schema version 21 (#56767) 2021-09-29 11:25:50 +02:00
Erik Montnemery
fe66d6295c
Improve migration to recorder schema version 21 (#56204) 2021-09-27 19:31:40 +02:00
Erik Montnemery
64393b462d
Add migration for 5-minute statistics (#56585)
* Add migration for 5-minute statistics

* Tweaks
2021-09-24 09:19:22 +02:00
Marcin Ciupak
b9ffd74db5
Fix recorder Oracle DB models (#55564)
* Fix recorder models for Oracle DB

* Fix StatisticsRuns

* Update migration for Oracle Identity columns.

* Update migration logic

Migration to schema version 22 done only for engine dialect oracle

* Add missing table check in schema 22 migration
2021-09-21 00:38:42 +02:00
Erik Montnemery
8c5efafdd8
Add 5-minute statistics for sensors (#56006)
* Add 5-minute statistics for sensors

* Address pylint issues

* Black

* Apply suggestion from code review

* Apply suggestions from code review

* Improve tests
2021-09-16 10:57:15 +02:00
Erik Montnemery
88dbc6373f
Make sure character set of events, states tables is utf8 (#56012)
* Make sure character set of events, states tables is utf8

* Pylint

* Apply suggestions from code review
2021-09-09 19:26:28 +02:00
Erik Montnemery
a47532c69b
Change character set of statistics_meta table to utf8 (#56011) 2021-09-09 17:24:20 +02:00
Erik Montnemery
80fd330479
Add sum_decrease and sum_increase statistics (#55850) 2021-09-08 23:35:53 -07:00
Erik Montnemery
0624859bf4
Set statistics columns to double precision (#55053) 2021-08-24 11:18:59 +02:00
Erik Montnemery
32e297f4a0
Compile missing statistics (#54690) 2021-08-19 22:10:45 -07:00
Ville Skyttä
470f2dd73f
Upgrade pyupgrade to 2.21.2, apply its changes (#52987) 2021-07-19 10:46:09 +02:00
Franck Nijhof
74029a0948
Fix Statistics recorder migration path by dropping in pairs (#52453) 2021-07-05 13:34:40 +02:00
Franck Nijhof
5e9127ef7a
Remove problematic/redudant db migration happning schema 15 (#52541) 2021-07-05 13:28:01 +02:00