#293: Changed IDs to UUIDs for all entities

This commit is contained in:
2025-01-01 20:53:05 +01:00
parent 465219276d
commit 586bb0ca83
17 changed files with 79 additions and 52 deletions

View File

@ -1,3 +1,5 @@
import { randomUUID } from 'node:crypto'
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import bcrypt from 'bcryptjs'
@ -5,11 +7,12 @@ import { Character } from './character'
import { PasswordResetToken } from './passwordResetToken'
import { BaseEntity } from '#application/base/baseEntity'
import { UUID } from '#application/types'
@Entity()
export class User extends BaseEntity {
@PrimaryKey()
id!: number
id = randomUUID()
@Property({ unique: true })
username!: string
@ -29,7 +32,7 @@ export class User extends BaseEntity {
@OneToMany(() => PasswordResetToken, (token) => token.user)
passwordResetTokens = new Collection<PasswordResetToken>(this)
setId(id: number) {
setId(id: UUID) {
this.id = id
return this
}