Renaming items with persistence

Hi There,

after two years of using openhab i want to refactor my item names. Is there any way to rename an item including the persistence layer?

best regards!

You can use Visual Studio Code to rename all files with your item names.

I think, that doesn’t answer the question.
To keep persistence, you have to also rename your items in your persistence database.
How to rename depends on the DB, you are using.
I think, there already some examples in the community threads.

That’s true @Joerg_Schreiner. I didn’t think about that :face_with_monocle:

@Joerg_Schreiner Thanks for your answer.
The main question is, whether this could bei automated (eg. with scripting) or do i have to update every db table (100 in my case) manually?

Almost certainly.

How is going to depend on your specific database server.

Ofcourse the approach would differ for the persistence service used, this is what i did for MySQL.

  1. Stop openHab
  2. Refactoring in VS Code and while doing so building up a mapping file in Excel or text editor. (old/new value)
  3. With find and replace i made the mapping file turn into UPDATE statements
  4. Update database with the statements.
  5. Start openhab
  6. Continue thinking about a even better naming convention and start over again :wink:

Yep, done that lots.