Skip to content

Commit cbf6d1a

Browse files
committed
fix: remove obsolete RoleCondition.name property
1 parent d74d9fd commit cbf6d1a

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

libs/api/core/data-access/src/lib/api-core.service.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,24 @@ import { slugifyId, slugifyUsername } from './helpers/slugify-id'
88
export class ApiCoreService {
99
private readonly logger = new Logger(ApiCoreService.name)
1010
readonly data: ApiCorePrismaClient = prismaClient
11-
constructor(readonly config: ApiCoreConfigService) {}
11+
constructor(readonly config: ApiCoreConfigService) {
12+
// Get all the condition that have a name to reset them to null
13+
this.data.roleCondition
14+
.findMany({
15+
where: { name: { not: null } },
16+
select: { id: true },
17+
})
18+
.then((conditions) => {
19+
console.log('Found conditions with name', conditions)
20+
conditions.forEach((condition) => {
21+
console.log(`Resetting name for condition ${condition.id}`)
22+
this.data.roleCondition.update({
23+
where: { id: condition.id },
24+
data: { name: null },
25+
})
26+
})
27+
})
28+
}
1229

1330
async createCommunity({ input, userId }: { input: Prisma.CommunityCreateInput; userId?: string }) {
1431
const id = slugifyId(input.name).toLowerCase()

libs/api/role/data-access/src/lib/api-admin-role.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ApiAdminRoleService {
3434
return this.core.data.role.findUnique({
3535
where: { id: roleId },
3636
include: {
37-
conditions: { include: { token: true }, orderBy: { name: 'asc' } },
37+
conditions: { include: { token: true }, orderBy: { createdAt: 'asc' } },
3838
community: true,
3939
permissions: { include: { botRole: true } },
4040
},

libs/api/role/data-access/src/lib/api-role-resolver.service.ts

-2
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ export class ApiRoleResolverService {
360360
config: true,
361361
filters: true,
362362
id: true,
363-
name: true,
364363
type: true,
365364
role: true,
366365
token: {
@@ -374,7 +373,6 @@ export class ApiRoleResolverService {
374373
amount: condition.amount ?? undefined,
375374
config: condition.config ?? undefined,
376375
filters: condition.filters ?? undefined,
377-
name: condition.name ?? condition.type,
378376
token: condition.token ?? undefined,
379377
})),
380378
)

libs/api/role/data-access/src/lib/api-user-role.service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class ApiUserRoleService {
2727
data: {
2828
config: input.config ?? undefined,
2929
filters: input.filters ?? undefined,
30-
name: input.type.toString(),
3130
role: { connect: { id: input.roleId } },
3231
token: { connect: { id: input.tokenId } },
3332
type: input.type,
@@ -103,7 +102,7 @@ export class ApiUserRoleService {
103102
return this.core.data.role.findUnique({
104103
where: { id: roleId },
105104
include: {
106-
conditions: { include: { token: true }, orderBy: { name: 'asc' } },
105+
conditions: { include: { token: true }, orderBy: { createdAt: 'asc' } },
107106
community: true,
108107
permissions: { include: { botRole: true } },
109108
},

prisma/schema.prisma

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ model RoleCondition {
244244
amount String @default("0")
245245
config Json?
246246
filters Json?
247-
name String
247+
name String?
248248
token NetworkToken @relation(fields: [tokenId], references: [id])
249249
tokenId String
250250
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)

0 commit comments

Comments
 (0)