summaryrefslogtreecommitdiffstats
path: root/models/migrations/v1_18/v224.go
blob: f3d522b91a17a93f03b30a5d7ac76b53c008ab45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package v1_18 //nolint

import (
	"xorm.io/xorm"
)

func CreateUserBadgesTable(x *xorm.Engine) error {
	type Badge struct {
		ID          int64 `xorm:"pk autoincr"`
		Description string
		ImageURL    string
	}

	type userBadge struct {
		ID      int64 `xorm:"pk autoincr"`
		BadgeID int64
		UserID  int64 `xorm:"INDEX"`
	}

	if err := x.Sync(new(Badge)); err != nil {
		return err
	}
	return x.Sync(new(userBadge))
}