mirror of
https://github.com/go-shiori/shiori.git
synced 2025-03-10 23:05:33 +08:00
fix: not checking for nil-pointer errors on migrations (#906)
This commit is contained in:
parent
eaa6f0ea2a
commit
a6e55705da
3 changed files with 6 additions and 6 deletions
|
@ -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)
|
||||
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue