Skip to content

Commit 8aaeaed

Browse files
author
Laurie T. Malau
committed
[public api] personal access token db model
1 parent ca3f94d commit 8aaeaed

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License-AGPL.txt in the project root for license information.
4+
5+
package common_db
6+
7+
import (
8+
"github.com/google/uuid"
9+
"time"
10+
)
11+
12+
type PersonalAccessToken struct {
13+
ID uuid.UUID `gorm:"primary_key;column:id;type:varchar;size:255;" json:"id"`
14+
UserID uuid.UUID `gorm:"column:userId;type:varchar;size:255;" json:"userId"`
15+
Hash string `gorm:"column:hash;type:varchar;size:255;" json:"hash"`
16+
Name string `gorm:"column:name;type:varchar;size:255;" json:"name"`
17+
Description string `gorm:"column:description;type:varchar;size:255;" json:"description"`
18+
Scopes []string `gorm:"column:scopes;type:text;size:65535;" json:"scopes"`
19+
ExpirationTime time.Time `gorm:"column:expirationTime;type:timestamp;" json:"expirationTime"`
20+
CreatedAt time.Time `gorm:"column:createdAt;type:timestamp;default:CURRENT_TIMESTAMP(6);" json:"createdAt"`
21+
LastModified time.Time `gorm:"column:_lastModified;type:timestamp;default:CURRENT_TIMESTAMP(6);" json:"_lastModified"`
22+
23+
// deleted is reserved for use by db-sync.
24+
_ bool `gorm:"column:deleted;type:tinyint;default:0;" json:"deleted"`
25+
}
26+
27+
// TableName sets the insert table name for this struct type
28+
func (d *PersonalAccessToken) TableName() string {
29+
return "d_b_personal_access_token"
30+
}

components/common-go/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ require (
3636

3737
require (
3838
github.com/go-sql-driver/mysql v1.6.0
39+
github.com/google/uuid v1.1.2
3940
github.com/relvacode/iso8601 v1.1.0
4041
gorm.io/driver/mysql v1.4.4
4142
gorm.io/gorm v1.24.1

components/common-go/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)