Skip to content

Commit

Permalink
Merge pull request #257 from systemli/Fix-Migrations-for-MySQL
Browse files Browse the repository at this point in the history
🐛 Fix Migrations for MySQL
  • Loading branch information
0x46616c6b authored Oct 22, 2023
2 parents 58cbfab + eba6b5b commit 8fa16f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions internal/legacy/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (m *Migration) Do() error {
},
}

if err := m.newStorage.SaveMessage(&message); err != nil {
if err := m.newStorage.DB.Create(&message).Error; err != nil {
log.WithError(err).WithField("message_id", message.ID).Error("Unable to save message")
continue
}
Expand All @@ -134,7 +134,7 @@ func (m *Migration) Do() error {
IsSuperAdmin: oldUser.IsSuperAdmin,
}

if err := m.newStorage.SaveUser(&user); err != nil {
if err := m.newStorage.DB.Create(&user).Error; err != nil {
log.WithError(err).WithField("user_id", user.ID).Error("Unable to save user")
continue
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func (m *Migration) Do() error {
ContentType: oldUpload.ContentType,
}

if err := m.newStorage.SaveUpload(&upload); err != nil {
if err := m.newStorage.DB.Create(&upload).Error; err != nil {
log.WithError(err).WithField("upload_id", upload.ID).Error("Unable to save upload")
continue
}
Expand Down
8 changes: 4 additions & 4 deletions internal/storage/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import "gorm.io/gorm"
// MigrateDB migrates the database
func MigrateDB(db *gorm.DB) error {
return db.AutoMigrate(
&Attachment{},
&Message{},
&Setting{},
&Ticker{},
&TickerInformation{},
&TickerMastodon{},
&TickerTelegram{},
&Upload{},
&User{},
&Setting{},
&Upload{},
&Message{},
&Attachment{},
)
}

0 comments on commit 8fa16f4

Please sign in to comment.