Skip to content

Commit

Permalink
Update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Barillas committed Mar 3, 2024
1 parent cf32d0b commit a0478ad
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backends/postgres/postgres_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func txFromContext(ctx context.Context) (t pgx.Tx, err error) {
func (p *PgBackend) initializeDB() (err error) {
migrations, err := iofs.New(migrationsFS, "migrations")
if err != nil {
err = fmt.Errorf("unable to run migrations, error during iofs new: %w", err)
p.logger.Error("unable to run migrations", slog.Any("error", err))
return
}
Expand All @@ -336,12 +337,14 @@ func (p *PgBackend) initializeDB() (err error) {
// So we must first sanitize connection strings for pq
pqConnectionString, err := GetPQConnectionString(p.config.ConnectionString)
if err != nil {
err = fmt.Errorf("unable to run migrations, error parsing connection string: %w", err)
p.logger.Error("unable to run migrations", slog.Any("error", err))
return
}

m, err := migrate.NewWithSourceInstance("iofs", migrations, pqConnectionString)
if err != nil {
err = fmt.Errorf("unable to run migrations, could not create new source: %w", err)
p.logger.Error("unable to run migrations", slog.Any("error", err))
return
}
Expand All @@ -350,6 +353,7 @@ func (p *PgBackend) initializeDB() (err error) {

err = m.Up()
if err != nil && !errors.Is(err, migrate.ErrNoChange) {
err = fmt.Errorf("unable to run migrations, could not apply up migration: %w", err)
p.logger.Error("unable to run migrations", slog.Any("error", err))
return
}
Expand Down

0 comments on commit a0478ad

Please sign in to comment.