diff options
author | John Olheiser <42128690+jolheiser@users.noreply.github.com> | 2019-12-11 22:38:58 -0600 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-12-11 23:38:58 -0500 |
commit | 9ef148abeb1036e0d0b9899e71c95ecd20701dc4 (patch) | |
tree | cb62150f7ba610c200b4b4447bffbabae443deb5 | |
parent | f11df80058275a9b1ec83dc4a1b96df8d6d7d86e (diff) | |
download | gitea-9ef148abeb1036e0d0b9899e71c95ecd20701dc4.tar.gz gitea-9ef148abeb1036e0d0b9899e71c95ecd20701dc4.zip |
Fix migration releases (#9319) (#9326) (#9328)
* Only sync tags after all batches (#9319)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Add SyncTags to uploader interface (#9326)
* Add sync tags to interface
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix revive
Signed-off-by: jolheiser <john.olheiser@gmail.com>
-rw-r--r-- | modules/migrations/base/uploader.go | 1 | ||||
-rw-r--r-- | modules/migrations/gitea.go | 9 | ||||
-rw-r--r-- | modules/migrations/migrate.go | 5 |
3 files changed, 11 insertions, 4 deletions
diff --git a/modules/migrations/base/uploader.go b/modules/migrations/base/uploader.go index ae1be84b88..257c7a2909 100644 --- a/modules/migrations/base/uploader.go +++ b/modules/migrations/base/uploader.go @@ -12,6 +12,7 @@ type Uploader interface { CreateTopics(topic ...string) error CreateMilestones(milestones ...*Milestone) error CreateReleases(releases ...*Release) error + SyncTags() error CreateLabels(labels ...*Label) error CreateIssues(issues ...*Issue) error CreateComments(comments ...*Comment) error diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go index 81a6116a23..18f4da7584 100644 --- a/modules/migrations/gitea.go +++ b/modules/migrations/gitea.go @@ -288,11 +288,12 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { rels = append(rels, &rel) } - if err := models.InsertReleases(rels...); err != nil { - return err - } - // sync tags to releases in database + return models.InsertReleases(rels...) +} + +// SyncTags syncs releases with tags in the database +func (g *GiteaLocalUploader) SyncTags() error { return models.SyncReleasesWithTags(g.repo, g.gitRepo) } diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go index 7a5071e125..e2a2c8b7ec 100644 --- a/modules/migrations/migrate.go +++ b/modules/migrations/migrate.go @@ -165,6 +165,11 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts } releases = releases[relBatchSize:] } + + // Once all releases (if any) are inserted, sync any remaining non-release tags + if err := uploader.SyncTags(); err != nil { + return err + } } var commentBatchSize = uploader.MaxBatchInsertSize("comment") |