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