From 5958553066d275c767018454fbed9470c2cf473d Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 15 Aug 2023 01:06:13 +0200 Subject: [PATCH] [DB] forgejo migration v1: add blocked user migration (cherry picked from commit 66afddd511d2821f648919925ea365cd085e4e77) (cherry picked from commit 19da0dee9df87cb946d1c8e25b917f7283d95302) (cherry picked from commit 0b725af693828bd7705b09433fb25d974fbb820e) (cherry picked from commit 64d4de2b664a9f406b2927c6e6b465ee2b3a8915) (cherry picked from commit 05bc9d3b7f8d00a37b41615f9caccca84a98c0ee) --- models/forgejo_migrations/migrate.go | 2 ++ models/forgejo_migrations/v1_20/v1.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 models/forgejo_migrations/v1_20/v1.go diff --git a/models/forgejo_migrations/migrate.go b/models/forgejo_migrations/migrate.go index 2abacb0679..268edef4f9 100644 --- a/models/forgejo_migrations/migrate.go +++ b/models/forgejo_migrations/migrate.go @@ -36,6 +36,8 @@ func NewMigration(desc string, fn func(*xorm.Engine) error) *Migration { // This is a sequence of additional Forgejo migrations. // Add new migrations to the bottom of the list. var migrations = []*Migration{ + // v0 -> v1 + NewMigration("Add Forgejo Blocked Users table", forgejo_v1_20.AddForgejoBlockedUser), // v1 -> v2 NewMigration("create the forgejo_sem_ver table", forgejo_v1_20.CreateSemVerTable), } diff --git a/models/forgejo_migrations/v1_20/v1.go b/models/forgejo_migrations/v1_20/v1.go new file mode 100644 index 0000000000..1097613655 --- /dev/null +++ b/models/forgejo_migrations/v1_20/v1.go @@ -0,0 +1,21 @@ +// Copyright 2023 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package forgejo_v1_20 //nolint:revive + +import ( + "code.gitea.io/gitea/modules/timeutil" + + "xorm.io/xorm" +) + +func AddForgejoBlockedUser(x *xorm.Engine) error { + type ForgejoBlockedUser struct { + ID int64 `xorm:"pk autoincr"` + BlockID int64 `xorm:"index"` + UserID int64 `xorm:"index"` + CreatedUnix timeutil.TimeStamp `xorm:"created"` + } + + return x.Sync(new(ForgejoBlockedUser)) +}