-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix migration order v1.3 #3157
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
Fix migration order v1.3 #3157
Conversation
LGTM |
Did file name renames to match real migration version, so diff does looks bigger than actual changes are because of that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any changes to the migrations (other than reordering/renaming)? It's hard to tell with the diff.
models/migrations/migrations.go
Outdated
@@ -59,6 +59,10 @@ type Version struct { | |||
Version int64 | |||
} | |||
|
|||
func emptyMigtation(x *xorm.Engine) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg :) thanks :)
@ethantkoenig Not really, just skipping column drop errors (in case migration is being run second time) |
@ethantkoenig fixed typo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one nit: could we add comments to where errors are ignored? It will help future readers understand what's going on, and may be useful if there turns out to be something wrong in this PR (hopefully not, but let's be safe).
8d28831
to
563db61
Compare
@ethantkoenig added comment before ignored error warn log message |
|
models/migrations/v45.go
Outdated
@@ -18,6 +18,7 @@ func removeIndexColumnFromRepoUnitTable(x *xorm.Engine) (err error) { | |||
log.Warn("Unable to drop columns in SQLite") | |||
case setting.UseMySQL, setting.UsePostgreSQL, setting.UseMSSQL, setting.UseTiDB: | |||
if _, err := x.Exec("ALTER TABLE repo_unit DROP COLUMN `index`"); err != nil { | |||
// Ignoring this error in case we run this migration second time (after migration reordeting) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not ignoring this error. Also typo (reordeting)
EDIT: I meant we are not currently ignornig this error; I did not mean that we shouldn't ignore this error. Sorry for any confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then there is no way to fix this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least I don't see how we can fix to run 3 migrations again that were not run for all who upgraded from 1.2 -> 1.3 without running them for all and ignoring this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean; can't we just replace the return with log.Warn
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ethantkoenig I already do log.Warn this error, see code below this comment. By ignoring I meant we do not fail migration by returning error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 22 (directly beneath this comment) is a return
statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooooh... Sry, just woke up and did not have my coffee yet :))) I thought you are saying this error can't be ignored but I just have added comment also to wrong file :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you are commenting on v51 migration where there is log.Warn and same comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I don't want to block an important bug fix, so we can fix nits later
@ethantkoenig fixed :) |
Thanks for fixing this so quickly! One note, though: It might be a good idea to add a comment to |
Yes, I will add comment in master branch code |
@lafriks Are there any corruptions to the database when I have already upgraded to 1.3 and if yes will this also be automatically fixed? |
@moritz-h there is just missing migrations so some features might not work as expected. Yes, 1.3.2 release will fix that. |
@lafriks maybe we should add a deprecated message on 1.3.X releases messages when 1.3.2 is release ? To indicate the existing bug. |
All not latest minor versions should be considered deprecated by default :) |
Specific to 1.3.x release when upgrading from 1.2.x
Fixes #3155
PR to fix on master branch will follow in other PR so that there is no problems when upgrading from 1.2.x and 1.3.x to 1.4.0