Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate existing recorder Database into ltss #78

Open
manonfgoo opened this issue Apr 24, 2023 · 4 comments
Open

migrate existing recorder Database into ltss #78

manonfgoo opened this issue Apr 24, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@manonfgoo
Copy link

Hello,
it there any simple way to migrate existing recorder Database Data into the ltss table ?

Kind regards

@freol35241
Copy link
Owner

Hi @manonfgoo and thanks for the questions.

There exists no ready-made script for migration to the ltss table as far as I know. The way to do that will also depend on what backend you are currently running the recorder with, i.e. sqlite, postgresql, mysql, or mariadb.

@freol35241 freol35241 added the enhancement New feature or request label Apr 26, 2023
@manonfgoo
Copy link
Author

manonfgoo commented Apr 26, 2023 via email

@freol35241
Copy link
Owner

I will leave this issue open and happily accept contributions for scripts that perform these kind of migrations.

@Bouke
Copy link

Bouke commented May 27, 2024

For postgres, you can do the following:

insert into ltss
select to_timestamp(last_updated_ts) time, states_meta.entity_id, state, shared_attrs::json attributes
from states, states_meta, state_attributes
where states.metadata_id = states_meta.metadata_id and states.attributes_id = state_attributes.attributes_id
    and states_meta.entity_id like 'sensor.%'
on conflict do nothing;

Note that you can optionally limit the entity_id to sensor.% to match your include/exclude list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants