jojo/models/gitea_migrations
Mathieu Fenniak 81cce58a48 migration: update existing foreign key migrations to automatically fix inconsistencies (#10568)
Changes foreign key database inconsistency handling so that inconsistent records are automatically deleted with an administrator warning during migration.  As noted in discussion: https://codeberg.org/forgejo/discussions/issues/385#issuecomment-9175566

Intended for backport to v14 to eliminate pain during upgrades.

Because these migrations are now deleting data, rather than allowing the administrator to do it, all migrations have been covered with an integration test that verifies expected data is deleted.  This is particularly interesting with nullable fields.

## 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.
  - [ ] 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.
- [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.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10568
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-12-29 02:50:20 +01:00
..
base chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
fixtures migration: update existing foreign key migrations to automatically fix inconsistencies (#10568) 2025-12-29 02:50:20 +01:00
test refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
v1_6 chore: unify the usage of CryptoRandomString (#10110) 2025-11-15 13:24:53 +01:00
v1_7 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_8 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_9 chore: unify the usage of CryptoRandomString (#10110) 2025-11-15 13:24:53 +01:00
v1_10 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_11 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_12 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_13 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_14 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_15 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_16 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_17 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_18 refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
v1_19 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_20 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_21 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_22 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
v1_23 chore: rename 'migrations' to 'gitea_migrations' 2025-10-14 14:40:49 -06:00
main_test.go fix: strict error handling on corrupted DB migration tracking tables (#9773) 2025-10-20 18:03:30 +02:00
migrations.go chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
migrations_test.go fix: strict error handling on corrupted DB migration tracking tables (#9773) 2025-10-20 18:03:30 +02:00