Browse Source

add dataset migration

tags/v1.21.12.1
yan 5 years ago
parent
commit
c734eacb97
4 changed files with 59 additions and 0 deletions
  1. +23
    -0
      models/dataset.go
  2. +1
    -0
      models/migrations/migrations.go
  3. +34
    -0
      models/migrations/v140.go
  4. +1
    -0
      models/models.go

+ 23
- 0
models/dataset.go View File

@@ -0,0 +1,23 @@
package models

import (
"code.gitea.io/gitea/modules/timeutil"
)

// Issue represents an issue or pull request of repository.
type Dataset struct {
ID int64 `xorm:"pk autoincr"`
Title string `xorm:"INDEX NOT NULL"`
Status int32 `xorm:"INDEX"`
Category string
Description string `xorm:"TEXT"`
Download_times int64
License string
Task string
Release_id int64 `xorm:"INDEX"`
User_id int64 `xorm:"INDEX"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`

Attachments []*Attachment `xorm:"-"`
}

+ 1
- 0
models/migrations/migrations.go View File

@@ -212,6 +212,7 @@ var migrations = []Migration{
NewMigration("Add ResolveDoerID to Comment table", addResolveDoerIDCommentColumn),
// v139 -> v140
NewMigration("prepend refs/heads/ to issue refs", prependRefsHeadsToIssueRefs),
NewMigration("add dataset migration", addDatasetTable),
}

// GetCurrentDBVersion returns the current db version


+ 34
- 0
models/migrations/v140.go View File

@@ -0,0 +1,34 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package migrations

import (
"fmt"

"code.gitea.io/gitea/modules/timeutil"
"xorm.io/xorm"
)

func addDatasetTable(x *xorm.Engine) error {
type Dataset struct {
ID int64 `xorm:"pk autoincr"`
Title string `xorm:"INDEX NOT NULL"`
Status int32 `xorm:"INDEX"`
Category string
Description string `xorm:"TEXT"`
Download_times int64
License string
Task string
Release_id int64 `xorm:"INDEX"`
User_id int64 `xorm:"INDEX"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

if err := x.Sync2(new(Dataset)); err != nil {
return fmt.Errorf("Sync2: %v", err)
}
return nil
}

+ 1
- 0
models/models.go View File

@@ -125,6 +125,7 @@ func init() {
new(Task),
new(LanguageStat),
new(EmailHash),
new(Dataset),
)

gonicNames := []string{"SSL", "UID"}


Loading…
Cancel
Save