Walter Pagani
Walter Pagani

Reputation: 23

Update database records

I've been wanting to get this question out for a long time. Can you do database record updates while the server is running? Actually the question is different, would it be advisable to make those updates with the server running or would it be preferable, to turn off the server, make the modifications and then turn it on again? Thank you. It may seem like the stupidest question in the world to some, but they can't even imagine how many times I've seen people doing log updates with the server running.

Upvotes: 2

Views: 774

Answers (4)

Francesco Borzi
Francesco Borzi

Reputation: 61994

It is always preferable to do changes to the DB while the server is offline.

However, there is a set of tables that support live reloading. This means that you can modify them and then reload their contents using the .reload * GM commands. Such commands are implemented in this file:

Note that, while most of the .reload * commands will reload the whole table, there are some cases, such as reload creature_template XXX where you can only reload a specific XXX entity at the time (so you can't reload the whole table at once).

Typically, editing contents of the tables supported by the .reload * commands is considered safe enough.

There are other cases while it's still safe to edit the table contents, but they are not immediately reflected in the core. For example, if you change a character's account (by changing the account field in the characters table of the acore_characters database), the changes are reflected at next account login.

Finally, there could be cases where editing a DB value could lead to inconsistent behaviour. For example, the server might not load on time the new change that has been manually done to the database and then overwrite it. So the manual change will be lost. If you are in doubt, it's always better to first experiment in a testing environment before applying the changes to the production envinroment.

Upvotes: 2

Barbz_YHOOL
Barbz_YHOOL

Reputation: 607

Turn server off to do big updates else you can have unwanted issues (when a query is ran by the core at the same time)

Upvotes: 1

naravena
naravena

Reputation: 33

Any changes to database need to reload the world database to reflect changes, so is not a real problem if you do it when the server is running. However, applying changes like alters or massive updates, will lock the table until changes are applied.

Saying that, should be ideal to do it with server off, preventing errors, or any kind of data loss for players.

Upvotes: 2

Hacaw
Hacaw

Reputation: 21

I tried to update database with some npc text changes, while the server was still running, but the updates were not reflected at all, so I had to re-trigger docker-compose up again.

Maybe for other parts of the app work, but for the text tables it didn't work. This is probably because character data which is static is loaded once when the server is started.

It would be awesome to have this feature, as it will increase debug speed time.

Upvotes: 1

Related Questions