Skip to content
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

Closed
conde2 opened this issue Aug 5, 2013 · 3 comments
Closed

onUpdateDatabase() #25

conde2 opened this issue Aug 5, 2013 · 3 comments
Labels
enhancement Increase or improvement in quality, value, or extent
Milestone

Comments

@conde2
Copy link
Contributor

conde2 commented Aug 5, 2013

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

@marksamman
Copy link
Member

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?

@conde2
Copy link
Contributor Author

conde2 commented Aug 5, 2013

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.

@marksamman
Copy link
Member

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.

@marksamman marksamman modified the milestone: 1.0 Mar 19, 2014
@Donkey-Robot Donkey-Robot mentioned this issue Jan 5, 2016
rookgaard added a commit to rookgaard/forgottenserver that referenced this issue May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Increase or improvement in quality, value, or extent
Projects
None yet
Development

No branches or pull requests

2 participants