fix(notification): sync notification permissions
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package migration
|
||||
|
||||
import "github.com/mlogclub/simple/sqls"
|
||||
|
||||
func init() {
|
||||
register(7, "sync notification permissions", func() error {
|
||||
return sqls.WithTransaction(func(ctx *sqls.TxContext) error {
|
||||
permissions, err := ensurePermissions(ctx.Tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
roles, err := ensureRoles(ctx.Tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ensureRolePermissions(ctx.Tx, roles, permissions)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package migration
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNotificationPermissionMigrationRegistered(t *testing.T) {
|
||||
migration, ok := migrationFuncs[7]
|
||||
if !ok {
|
||||
t.Fatalf("expected migration version 7 to be registered")
|
||||
}
|
||||
if migration.Remark != "sync notification permissions" {
|
||||
t.Fatalf("unexpected migration remark: %q", migration.Remark)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user