Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a empty database start, initdb complains that the datadir is not empty #52

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading