From eba6b5b102add2691cb30ae8b988a58e5dac62cd Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 22 Oct 2023 13:48:14 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Migrations=20for=20MySQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/legacy/migration.go | 6 +++--- internal/storage/migrations.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/legacy/migration.go b/internal/legacy/migration.go index d2cc54f1..7d667348 100644 --- a/internal/legacy/migration.go +++ b/internal/legacy/migration.go @@ -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 } @@ -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 } @@ -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 } diff --git a/internal/storage/migrations.go b/internal/storage/migrations.go index 55c2cacd..77e8bdfc 100644 --- a/internal/storage/migrations.go +++ b/internal/storage/migrations.go @@ -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{}, ) }