Skip to content

Commit

Permalink
Merge pull request #1595 from traPtitech/fix/favorite-stamp-perm
Browse files Browse the repository at this point in the history
#729 のお気に入りスタンプパーミッション削除忘れ対応
  • Loading branch information
motoki317 authored Nov 26, 2022
2 parents 2f6cbb8 + 1aef08f commit 0934dd9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions migration/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func Migrations() []*gormigrate.Migration {
v28(), // v28 ユーザーグループにアイコンを追加
v29(), // BotにModeを追加、WebSocket Modeを追加
v30(), // bot_event_logsにresultを追加
v31(), // お気に入りスタンプパーミッション削除(削除忘れ)
}
}

Expand Down
36 changes: 36 additions & 0 deletions migration/v31.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package migration

import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)

// v31 お気に入りスタンプパーミッション削除(削除忘れ)
func v31() *gormigrate.Migration {
return &gormigrate.Migration{
ID: "31",
Migrate: func(db *gorm.DB) error {
removedPermissions := []string{
"get_favorite_stamp",
"edit_favorite_stamp",
}
for _, perm := range removedPermissions {
if err := db.Delete(&v31RolePermission{}, &v31RolePermission{Permission: perm}).Error; err != nil {
return err
}
}
return nil
},
}
}

// v31RolePermission ロール権限構造体
type v31RolePermission struct {
Role string `gorm:"type:varchar(30);not null;primaryKey"`
Permission string `gorm:"type:varchar(30);not null;primaryKey"`
}

// TableName RolePermission構造体のテーブル名
func (*v31RolePermission) TableName() string {
return "user_role_permissions"
}

0 comments on commit 0934dd9

Please sign in to comment.