mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
Migrate DB: rename table is plural, order matters
The calls to AutoMigrate to other classes that refer to users will create the table and it will break, it needs to be done before everything else. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
81441afe70
commit
9eaa8dd049
1 changed files with 7 additions and 7 deletions
14
db.go
14
db.go
|
@ -41,6 +41,13 @@ func (h *Headscale) initDB() error {
|
|||
db.Exec(`create extension if not exists "uuid-ossp";`)
|
||||
}
|
||||
|
||||
_ = db.Migrator().RenameTable("namespaces", "users")
|
||||
|
||||
err = db.AutoMigrate(&User{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_ = db.Migrator().RenameColumn(&Machine{}, "ip_address", "ip_addresses")
|
||||
_ = db.Migrator().RenameColumn(&Machine{}, "name", "hostname")
|
||||
|
||||
|
@ -187,13 +194,6 @@ func (h *Headscale) initDB() error {
|
|||
return err
|
||||
}
|
||||
|
||||
_ = db.Migrator().RenameTable("Namespace", "User")
|
||||
|
||||
err = db.AutoMigrate(&User{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = db.AutoMigrate(&PreAuthKey{})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue