Remove isInLocalDb flag, start dumping saves into S3

beta
Pancakes 1 month ago
parent ad8fa03503
commit 5480c2ee72
No known key found for this signature in database
GPG Key ID: 5792877BFA27DC8F

@ -132,7 +132,7 @@ func S3SaveMigration() error {
}
// retrieve accounts from db
accounts, err := db.GetLocalAccounts()
accounts, err := db.GetLocalSystemAccounts()
if err != nil {
return fmt.Errorf("failed to retrieve old accounts: %s", err)
}
@ -163,9 +163,9 @@ func S3SaveMigration() error {
continue
}
err = db.UpdateSystemSaveLocation(user)
err = db.DeleteSystemSaveData(user)
if err != nil {
log.Printf("failed to update location for user %s: %s", username, err)
log.Printf("failed to delete old save for user %s: %s", username, err)
continue
}

@ -108,6 +108,11 @@ func setupDb(tx *sql.Tx) error {
// MIGRATION 004
`ALTER TABLE accounts ADD COLUMN IF NOT EXISTS isInLocalDb TINYINT(1) NOT NULL DEFAULT 1`,
// ----------------------------------
// MIGRATION 005
`ALTER TABLE accounts DROP COLUMN IF EXISTS isInLocalDb`,
}
for _, q := range queries {

@ -98,7 +98,7 @@ func ReadSystemSaveData(uuid []byte) (defs.SystemSaveData, error) {
}
// delete the one in db
err = UpdateSystemSaveLocation(uuid)
err = DeleteSystemSaveData(uuid)
if err != nil {
return system, err
}
@ -259,9 +259,9 @@ func GetSystemSaveFromS3(uuid []byte) (defs.SystemSaveData, error) {
return session, nil
}
func GetLocalAccounts() ([][]byte, error) {
func GetLocalSystemAccounts() ([][]byte, error) {
var users [][]byte
rows, err := handle.Query("SELECT uuid FROM accounts WHERE isInLocalDb = 1) LIMIT 3000")
rows, err := handle.Query("SELECT uuid FROM systemSaveData LIMIT 3000")
if err != nil {
return nil, err
}
@ -280,17 +280,3 @@ func GetLocalAccounts() ([][]byte, error) {
return users, nil
}
func UpdateSystemSaveLocation(uuid []byte) error {
_, err := handle.Exec("UPDATE accounts SET isInLocalDb = 0 WHERE uuid = ?", uuid)
if err != nil {
return err
}
err = DeleteSystemSaveData(uuid)
if err != nil {
return err
}
return nil
}

Loading…
Cancel
Save