mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-01 13:46:49 +02:00
db: migrate badly joined provider identifiers
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
05072c2a3d
commit
3f4c3577fe
@ -695,6 +695,29 @@ AND auth_key_id NOT IN (
|
|||||||
},
|
},
|
||||||
Rollback: func(db *gorm.DB) error { return nil },
|
Rollback: func(db *gorm.DB) error { return nil },
|
||||||
},
|
},
|
||||||
|
// Fix the provider identifier for users that have a double slash in the
|
||||||
|
// provider identifier.
|
||||||
|
{
|
||||||
|
ID: "202505141324",
|
||||||
|
Migrate: func(tx *gorm.DB) error {
|
||||||
|
users, err := ListUsers(tx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("listing users: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, user := range users {
|
||||||
|
user.ProviderIdentifier.String = types.CleanIdentifier(user.ProviderIdentifier.String)
|
||||||
|
|
||||||
|
err := tx.Save(user).Error
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("saving user: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
Rollback: func(db *gorm.DB) error { return nil },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user