-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c164f14
commit 43a7ad2
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package migration | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/go-gormigrate/gormigrate/v2" | ||
"gorm.io/gorm" | ||
) | ||
|
||
func tablesWithWrongCOLLATE() []string { | ||
return []string{"crontab", "devices", "dish", "files", "kino", "news", "newsSource", "notifications", "notification_types"} | ||
} | ||
|
||
// migrate20240317000000 | ||
// unified a variety of factors to not be different for no reason | ||
func migrate20240317000000() *gormigrate.Migration { | ||
return &gormigrate.Migration{ | ||
ID: "20240317000000", | ||
Migrate: func(tx *gorm.DB) error { | ||
for _, t := range tablesWithWrongCOLLATE() { | ||
if err := tx.Exec(fmt.Sprintf("ALTER TABLE `%s` COLLATE utf8mb4_unicode_ci", t)).Error; err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}, | ||
Rollback: func(tx *gorm.DB) error { | ||
for _, t := range tablesWithWrongCOLLATE() { | ||
if err := tx.Exec(fmt.Sprintf("ALTER TABLE `%s` COLLATE utf8mb4_general_ci", t)).Error; err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters