summaryrefslogtreecommitdiffstats
path: root/models/repo/release.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo/release.go')
-rw-r--r--models/repo/release.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/models/repo/release.go b/models/repo/release.go
index 191475d541..0e92474365 100644
--- a/models/repo/release.go
+++ b/models/repo/release.go
@@ -552,3 +552,31 @@ func (r *Release) GetExternalName() string { return r.OriginalAuthor }
// ExternalID ExternalUserRemappable interface
func (r *Release) GetExternalID() int64 { return r.OriginalAuthorID }
+
+// InsertReleases migrates release
+func InsertReleases(rels ...*Release) error {
+ ctx, committer, err := db.TxContext(db.DefaultContext)
+ if err != nil {
+ return err
+ }
+ defer committer.Close()
+ sess := db.GetEngine(ctx)
+
+ for _, rel := range rels {
+ if _, err := sess.NoAutoTime().Insert(rel); err != nil {
+ return err
+ }
+
+ if len(rel.Attachments) > 0 {
+ for i := range rel.Attachments {
+ rel.Attachments[i].ReleaseID = rel.ID
+ }
+
+ if _, err := sess.NoAutoTime().Insert(rel.Attachments); err != nil {
+ return err
+ }
+ }
+ }
+
+ return committer.Commit()
+}