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 {