Continue using existing MariaDB database for new (optimized) OpenHab instance?


actually i am setting up a new OpenHab instance with some optimizations with some things and items (most item are migrated, but some did changed).
I would really love to continue using my already existing MariaDB for persistence.
In the existing database are tabeles named by their item, not their item-id thats stored in the table “items”.
The question is, if the same named items on the new instance will continue writing in the existing tables or will there be the risk of “confusion” because maybe the item id will change?

This is how the item tables look:

This is a part of the items table with the item-ids:

Thanks for your help!


You definitely can continue with the same tables. As a precaution, I would advise you to take a backup first. And don’t let the two instances run at the same time.

The incremental numbers you see in your table names and in the items index table are managed by MariaDB, not by openHAB, so new items will be created correctly by your new openHAB instance. Existing items will be looked up in the index table, so as long as your item names are the same, it will work.

All naming conventions are preserved in JDBC persistence, so if you upgrade openHAB to the latest version, you will still be able to use that lowercase_item_name_xxxx convention. However, after you have successfully made the transition, I would advise you to migrate to a better convention. The problem with your currently used convention is that you only get half the benefit of using real names. As a human, you can more quickly find the correct table than if you had to check the index table first. But other software/scripts working on those tables will still need to look up the table name in the index.

If you combine tableUseRealItemNames and tableCaseSensitiveItemNames you can have case-sensitive table names without any need to have number suffixes, and there will no longer be an index table (e.g. items). See JDBC - Persistence Services | openHAB for details. rebuildTableNames can be used to perform the migration, but before doing that you should check consistency using console commands like jdbc tables list. And of course backup. :slight_smile:

1 Like

Thank you, i will give it a try!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.