Giter Site home page Giter Site logo

hamerger's Introduction

Home Assistant Database Merge Tool

A cross-platform tool to merge the statistic tables in the database created by Home Assistant. This tool should be able to support Sqlite, MySql and SqlServer (although I've only tested Sqlite). Built on .NET7 (cross-platform compatible), using OrmLite to manipulate the databases.

If you want to get started quickly, simply:

  • Open the project in Visual Studio 2022
  • Build the project (Ctrl + Shift + B)
  • Locate the build folder within the project folder bin/, create a folder called data and place your old and new database files in the folder (naming them old.db and new.db).
  • Run the program and wait for the data to be migrated.

Warning

This tool was only tested on my personal HA instance (schema version 35 and 41), it may not work for you!

  • Only work on COPIES of your databases to ensure no data loss.
  • If you need to re-run this script I suggest you re-copy the databases on each run to ensure a consistent state (though you can also set SKIP_DUPLICATE_CHECK=false).

Notes

  • There are a few options that can be set prior to building the project:
    • DB_TYPE - Select your database type here. Options are Sqlite, MySql, SqlServer. Default is Sqlite
    • OLD_DB_CONNECTION_STRING - Set the OLD database string here. Default is 'old.db'
    • NEW_DB_CONNECTION_STRING - Set the NEW database string here. Default is 'new.db'
    • DRY_RUN - Setting this to 'true' will ensure the new database is not modified, so you can see if/how it works. By default this is true for safety reasons.
    • SKIP_DUPLICATE_CHECK - Setting this to 'true' will speed up the time it takes to merge the databases but may lead to inconsistent data. Default is true to speed things up.
    • COPY_TO_NEW_DB - Setting this to 'true' will create a mirror copy of the statistic tables in the new database after all records have been processed. This allows you to use your new database whilst keeping all the old statistics. Default is false.
  • This tool currently doesn't copy the state tables. Tables copied are statistics, statistics_short_term, statistics_meta, statistics_runs.

hamerger's People

Contributors

olicooper avatar

Stargazers

 avatar Dominik Vogel avatar Imad avatar  avatar Ramon avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

geryyyyyy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.