From 87a0a93fece245afdfe0744f316db7995a2d9e22 Mon Sep 17 00:00:00 2001 From: Lucas Teske Date: Mon, 11 Jan 2021 16:51:07 -0300 Subject: [PATCH] hotfix(rql): Fix RethinkDB Migration Queries --- pkg/database/rql/GPGKey.go | 6 +++--- pkg/database/rql/UserModel.go | 12 ++++++------ pkg/database/rql/UserToken.go | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/database/rql/GPGKey.go b/pkg/database/rql/GPGKey.go index 82d29d6..8eb7aa4 100644 --- a/pkg/database/rql/GPGKey.go +++ b/pkg/database/rql/GPGKey.go @@ -18,9 +18,9 @@ func (h *RethinkDBDriver) initGPGKeyTable() error { func (h *RethinkDBDriver) migrateGPGKeyTable() error { // Legacy fields - h.log.Info("Migrating old fields to new fields") + h.log.Info("[GPGKeys] Migrating old fields to new fields") result, err := r.Table(gpgKeyTableInit.TableName). - Filter(r.Row.HasFields("FullFingerPrint")). + Filter(r.Row.HasFields("FullFingerprint").Not()). Update(map[string]interface{}{ "FullFingerprint": r.Row.Field("FullFingerPrint"), }).RunWrite(h.conn) @@ -29,7 +29,7 @@ func (h *RethinkDBDriver) migrateGPGKeyTable() error { return err } - h.log.Info("Migrated %d tokens FullFingerPrint -> FullFingerprint", result.Updated) + h.log.Info("[GPGKeys] Migrated %d gpg keys FullFingerPrint -> FullFingerprint", result.Updated) return nil } diff --git a/pkg/database/rql/UserModel.go b/pkg/database/rql/UserModel.go index b38ecda..46de138 100644 --- a/pkg/database/rql/UserModel.go +++ b/pkg/database/rql/UserModel.go @@ -18,9 +18,9 @@ func (h *RethinkDBDriver) initUserTable() error { func (h *RethinkDBDriver) migrateUserTable() error { // Legacy fields - h.log.Info("Migrating old fields to new fields") + h.log.Info("[User] Migrating old fields to new fields") result, err := r.Table(userModelTableInit.TableName). - Filter(r.Row.HasFields("FingerPrint")). + Filter(r.Row.HasFields("Fingerprint").Not()). Update(map[string]interface{}{ "Fingerprint": r.Row.Field("FingerPrint"), }).RunWrite(h.conn) @@ -29,11 +29,11 @@ func (h *RethinkDBDriver) migrateUserTable() error { return err } - h.log.Info("Migrated %d users FingerPrint -> Fingerprint", result.Updated) + h.log.Info("[User] Migrated %d users FingerPrint -> Fingerprint", result.Updated) - h.log.Info("Migrating old fields to new fields") + h.log.Info("[User] Migrating old fields to new fields") result, err = r.Table(userModelTableInit.TableName). - Filter(r.Row.HasFields("Fullname")). + Filter(r.Row.HasFields("FullName").Not()). Update(map[string]interface{}{ "FullName": r.Row.Field("Fullname"), }).RunWrite(h.conn) @@ -42,7 +42,7 @@ func (h *RethinkDBDriver) migrateUserTable() error { return err } - h.log.Info("Migrated %d users Fullname -> FullName", result.Updated) + h.log.Info("[User] Migrated %d users Fullname -> FullName", result.Updated) return nil } diff --git a/pkg/database/rql/UserToken.go b/pkg/database/rql/UserToken.go index 85b45aa..0ccf0e5 100644 --- a/pkg/database/rql/UserToken.go +++ b/pkg/database/rql/UserToken.go @@ -19,9 +19,9 @@ func (h *RethinkDBDriver) initUserTokenTable() error { func (h *RethinkDBDriver) migrateUserTokenTable() error { // Legacy fields - h.log.Info("Migrating old fields to new fields") + h.log.Info("[UserToken] Migrating old fields to new fields") result, err := r.Table(userTokenTableInit.TableName). - Filter(r.Row.HasFields("FingerPrint")). + Filter(r.Row.HasFields("Fingerprint").Not()). Update(map[string]interface{}{ "Fingerprint": r.Row.Field("FingerPrint"), }).RunWrite(h.conn) @@ -30,7 +30,7 @@ func (h *RethinkDBDriver) migrateUserTokenTable() error { return err } - h.log.Info("Migrated %d tokens FingerPrint -> Fingerprint", result.Updated) + h.log.Info("[UserToken] Migrated %d tokens FingerPrint -> Fingerprint", result.Updated) return nil }