Search code examples
azerothcore

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.


Solution

  • 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.