aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-03-10 22:04:55 +0000
committerGitHub <noreply@github.com>2022-03-10 23:04:55 +0100
commit886b1de94914186a502ed68a6a281a15f1d8d9a3 (patch)
treea915972a413787570a39db01d0b0152c63aa2fd8 /models/migrations
parenta0db075f21e961b687221a8b9ed9defb26d2624e (diff)
downloadgitea-886b1de94914186a502ed68a6a281a15f1d8d9a3.tar.gz
gitea-886b1de94914186a502ed68a6a281a15f1d8d9a3.zip
Update the webauthn_credential_id_sequence in Postgres (#19048)
* Update the webauthn_credential_id_sequence in Postgres There is (yet) another problem with v210 in that Postgres will silently allow preset ID insertions ... but it will not update the sequence value. This PR simply adds a little step to the end of the v210 migration to update the sequence number. Users who have already migrated who find that they cannot insert new webauthn_credentials into the DB can either run: ```bash gitea doctor recreate-table webauthn_credential ``` or ```bash ./gitea doctor --run=check-db-consistency --fix ``` which will fix the bad sequence. Fix #19012 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/v210.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/models/migrations/v210.go b/models/migrations/v210.go
index dafe355fe2..f32fae77ba 100644
--- a/models/migrations/v210.go
+++ b/models/migrations/v210.go
@@ -174,5 +174,11 @@ func remigrateU2FCredentials(x *xorm.Engine) error {
regs = regs[:0]
}
+ if x.Dialect().URI().DBType == schemas.POSTGRES {
+ if _, err := x.Exec("SELECT setval('webauthn_credential_id_seq', COALESCE((SELECT MAX(id)+1 FROM `webauthn_credential`), 1), false)"); err != nil {
+ return err
+ }
+ }
+
return nil
}