summaryrefslogtreecommitdiffstats
path: root/modules/doctor/dbconsistency.go
Commit message (Collapse)AuthorAgeFilesLines
* Refactor `setting.Database.UseXXX` to methods (#23354) (#23356)Giteabot2023-03-071-1/+1
| | | | | | | | | | | | | | | Backport #23354 Replace #23350. Refactor `setting.Database.UseMySQL` to `setting.Database.Type.IsMySQL()`. To avoid mismatching between `Type` and `UseXXX`. This refactor can fix the bug mentioned in #23350, so it should be backported. Co-authored-by: Jason Song <i@wolfogre.com>
* Implement FSFE REUSE for golang files (#21840)flynnnnnnnnnn2022-11-271-2/+1
| | | | | | | | | Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Add `context.Context` to more methods (#21546)KN4CK3R2022-11-191-11/+11
| | | | | | | This PR adds a context parameter to a bunch of methods. Some helper `xxxCtx()` methods got replaced with the normal name now. Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Prevent dangling user redirects (#21856)Gusted2022-11-181-0/+3
| | | | | | - It's possible that the `user_redirect` table contains a user id that no longer exists. - Delete a user redirect upon deleting the user. - Add a check for these dangling user redirects to check-db-consistency.
* Move some files into models' sub packages (#20262)Lunny Xiao2022-08-251-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * Move some files into models' sub packages * Move functions * merge main branch * Fix check * fix check * Fix some tests * Fix lint * Fix lint * Revert lint changes * Fix error comments * Fix lint Co-authored-by: 6543 <6543@obermui.de>
* Backtick table name in generic orphan check (#20019)Gusted2022-06-191-2/+2
|
* Add dbconsistency checks for Stopwatches (#20010)zeripath2022-06-181-0/+6
| | | | | | | | | | It appears possible that stopwatches can become orphaned or have been orphaned in the past. This PR adds Orphan checks for Stopwatches. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Move issues related files into models/issues (#19931)Lunny Xiao2022-06-131-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Move access and repo permission to models/perm/access * fix test * fix git test * Move functions sequence * Some improvements per @KN4CK3R and @delvh * Move issues related code to models/issues * Move some issues related sub package * Merge * Fix test * Fix test * Fix test * Fix test * Rename some files
* [doctor] pq: syntax error at or near "." quote user table name (#19765)silentcodeg2022-05-201-2/+2
|
* Add doctor orphan check for orphaned pull requests without an existing base ↵silentcodeg2022-05-181-0/+3
| | | | repo (#19731)
* Delete user related oauth stuff on user deletion too (#19677)65432022-05-111-0/+9
| | | | | * delete user related oauth stuff on user deletion too * extend doctor check-db-consistency
* [doctor] Add check/fix for bogus action rows (#19656)singuliere2022-05-101-0/+9
| | | | Signed-off-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Loïc Dachary <loic@dachary.org>
* Propagate context and ensure git commands run in request context (#17868)zeripath2022-01-191-4/+4
| | | | | | | | | This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Quote references to the user table in consistency checks (#18072)zeripath2021-12-221-2/+2
| | | | | | | | Although #17487 ensured that the table was quoted in the join it missed that the query part of the check also needed to be quoted. Fix #17485 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Move attachment into models/repo/ (#17650)Lunny Xiao2021-11-191-2/+3
| | | | | | | * Move attachment into models/repo/ * Fix test * Fix bug
* Rename db Engines related functions (#17481)Lunny Xiao2021-10-301-1/+1
| | | | | * Rename db Engines related functions Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Nicely handle missing user in collaborations (#17049)zeripath2021-09-271-253/+138
| | | | | | | | | | | | | | | | * Nicely handle missing user in collaborations It is possible to have a collaboration in a repository which refers to a no-longer existing user. This causes the repository transfer to fail with an unusual error. This PR makes `repo.getCollaborators()` nicely handle the missing user by ghosting the collaboration but also adds consistency check. It also adds an Access consistency check. Fix #17044 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Move db related basic functions to models/db (#17075)Lunny Xiao2021-09-191-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | * Move db related basic functions to models/db * Fix lint * Fix lint * Fix test * Fix lint * Fix lint * revert unnecessary change * Fix test * Fix wrong replace string * Use *Context * Correct committer spelling and fix wrong replaced words Co-authored-by: zeripath <art27@cantab.net>
* Add doctor dbconsistency check for release and attachment (#16978)Lunny Xiao2021-09-141-0/+36
|
* Delete references if repository gets deleted (#15681)KN4CK3R2021-04-301-9/+46
| | | | | | | * Remove DeletedBranch and LFSLocks. * Sort beans. Co-authored-by: zeripath <art27@cantab.net>
* Delete protected branch if repository gets removed (#15658)KN4CK3R2021-04-301-8/+26
| | | | | | | * Added missing error parameters. * Delete protected branch if repository gets removed. * Added doctor fix.
* Delete Labels & IssueLabels on Repo Delete too (#15039)65432021-03-191-1/+18
| | | | | | | | | | | | | | | | | | | | | | | * Doctor: find IssueLabels without existing label * on Repo Delete: delete labels & issue_labels too * performance nits * Add Migration: Delete orphaned IssueLabels * Migration v174: use Sync2 * USE sess !!! * better func name * code format & comment * RAW SQL * Update models/migrations/v176.go * next try?
* Prevent addition of labels from outside the repository or organisation in ↵zeripath2021-03-191-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | issues (#14912) * Never add labels not from this repository or organisation and remove org labels on transfer Prevent the addition of labels from outside of the repository or organisation and remove organisation labels on transfer. Related #14908 Signed-off-by: Andrew Thornton <art27@cantab.net> * switch to use sql Signed-off-by: Andrew Thornton <art27@cantab.net> * remove AS Signed-off-by: Andrew Thornton <art27@cantab.net> * subquery alias Signed-off-by: Andrew Thornton <art27@cantab.net> * Give me some AS? Signed-off-by: Andrew Thornton <art27@cantab.net> * double AS Signed-off-by: Andrew Thornton <art27@cantab.net> * try try again Signed-off-by: Andrew Thornton <art27@cantab.net> * once more around the merry go round Signed-off-by: Andrew Thornton <art27@cantab.net> * fix api problem Signed-off-by: Andrew Thornton <art27@cantab.net> * Add outside label consistency check into doctor This PR adds another consistency check into doctor in order to detect labels that have been added from outside of repositories and organisations Fix #14908 Signed-off-by: Andrew Thornton <art27@cantab.net> * fix migration Signed-off-by: Andrew Thornton <art27@cantab.net> * prep for merge Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
* Fix postgres ID sequences broken by recreate-table (#15015)zeripath2021-03-181-0/+20
| | | | | | | | | | | | | | | | | | | | | * Fix postgres ID sequences broken by recreate-table Unfortunately there is a subtle problem with recreatetable on postgres which leads to the sequences not being renamed and not being left at 0. Fix #14725 Signed-off-by: Andrew Thornton <art27@cantab.net> * let us try information_schema instead Signed-off-by: Andrew Thornton <art27@cantab.net> * try again Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: 6543 <6543@obermui.de>
* Prevent adding nil label to .AddedLabels or .RemovedLabels (#14623)zeripath2021-02-101-0/+18
| | | | | | | | | | | | | | | | | | * Prevent adding nil label to .AddedLabels or .RemovedLabels There are possibly a few old databases out there with malmigrated data that can cause panics with empty labels being migrated. This PR adds a few tests to prevent nil labels being added. Fix #14466 Signed-off-by: Andrew Thornton <art27@cantab.net> * Add doctor command to remove the broken label comments Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Refactor doctor (#12264)zeripath2020-12-021-0/+127
* Refactor Logger Refactor Logger to make a logger interface and make it possible to wrap loggers for specific purposes. * Refactor Doctor Move the gitea doctor functions into its own module. Use a logger for its messages instead of returning a results string[] Signed-off-by: Andrew Thornton <art27@cantab.net> * Update modules/doctor/misc.go Co-authored-by: 6543 <6543@obermui.de> * Update modules/doctor/misc.go Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>