From 304202fdf45a23d003dfcba5de02ef192b79d2e9 Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 23 Aug 2023 07:46:21 +0200 Subject: [PATCH] If a empty database start, initdb complains that the datadir is not empty --- cmd/internal/database/postgres/upgrade.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/internal/database/postgres/upgrade.go b/cmd/internal/database/postgres/upgrade.go index d567112..7ae5515 100644 --- a/cmd/internal/database/postgres/upgrade.go +++ b/cmd/internal/database/postgres/upgrade.go @@ -35,11 +35,6 @@ var ( func (db *Postgres) Upgrade() error { start := time.Now() - err := db.copyPostgresBinaries() - if err != nil { - return err - } - // First check if there are data already present pgVersionFile := path.Join(db.datadir, postgresVersionFile) if _, err := os.Stat(pgVersionFile); errors.Is(err, fs.ErrNotExist) { @@ -47,6 +42,12 @@ func (db *Postgres) Upgrade() error { return nil } + // If this is a database directory, save actual postgres binaries for a later major upgrade + err := db.copyPostgresBinaries() + if err != nil { + return err + } + // Check if required commands are present for _, command := range requiredCommands { if ok := db.isCommandPresent(command); !ok {