Skip to content

Commit

Permalink
If a empty database start, initdb complains that the datadir is not e…
Browse files Browse the repository at this point in the history
…mpty (#52)
  • Loading branch information
majst01 authored Aug 23, 2023
1 parent 0cdb888 commit 2d116e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/internal/database/postgres/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ 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) {
db.log.Infof("%q is not present, no upgrade required", pgVersionFile)
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 {
Expand Down

0 comments on commit 2d116e0

Please sign in to comment.