From e9adfcd6782d0237a14b4271913c1dff27b6e2f7 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 13:06:49 +0000 Subject: [PATCH 1/2] Migrate ip_address field to ip_addresses The automatic migration did not pick up this change and it breaks current setups as it only adds a new field which is empty. This means that clients who dont request a new IP will not have any IP at all. --- db.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/db.go b/db.go index 51363256..256f1bf3 100644 --- a/db.go +++ b/db.go @@ -30,18 +30,24 @@ func (h *Headscale) initDB() error { if h.dbType == Postgres { db.Exec("create extension if not exists \"uuid-ossp\";") } + + _ = db.Migrator().RenameColumn(&Machine{}, "ip_address", "ip_addresses") + err = db.AutoMigrate(&Machine{}) if err != nil { return err } + err = db.AutoMigrate(&KV{}) if err != nil { return err } + err = db.AutoMigrate(&Namespace{}) if err != nil { return err } + err = db.AutoMigrate(&PreAuthKey{}) if err != nil { return err From 9e3318ca27b61e8a203821e5794abf9663c601a5 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 14:53:40 +0000 Subject: [PATCH 2/2] Simplify postgres uuid-ossp stirng --- db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db.go b/db.go index 256f1bf3..7b777863 100644 --- a/db.go +++ b/db.go @@ -28,7 +28,7 @@ func (h *Headscale) initDB() error { h.db = db if h.dbType == Postgres { - db.Exec("create extension if not exists \"uuid-ossp\";") + db.Exec(`create extension if not exists "uuid-ossp";`) } _ = db.Migrator().RenameColumn(&Machine{}, "ip_address", "ip_addresses")