Skip to content

Commit

Permalink
fix: use data.id instead of id (#4333)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j authored Oct 14, 2024
1 parent 9ce5e75 commit 2035c6f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
21 changes: 12 additions & 9 deletions packages/migrations/__tests__/migrations/5.41.0/001/001.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ export const testData = [
{
PK: "T#root",
SK: "A",
createdOn: "2023-01-25T09:37:58.183Z",
description: "The top-level Webiny tenant.",
data: {
createdOn: "2023-01-25T09:37:58.183Z",
description: "The top-level Webiny tenant.",
id: "root",
name: "Root",
savedOn: "2023-01-25T09:37:58.183Z",
settings: {
domains: []
},
status: "active"
},

GSI1_PK: "TENANTS",
GSI1_SK: "T#null#2023-01-25T09:37:58.183Z",
id: "root",
name: "Root",
savedOn: "2023-01-25T09:37:58.183Z",
settings: {
domains: []
},
status: "active",
TYPE: "tenancy.tenant",
webinyVersion: "0.0.0",
_ct: "2023-01-25T09:37:58.220Z",
Expand Down
6 changes: 3 additions & 3 deletions packages/migrations/src/migrations/5.41.0/001/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class AdminUsers_5_41_0_001 {
}

async execute({ logger }: DataMigrationContext): Promise<void> {
const tenants = await queryAll<{ id: string; name: string }>({
const tenants = await queryAll<{ data: { id: string; name: string } }>({
entity: this.tenantEntity,
partitionKey: "TENANTS",
options: {
Expand All @@ -59,15 +59,15 @@ export class AdminUsers_5_41_0_001 {
for (const tenant of tenants) {
const users = await queryAll<{ id: string; email: string; data?: any }>({
entity: this.newUserEntity,
partitionKey: `T#${tenant.id}#ADMIN_USERS`,
partitionKey: `T#${tenant.data.id}#ADMIN_USERS`,
options: {
index: "GSI1",
gt: " "
}
});

if (users.length === 0) {
logger.info(`No users found on tenant "${tenant.id}".`);
logger.info(`No users found on tenant "${tenant.data.id}".`);
continue;
}

Expand Down

0 comments on commit 2035c6f

Please sign in to comment.