-
Notifications
You must be signed in to change notification settings - Fork 20
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
Database versioning and automatic upgrading #43
Comments
Migrations is the good concept for MySQL+PHP stack |
There is currently a folder of migration scripts located here: https://github.com/OneHourGameJam/OneHourGameJam/tree/master/SQL/migrations But these must be executed manually and there isn't a good way to determine which ones you need to execute to get from the version you're on to the most recent one... |
Really weird workaround would be to clear database, and then run those migrations in order every time. But we know how awful it is for performance and actual versioning. You can require last migration number in config. If none, all migrations are gonna run (database then should be cleared before). When user runs upgrade script, it iterates through migration files to find bigger order number (than one specified in config) and builds queue. |
The plan at the moment is to tie a migration file to a version, stored in config and compare it to a constant number somewhere in code. If the two don't match, migration scripts are ran. But that's not in the code yet, so you have to do it manually. |
@liambaloh would using https://flywaydb.org/ be an option? It uses a structure similar to the one that already exists in the SQL directory here. |
Eh, writing a database versioning script would take a few hours at most, probably not worth the annoyance of including another external dependency. It's just a version number and dictionary of database-version to sql query. If the version doesn't match the last entry in the list, find it and execute all SQL queries between it and the end, update the version number in the database once done. I'd like to keep external dependencies to a minimum, at least until #55 is done (and yes, I've been really bad with ignoring #70 for a long time until it got out of date, It's on me and I'm sorry 😢) |
My suggestion was probably too brief. 😃 I didn't intend to add flyway as a PHP dependency but use it as a command line tool. Not sure if that is feasible given that I don't need to admin this. 😉
This is basically what flyway does: https://flywaydb.org/getstarted/how |
Ah okay! That makes it way more appealing. There are two concerns that came to mind though:
Anyway, the way I make the migration files at the moment is by looking through the SQL history in MySQL Workbench (though we use MariaDB) |
yes. code. mhmm, PHP |
The database structure changes every so often. To make site upgrades easier, an automated system for DB upgrades should probably exist - something which simply updates the database with ALTER, CREATE and DROP statements as needed between versions.
(Low priority feature)
The text was updated successfully, but these errors were encountered: