From 1be388c5874a1880455a0a1d50935791c1ee72a3 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 20 Aug 2018 11:52:23 +0200 Subject: [PATCH 1/3] Update frontend to 20180820.0 --- homeassistant/components/frontend/__init__.py | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index e17bbad78d1..a436cc483ae 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -26,7 +26,7 @@ from homeassistant.helpers.translation import async_get_translations from homeassistant.loader import bind_hass from homeassistant.util.yaml import load_yaml -REQUIREMENTS = ['home-assistant-frontend==20180818.0'] +REQUIREMENTS = ['home-assistant-frontend==20180820.0'] DOMAIN = 'frontend' DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log', diff --git a/requirements_all.txt b/requirements_all.txt index a2b640cae1e..fe728bf2e02 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -432,7 +432,7 @@ hole==0.3.0 holidays==0.9.6 # homeassistant.components.frontend -home-assistant-frontend==20180818.0 +home-assistant-frontend==20180820.0 # homeassistant.components.homekit_controller # homekit==0.10 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 24aa79587ad..7119259304e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -81,7 +81,7 @@ hbmqtt==0.9.2 holidays==0.9.6 # homeassistant.components.frontend -home-assistant-frontend==20180818.0 +home-assistant-frontend==20180820.0 # homeassistant.components.homematicip_cloud homematicip==0.9.8 From bd776c84bc2cd0cb31b86f99b1f3d17eb889fe1b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 21 Aug 2018 11:41:52 +0200 Subject: [PATCH 2/3] Forgiving add index in migration (#16092) --- homeassistant/components/recorder/migration.py | 11 ++++++++++- tests/components/recorder/test_migrate.py | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/recorder/migration.py b/homeassistant/components/recorder/migration.py index 0dff21a5986..207f2f53a7f 100644 --- a/homeassistant/components/recorder/migration.py +++ b/homeassistant/components/recorder/migration.py @@ -57,6 +57,7 @@ def _create_index(engine, table_name, index_name): within the table definition described in the models """ from sqlalchemy import Table + from sqlalchemy.exc import OperationalError from . import models table = Table(table_name, models.Base.metadata) @@ -67,7 +68,15 @@ def _create_index(engine, table_name, index_name): _LOGGER.info("Adding index `%s` to database. Note: this can take several " "minutes on large databases and slow computers. Please " "be patient!", index_name) - index.create(engine) + try: + index.create(engine) + except OperationalError as err: + if 'already exists' not in str(err).lower(): + raise + + _LOGGER.warning('Index %s already exists on %s, continueing', + index_name, table_name) + _LOGGER.debug("Finished creating %s", index_name) diff --git a/tests/components/recorder/test_migrate.py b/tests/components/recorder/test_migrate.py index 1c48c261372..93da4ec109b 100644 --- a/tests/components/recorder/test_migrate.py +++ b/tests/components/recorder/test_migrate.py @@ -80,3 +80,13 @@ def test_forgiving_add_column(): migration._add_columns(engine, 'hello', [ 'context_id CHARACTER(36)', ]) + + +def test_forgiving_add_index(): + """Test that add index will continue if index exists.""" + engine = create_engine( + 'sqlite://', + poolclass=StaticPool + ) + models.Base.metadata.create_all(engine) + migration._create_index(engine, "states", "ix_states_context_id") From 977d86e7ca88def52d5137ef7fc326f72ae5e9de Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 21 Aug 2018 11:43:14 +0200 Subject: [PATCH 3/3] Bumped version to 0.76.2 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 855f973554b..14054e44663 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 76 -PATCH_VERSION = '1' +PATCH_VERSION = '2' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3)