Skip to content

Commit

Permalink
Merge pull request #93 from quan-to/hotfix/QueryMigration
Browse files Browse the repository at this point in the history
[HOTFIX] Fix RethinkDB Migration Queries
  • Loading branch information
racerxdl authored Jan 11, 2021
2 parents 55f1b16 + 87a0a93 commit a89b6d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pkg/database/rql/GPGKey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/database/rql/UserModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/database/rql/UserToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down

0 comments on commit a89b6d1

Please sign in to comment.