-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onUpdateDatabase() #25
Comments
That would eventually become a mess with everything in one file, and some database migrations are more complex than simple query strings, see version 7, 8, 10, 11, 13 and 14 to understand why. Using separate files also makes it easier for the user to find out why when a database upgrade fails. For example if it fails on the upgrade from 13 to 14, the user can just open data/migrations/13.lua and see exactly what happens when upgrading from 13 to 14 instead of opening a huge Lua file and having to look through it to find out which parts belong to the upgrade process between version 13 and 14. Besides, the database migrations aren't meant to be changed by the user. If you want to make custom migrations, I would suggest implementing that using onStartup global event. Can you elaborate on how your idea will improve this system? |
Opening each file and parsing it one by one is slower than just open one file and do everything, so it will take more time to server start up, and I think easier see the queries togheter, but i didin't noticed how complex was some updates, now I get your point and see how worse it will look like, thanks for waste some time in this discussion. I will try help always it 's possible. |
It will open multiple files when there are new updates for your database, and the overhead for doing that is minimal. We're not performing a directory scan, we're directly accessing files by name. When your database is up to date, it will only open one file. |
I have just a suggestion this time, in the onUpdateDatabase() the version could be passsed by parameter for the lua function instead of opening each file version, and the errors should be handled by lua using assert, so that what i think that could be improved, not something really important hahahaha.
something like that:
http://pastebin.com/2EihYUdx
The text was updated successfully, but these errors were encountered: