Skip to content

Commit

Permalink
chore: fix migration name and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmitr committed Jan 10, 2025
1 parent dfd07d6 commit 17cc05b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ import (
"gorm.io/gorm"
)

var _20241221234500_fix_types = &gormigrate.Migration{
// This migration fixes column types for Postgres compatibility.
//
// First, an autoincrement sequence is created for user_configs.id (this works
// in sqlite, because an integer primary key becomes "autoincrement"
// automatically).
//
// Second, user_configs.encrypted is converted into a boolean; otherwise,
// it fails to de/serialize from/to the Go model's `Encrypted bool` field.
// Again, this happens to work in sqlite due to the way booleans are handled
// (they're just an alias for numeric).
var _202412212345_fix_types = &gormigrate.Migration{
ID: "20241221234500_fix_types",
Migrate: func(tx *gorm.DB) error {
if tx.Dialector.Name() == "postgres" {
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Migrate(gormDB *gorm.DB) error {
_202408191242_transaction_failure_reason,
_202408291715_app_metadata,
_202410141503_add_wallet_pubkey,
_20241221234500_fix_types,
_202412212345_fix_types,
})

return m.Migrate()
Expand Down

0 comments on commit 17cc05b

Please sign in to comment.