|
1
|
import { model } from "@medusajs/framework/utils" |
|
2
|
import RbacRole from "./rbac-role" |
|
3
|
|
|
4
|
const RbacRoleInheritance = model |
|
5
|
.define("rbac_role_inheritance", { |
|
6
|
id: model.id({ prefix: "rlin" }).primaryKey(), |
|
7
|
role: model.belongsTo(() => RbacRole, { mappedBy: "inherited_roles" }), |
|
8
|
inherited_role: model.belongsTo(() => RbacRole, { |
|
9
|
mappedBy: "inheritedBy", |
|
10
|
}), |
|
11
|
metadata: model.json().nullable(), |
|
12
|
}) |
|
13
|
.indexes([ |
|
14
|
{ |
|
15
|
on: ["role_id"], |
|
16
|
where: "deleted_at IS NULL", |
|
17
|
}, |
|
18
|
{ |
|
19
|
on: ["inherited_role_id"], |
|
20
|
where: "deleted_at IS NULL", |
|
21
|
}, |
|
22
|
{ |
|
23
|
on: ["role_id", "inherited_role_id"], |
|
24
|
unique: true, |
|
25
|
where: "deleted_at IS NULL", |
|
26
|
}, |
|
27
|
]) |
|
28
|
|
|
29
|
export default RbacRoleInheritance |