Skip to content

Commit

Permalink
fix: adding prefix to table name
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored May 7, 2024
1 parent 4bade90 commit ad8b8a2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func RunMigrations(db *gorm.DB) error {
return err
}

query := db.Raw("SELECT A.user_id, A.team_id, C.scope as permission FROM user_roles AS A LEFT JOIN role_permissions AS B ON A.role_id = B.role_id LEFT JOIN permissions AS C on B.permission_id = C.id;")
query := db.Raw("SELECT A.user_id, A.team_id, C.scope as permission FROM " + db.Config.NamingStrategy.TableName("user_roles") + "AS A LEFT JOIN role_permissions AS B ON A.role_id = B.role_id LEFT JOIN permissions AS C on B.permission_id = C.id;")
err = db.Migrator().CreateView("vw_user_team_permissions", gorm.ViewOption{Query: query, Replace: true})
if err != nil {
return err
}

query = db.Raw("SELECT A.key_id, A.team_id, C.scope as permission FROM api_key_roles AS A LEFT JOIN role_permissions AS B ON A.role_id = B.role_id LEFT JOIN permissions AS C on B.permission_id = C.id;")
query = db.Raw("SELECT A.key_id, A.team_id, C.scope as permission FROM " + db.Config.NamingStrategy.TableName("api_key_roles") + " AS A LEFT JOIN role_permissions AS B ON A.role_id = B.role_id LEFT JOIN permissions AS C on B.permission_id = C.id;")
err = db.Migrator().CreateView("vw_api_key_team_permissions", gorm.ViewOption{Query: query, Replace: true})
if err != nil {
return err
Expand Down

0 comments on commit ad8b8a2

Please sign in to comment.