Skip to content

Commit

Permalink
check non-nil err
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed May 12, 2024
1 parent c107e97 commit e65b18e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/database/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var postgresMigrations = []migration{
defer tx.Rollback()

_, err = tx.Exec(`ALTER TABLE bookmark ADD COLUMN has_content BOOLEAN DEFAULT FALSE NOT NULL`)
if strings.Contains(err.Error(), `column "has_content" of relation "bookmark" already exists`) {
if err != nil && strings.Contains(err.Error(), `column "has_content" of relation "bookmark" already exists`) {
tx.Rollback()
} else if err != nil {
return fmt.Errorf("failed to add has_content column to bookmark table: %w", err)
Expand All @@ -45,7 +45,7 @@ var postgresMigrations = []migration{
defer tx.Rollback()

_, err = tx.Exec(`ALTER TABLE account ADD COLUMN config JSONB NOT NULL DEFAULT '{}'`)
if strings.Contains(err.Error(), `column "config" of relation "account" already exists`) {
if err != nil && strings.Contains(err.Error(), `column "config" of relation "account" already exists`) {
tx.Rollback()
} else if err != nil {
return fmt.Errorf("failed to add config column to account table: %w", err)
Expand Down

0 comments on commit e65b18e

Please sign in to comment.