Skip to content

Commit da34504

Browse files
authored
Default user status to Active (#3520)
1 parent ec45704 commit da34504

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/components/user/dto/create-person.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export abstract class CreatePerson {
3333
readonly about?: string | null;
3434

3535
@Field(() => UserStatus, { nullable: true })
36-
readonly status?: UserStatus;
36+
readonly status?: UserStatus = 'Active';
3737

3838
@Field(() => [Role], { nullable: true })
3939
@Transform(({ value }) => uniq(value))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { BaseMigration, Migration } from '~/core/database';
2+
import { UserStatus } from '../dto';
3+
4+
@Migration('2025-07-02T08:00:00')
5+
export class DefaultUserStatusMigration extends BaseMigration {
6+
async up() {
7+
await this.db.query().raw`
8+
match (:User)-[:status]->(prop)
9+
where prop.value is null
10+
set prop.value = ${UserStatus.Active}
11+
return count(prop)
12+
`.executeAndLogStats();
13+
}
14+
}

src/components/user/user.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { KnownLanguageRepository } from './known-language.repository';
1313
import { KnownLanguageResolver } from './known-language.resolver';
1414
import { AddActorLabelMigration } from './migrations/add-actor-label.migration';
1515
import { AddUserNameLabelMigration } from './migrations/add-user-name-label.migration';
16+
import { DefaultUserStatusMigration } from './migrations/default-user-status.migration';
1617
import { SystemAgentGelRepository } from './system-agent.gel.repository';
1718
import { SystemAgentNeo4jRepository } from './system-agent.neo4j.repository';
1819
import { SystemAgentRepository } from './system-agent.repository';
@@ -49,6 +50,7 @@ import { UserService } from './user.service';
4950
},
5051
AddActorLabelMigration,
5152
AddUserNameLabelMigration,
53+
DefaultUserStatusMigration,
5254
],
5355
exports: [
5456
UserService,

test/user.e2e-spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { faker } from '@faker-js/faker';
22
import { times } from 'lodash';
33
import { firstLettersOfWords, isValidId } from '~/common';
44
import { graphql, type InputOf } from '~/graphql';
5+
import { UserStatus } from '../src/components/user/dto';
56
import {
67
createEducation,
78
createOrganization,
@@ -87,7 +88,7 @@ describe('User e2e', () => {
8788
expect(actual.displayLastName.value).toBe(user.displayLastName);
8889
expect(actual.phone.value).toBeNull();
8990
expect(actual.about.value).toBeNull();
90-
expect(actual.status.value).toBeNull();
91+
expect(actual.status.value).toBe(UserStatus.Active);
9192
expect(actual.timezone.value?.name).toBe(user.timezone);
9293
});
9394

0 commit comments

Comments
 (0)