From 581a563cac5e910510f4f5cc54ccb4478193846f Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Mon, 14 Feb 2022 16:13:17 +0800
Subject: [PATCH] Ignore the migrate if u2f_registration is not exist (#18760)

---
 models/migrations/v209.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/models/migrations/v209.go b/models/migrations/v209.go
index c42aba245b..b4295d62fa 100644
--- a/models/migrations/v209.go
+++ b/models/migrations/v209.go
@@ -78,6 +78,14 @@ func increaseCredentialIDTo410(x *xorm.Engine) error {
 		return nil
 	}
 
+	exist, err := x.IsTableExist("u2f_registration")
+	if err != nil {
+		return err
+	}
+	if !exist {
+		return nil
+	}
+
 	// Now migrate the old u2f registrations to the new format
 	type u2fRegistration struct {
 		ID          int64 `xorm:"pk autoincr"`