From 726e1e5279b6461cad8eee2e461c2c6d8ab0f075 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 29 May 2020 15:24:15 +0200 Subject: Doctor check & fix db consistency (#11111) needed to fix issue as described in #10280 * rename check-db to check-db-version * add check-db-consistency: * find issues without existing repository * find pulls without existing issues * find tracked times without existing issues/pulls * find labels without repository or org reference Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lunny Xiao --- models/models.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'models/models.go') diff --git a/models/models.go b/models/models.go index c818c65100..7f12d6260a 100644 --- a/models/models.go +++ b/models/models.go @@ -182,6 +182,10 @@ func SetEngine() (err error) { } // NewEngine initializes a new xorm.Engine +// This function must never call .Sync2() if the provided migration function fails. +// When called from the "doctor" command, the migration function is a version check +// that prevents the doctor from fixing anything in the database if the migration level +// is different from the expected value. func NewEngine(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err error) { if err = SetEngine(); err != nil { return err -- cgit v1.2.3