Skip to content

Commit

Permalink
apply to mysql and sqlite too
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed May 12, 2024
1 parent e65b18e commit e0fa4cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/database/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var mysqlMigrations = []migration{
defer tx.Rollback()

_, err = tx.Exec(`ALTER TABLE bookmark ADD COLUMN has_content BOOLEAN DEFAULT 0`)
if strings.Contains(err.Error(), `Duplicate column name`) {
if err != nil && strings.Contains(err.Error(), `Duplicate column name`) {
tx.Rollback()
} else if err != nil {
return fmt.Errorf("failed to add has_content column to bookmark table: %w", err)
Expand All @@ -49,7 +49,7 @@ var mysqlMigrations = []migration{
defer tx.Rollback()

_, err = tx.Exec(`ALTER TABLE account ADD COLUMN config JSON NOT NULL DEFAULT '{}'`)
if strings.Contains(err.Error(), `Duplicate column name`) {
if err != nil && strings.Contains(err.Error(), `Duplicate column name`) {
tx.Rollback()
} else if err != nil {
return fmt.Errorf("failed to add config column to account table: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/database/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var sqliteMigrations = []migration{
defer tx.Rollback()

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

_, err = tx.Exec(`ALTER TABLE account ADD COLUMN config JSON NOT NULL DEFAULT '{}'`)
if strings.Contains(err.Error(), `duplicate column name`) {
if err != nil && strings.Contains(err.Error(), `duplicate column name`) {
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 e0fa4cc

Please sign in to comment.