mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
Fixes [#3525](https://codeberg.org/forgejo/forgejo/issues/3525) and supersedes [#9586](https://codeberg.org/forgejo/forgejo/pulls/9586) ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Features - [PR](https://codeberg.org/forgejo/forgejo/pulls/9829): <!--number 9829 --><!--line 0 --><!--description Y2hvcmU6IFJlbW92ZSBJc0RlbGV0ZWQgZnJvbSBhY3Rpb24gKGFjdGl2aXR5KSB0YWJsZQ==-->chore: Remove IsDeleted from action (activity) table<!--description--> <!--end release-notes-assistant--> Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9829 Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org> Co-authored-by: Leni Kadali <lenikadali@noreply.codeberg.org> Co-committed-by: Leni Kadali <lenikadali@noreply.codeberg.org>
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
// Copyright 2025 The Forgejo Authors.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package forgejo_migrations
|
|
|
|
import (
|
|
"testing"
|
|
|
|
migration_tests "forgejo.org/models/gitea_migrations/test"
|
|
"forgejo.org/modules/timeutil"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"xorm.io/xorm/schemas"
|
|
)
|
|
|
|
func Test_removeIsDeletedColumnFromActivityActionTable(t *testing.T) {
|
|
type Action struct {
|
|
ID int64 `xorm:"pk autoincr"`
|
|
UserID int64 `xorm:"INDEX"` // Receiver user id.
|
|
ActUserID int64 // Action user id.
|
|
RepoID int64
|
|
CommentID int64 `xorm:"INDEX"`
|
|
IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
|
|
RefName string
|
|
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
|
|
Content string `xorm:"TEXT"`
|
|
CreatedUnix timeutil.TimeStamp `xorm:"created"`
|
|
}
|
|
|
|
// Prepare TestEnv
|
|
x, deferable := migration_tests.PrepareTestEnv(t, 0,
|
|
new(Action),
|
|
)
|
|
defer deferable()
|
|
if x == nil || t.Failed() {
|
|
return
|
|
}
|
|
|
|
// test for expected results
|
|
getColumn := func(tn, co string) *schemas.Column {
|
|
tables, err := x.DBMetas()
|
|
require.NoError(t, err)
|
|
var table *schemas.Table
|
|
for _, elem := range tables {
|
|
if elem.Name == tn {
|
|
table = elem
|
|
break
|
|
}
|
|
}
|
|
return table.GetColumn(co)
|
|
}
|
|
|
|
require.NotNil(t, getColumn("action", "is_deleted"))
|
|
_, err := x.Table("action").Count()
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, removeIsDeletedColumnFromActivityActionTable(x))
|
|
|
|
require.Nil(t, getColumn("action", "is_deleted"))
|
|
cnt2, err := x.Table("action").Count()
|
|
require.NoError(t, err)
|
|
require.Equal(t, int64(0), cnt2)
|
|
}
|