Add migration to restrict users without workspaces (#5369)

- update set null ON DELETE constraint to RESTRICT
- update missing updates
This commit is contained in:
martmull
2024-05-13 14:18:45 +02:00
committed by GitHub
parent 1ac8abb118
commit 8576127b47
3 changed files with 48 additions and 2 deletions

View File

@ -160,6 +160,9 @@ describe('TokenService', () => {
};
const mockUser = { id: '1', email: 'user@example.com' };
const mockedNewDate = new Date();
jest.spyOn(global, 'Date').mockImplementation(() => mockedNewDate);
jest
.spyOn(appTokenRepository, 'findOne')
.mockResolvedValue(mockToken as AppToken);
@ -173,7 +176,7 @@ describe('TokenService', () => {
where: {
value: hashedToken,
type: AppTokenType.PasswordResetToken,
expiresAt: MoreThan(new Date()),
expiresAt: MoreThan(mockedNewDate),
revokedAt: IsNull(),
},
});

View File

@ -71,7 +71,7 @@ export class User {
@Field(() => Workspace, { nullable: false })
@ManyToOne(() => Workspace, (workspace) => workspace.users, {
onDelete: 'SET NULL',
onDelete: 'RESTRICT',
})
defaultWorkspace: Relation<Workspace>;