forgejo/models/issues
Mathieu Fenniak 187ad99f3c feat: add foreign keys to stopwatch & tracked_time tables (#9373)
Adds four foreign keys:
- stopwatch -- issue_id -> issue, user_id -> user
- tracked_time -- issue_id -> issue, user_id -> user

The majority of work encompassed in this PR is updating testing and support infrastructure to support foreign keys:
- `models/db/foreign_keys.go` adds new capabilities to sort registered tables into the right insertion order to avoid violating foreign keys
- `RecreateTables`, used by migration testing and the `doctor recreate-table` CLI, has been updated to support tables with foreign keys; new restrictions require that FK-related tables be rebuilt at the same time
- test fixture data is inserted in foreign-key order, and deleted in the reverse

An upgrade to xorm v1.3.9-forgejo.2 is incorporated in this PR, as two unexpected behaviors in the foreign key schema management were discovered during development of the updated `RecreateTables` routine.

Work in this PR is laid out to be reviewed easier commit-by-commit.

## 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...
  - [x] in their respective `*_test.go` for unit tests.
  - [x] 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.
- [x] 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.
- [ ] I want the title to show in the release notes with a link to this pull request.
- [x] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9373
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-10-01 00:31:38 +02:00
..
TestGetUIDsAndStopwatch feat: add foreign keys to stopwatch & tracked_time tables (#9373) 2025-10-01 00:31:38 +02:00
action_aggregator.go feat(ui): add links to review request targets in issue comments (#8239) 2025-07-23 04:45:58 +02:00
action_aggregator_test.go feat(ui): add links to review request targets in issue comments (#8239) 2025-07-23 04:45:58 +02:00
assignees.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
assignees_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
comment.go fix: ignore existence of commits for force pushes (#9262) 2025-09-12 07:27:15 +02:00
comment_code.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
comment_list.go fix: load OldMilestone based on OldMilestoneID, not MilestoneID (#8330) 2025-06-29 12:08:03 +02:00
comment_list_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
comment_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
content_history.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
content_history_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
dependency.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
dependency_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue.go fix(ui): show participants in mention suggestions in pr review (#8363) 2025-09-04 23:29:34 +02:00
issue_index.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_index_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_label.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_label_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_list.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_list_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
issue_lock.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_project.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_project_test.go chore: merge tests.AddFixtures and unittest.OverrideFixtures (#7648) 2025-04-25 09:14:33 +00:00
issue_search.go fix: do not display the title of unsubscribed issues or pull requests in the notification web page (#9362) 2025-09-19 22:32:06 +02:00
issue_stats.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_stats_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_test.go fix: do not display the title of unsubscribed issues or pull requests in the notification web page (#9362) 2025-09-19 22:32:06 +02:00
issue_update.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
issue_user.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_user_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_watch.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_watch_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_xref.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_xref_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
label.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
label_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
main_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
milestone.go feat(ui): add links to milestones and projects in issue comments (#7992) 2025-06-23 23:31:51 +02:00
milestone_list.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
milestone_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
moderation.go feat: Admin interface for abuse reports (#7905) 2025-07-23 00:20:15 +02:00
moderation_test.go feat: Admin interface for abuse reports (#7905) 2025-07-23 00:20:15 +02:00
pull.go blob: use NewTruncatedReader for CodeOwners parsing 2025-06-20 20:43:10 +02:00
pull_list.go feat: show more relevant results for 'dependencies' dropdown (#8003) 2025-06-26 20:06:21 +02:00
pull_test.go [gitea] week 2025-21 cherry pick (gitea/main -> forgejo) (#8040) 2025-06-16 20:27:47 +02:00
reaction.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
reaction_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
review.go fix: PR not blocked by review request for a whitelisted team (#8511) 2025-07-15 23:21:42 +02:00
review_list.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
review_test.go fix: PR not blocked by review request for a whitelisted team (#8511) 2025-07-15 23:21:42 +02:00
stopwatch.go feat: add foreign keys to stopwatch & tracked_time tables (#9373) 2025-10-01 00:31:38 +02:00
stopwatch_test.go chore: merge tests.AddFixtures and unittest.OverrideFixtures (#7648) 2025-04-25 09:14:33 +00:00
tracked_time.go feat: add foreign keys to stopwatch & tracked_time tables (#9373) 2025-10-01 00:31:38 +02:00
tracked_time_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00