Recreate UserNotificationTarget from scratch
This commit is contained in:
parent
adf5c0c0cd
commit
bb739de594
1 changed files with 9 additions and 0 deletions
|
@ -26,6 +26,15 @@ func (m MigrateChatIdToNotificationTarget20241212) Down(ctx context.Context, db
|
||||||
|
|
||||||
func (m MigrateChatIdToNotificationTarget20241212) Up(ctx context.Context, db *gorm.DB) error {
|
func (m MigrateChatIdToNotificationTarget20241212) Up(ctx context.Context, db *gorm.DB) error {
|
||||||
log := logging.FromContext(ctx)
|
log := logging.FromContext(ctx)
|
||||||
|
// if UserNotificationTarget table already exists drop it and recreate it:
|
||||||
|
if err := db.Migrator().DropTable(&uModel.UserNotificationTarget{}); err != nil {
|
||||||
|
log.Errorf("Failed to drop user_notification_targets table: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create UserNotificationTarget table
|
||||||
|
if err := db.AutoMigrate(&uModel.UserNotificationTarget{}); err != nil {
|
||||||
|
log.Errorf("Failed to create user_notification_targets table: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Start a transaction
|
// Start a transaction
|
||||||
return db.Transaction(func(tx *gorm.DB) error {
|
return db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
|
Loading…
Add table
Reference in a new issue