-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Migration system for sqlite #83
Conversation
Need more tests.
Add tests for DropColumns.
Also change the way we handle columns rename migration. SQLite restrict column addition not to have PRIMARY KEY and/or UNIQUE attribute, so we have to change from: add new column -> migrate data from old column to new column -> rename old table -> create new table with old columns removed -> migrate data from old table to the new table -> drop old table to directly: rename old table -> create new table with renamed columns -> migrate data from old table to the new table -> drop old table
Also add migration to tests.
thanks! this is really good work 👍 i'll get this merged shortly |
nice! |
Migration system for sqlite
@fudanchii this is working really well, great job! One last request. When a column is renamed (table is renamed, new table created, data copied, old table removed) we lose the indexes. We might be able to retrieve the indexes prior to renaming the column, and then re-execute: select * from sqlite_master where type = 'index' and tbl_name = 'repos' thoughts? |
Sure, I think I need a couple of steps to fetch all indices info before recreate it, I'll shoot another PR later tonight (GMT+7 here) :D Thanks! |
I choosed Rev3, because Rev2 will be about "open invitations" feature.
I choosed Rev3, because Rev2 will be about "open invitations" feature.
Are there any docs for how to use this? |
Not yet as of currently, it's a bit involved to document the components since we haven't document the overall architecture yet. But yes, I plan to setup some wiki article on this. |
@fudanchii maybe pull migration out of the drone to separate package with docs? |
@bradrydzewski what do you think? I will fork drone/docs repo and put some documentation over there. Thanks. |
I actually think your migration package might make a great project that others would find useful :) It is up to you though |
* Fix message encoding * Add prototype for BranchTagSelect component * Finish BranchAndTag component
Hey @bradrydzewski
I tried to integrate your migrate package and write some sqlite specific helper, it turns out quite nice in my opinion. ;)
It has nice wrapper for the migration step, so for most of the time we don't have to write raw sql on our own, for example
some minor caveats:
It still lacks index operation support but it's rather easy to add, I believe.
Also it doesn't have any parameter sanitization, but I'm sure we're not going to write our migration script from the web, so I'll leave it at that for now.
The migration driver implements
Operation
interface, which is accessible from within migration script. And it's possible to create more drivers for another database just by implementingOperation
interface and tell the main program to use that driver.Anyway, I'm not sure if this is already being worked on, or if it's not being planned to be something like this. So it's okay if you reject this PR just in case. :)
Thanks!