From 43f83ab68f9bfba5139d59244a8b38b81c36f5d7 Mon Sep 17 00:00:00 2001 From: "Barros, Antonio" Date: Sat, 11 May 2024 11:06:53 -0300 Subject: [PATCH] Change create_at and updated_at to TIMESTAMP WITH TIME ZONE. --- package-lock.json | 10 ++ package.json | 1 + .../migrations/20240511135945_/migration.sql | 157 ++++++++++++++++++ .../migrations/20240511142910_/migration.sql | 20 +++ prisma/schema.prisma | 32 ++-- src/sessions/sessions.service.ts | 6 +- .../shelter-managers.service.ts | 2 +- src/shelter-managers/types.ts | 4 +- src/shelter-supply/shelter-supply.service.ts | 8 +- src/shelter-supply/types.ts | 4 +- src/shelter/shelter.service.ts | 6 +- src/shelter/types/types.ts | 4 +- .../supply-categories.service.ts | 4 +- src/supply-categories/types.ts | 4 +- src/supply/supply.service.ts | 4 +- src/supply/types.ts | 4 +- src/users/types.ts | 4 +- src/users/users.service.ts | 4 +- 18 files changed, 233 insertions(+), 45 deletions(-) create mode 100644 prisma/migrations/20240511135945_/migration.sql create mode 100644 prisma/migrations/20240511142910_/migration.sql diff --git a/package-lock.json b/package-lock.json index 6c3ae692..44e87aad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@types/bcrypt": "^5.0.2", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", @@ -2405,6 +2406,15 @@ "@babel/types": "^7.20.7" } }, + "node_modules/@types/bcrypt": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@types/bcrypt/-/bcrypt-5.0.2.tgz", + "integrity": "sha512-6atioO8Y75fNcbmj0G7UjI9lXN2pQ/IGJ2FWT4a/btd0Lk9lQalHLKhkgKVZ3r+spnmWUKfbMi1GEe9wyHQfNQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/body-parser": { "version": "1.19.5", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", diff --git a/package.json b/package.json index 5e154b46..f10c2669 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@types/bcrypt": "^5.0.2", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", diff --git a/prisma/migrations/20240511135945_/migration.sql b/prisma/migrations/20240511135945_/migration.sql new file mode 100644 index 00000000..a2c03c27 --- /dev/null +++ b/prisma/migrations/20240511135945_/migration.sql @@ -0,0 +1,157 @@ +/* + Warnings: + + - The `created_at` column on the `category_supplies` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `updated_at` column on the `category_supplies` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `created_at` column on the `sessions` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `updated_at` column on the `sessions` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `created_at` column on the `shelter_managers` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `updated_at` column on the `shelter_managers` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `created_at` column on the `shelter_supplies` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `updated_at` column on the `shelter_supplies` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `created_at` column on the `shelters` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `updated_at` column on the `shelters` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `created_at` column on the `supplies` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `updated_at` column on the `supplies` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `created_at` column on the `users` table would be dropped and recreated. This will lead to data loss if there is data in the column. + - The `updated_at` column on the `users` table would be dropped and recreated. This will lead to data loss if there is data in the column. + +*/ +-- AlterTable +ALTER TABLE "category_supplies" ADD COLUMN "created_at_tmp" TIMESTAMP(3) default null; +UPDATE "category_supplies" +SET "created_at_tmp" = CASE + WHEN "created_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "created_at"::timestamp + ELSE NOW() + END; +ALTER TABLE "category_supplies" DROP COLUMN "created_at"; +ALTER TABLE "category_supplies" RENAME COLUMN "created_at_tmp" TO "created_at"; + +-- AlterTable +ALTER TABLE "category_supplies" ADD COLUMN "updated_at_tmp" TIMESTAMP(3) default null; +UPDATE "category_supplies" +SET "updated_at_tmp" = CASE + WHEN "updated_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "updated_at"::timestamp + ELSE null + END; +ALTER TABLE "category_supplies" DROP COLUMN "updated_at"; +ALTER TABLE "category_supplies" RENAME COLUMN "updated_at_tmp" TO "updated_at"; + +-- AlterTable +ALTER TABLE "sessions" ADD COLUMN "created_at_tmp" TIMESTAMP(3) default null; +UPDATE "sessions" +SET "created_at_tmp" = CASE + WHEN "created_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "created_at"::timestamp + ELSE NOW() + END; +ALTER TABLE "sessions" DROP COLUMN "created_at"; +ALTER TABLE "sessions" RENAME COLUMN "created_at_tmp" TO "created_at"; + +-- AlterTable +ALTER TABLE "sessions" ADD COLUMN "updated_at_tmp" TIMESTAMP(3) default null; +UPDATE "sessions" +SET "updated_at_tmp" = CASE + WHEN "updated_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "updated_at"::timestamp + ELSE null + END; +ALTER TABLE "sessions" DROP COLUMN "updated_at"; +ALTER TABLE "sessions" RENAME COLUMN "updated_at_tmp" TO "updated_at"; + +-- AlterTable +ALTER TABLE "shelter_managers" ADD COLUMN "created_at_tmp" TIMESTAMP(3) default null; +UPDATE "shelter_managers" +SET "created_at_tmp" = CASE + WHEN "created_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "created_at"::timestamp + ELSE NOW() + END; +ALTER TABLE "shelter_managers" DROP COLUMN "created_at"; +ALTER TABLE "shelter_managers" RENAME COLUMN "created_at_tmp" TO "created_at"; + +-- AlterTable +ALTER TABLE "shelter_managers" ADD COLUMN "updated_at_tmp" TIMESTAMP(3) default null; +UPDATE "shelter_managers" +SET "updated_at_tmp" = CASE + WHEN "updated_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "updated_at"::timestamp + ELSE null + END; +ALTER TABLE "shelter_managers" DROP COLUMN "updated_at"; +ALTER TABLE "shelter_managers" RENAME COLUMN "updated_at_tmp" TO "updated_at"; + +-- AlterTable +ALTER TABLE "shelter_supplies" ADD COLUMN "created_at_tmp" TIMESTAMP(3) default null; +UPDATE "shelter_supplies" +SET "created_at_tmp" = CASE + WHEN "created_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "created_at"::timestamp + ELSE NOW() + END; +ALTER TABLE "shelter_supplies" DROP COLUMN "created_at"; +ALTER TABLE "shelter_supplies" RENAME COLUMN "created_at_tmp" TO "created_at"; + + +ALTER TABLE "shelter_supplies" ADD COLUMN "updated_at_tmp" TIMESTAMP(3) default null; +UPDATE "shelter_supplies" +SET "updated_at_tmp" = CASE + WHEN "updated_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "updated_at"::timestamp + ELSE null + END; +ALTER TABLE "shelter_supplies" DROP COLUMN "updated_at"; +ALTER TABLE "shelter_supplies" RENAME COLUMN "updated_at_tmp" TO "updated_at"; + +-- AlterTable +ALTER TABLE "shelters" ADD COLUMN "created_at_tmp" TIMESTAMP(3) default null; +UPDATE "shelters" +SET "created_at_tmp" = CASE + WHEN "created_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "created_at"::timestamp + ELSE NOW() + END; +ALTER TABLE "shelters" DROP COLUMN "created_at"; +ALTER TABLE "shelters" RENAME COLUMN "created_at_tmp" TO "created_at"; + +-- AlterTable +ALTER TABLE "shelters" ADD COLUMN "updated_at_tmp" TIMESTAMP(3) default null; +UPDATE "shelters" +SET "updated_at_tmp" = CASE + WHEN "updated_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "updated_at"::timestamp + ELSE null + END; +ALTER TABLE "shelters" DROP COLUMN "updated_at"; +ALTER TABLE "shelters" RENAME COLUMN "updated_at_tmp" TO "updated_at"; + +-- AlterTable +ALTER TABLE "supplies" ADD COLUMN "created_at_tmp" TIMESTAMP(3) default null; +UPDATE "supplies" +SET "created_at_tmp" = CASE + WHEN "created_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "created_at"::timestamp + ELSE NOW() + END; +ALTER TABLE "supplies" DROP COLUMN "created_at"; +ALTER TABLE "supplies" RENAME COLUMN "created_at_tmp" TO "created_at"; + +-- AlterTable +ALTER TABLE "supplies" ADD COLUMN "updated_at_tmp" TIMESTAMP(3) default null; +UPDATE "supplies" +SET "updated_at_tmp" = CASE + WHEN "updated_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "updated_at"::timestamp + ELSE null + END; +ALTER TABLE "supplies" DROP COLUMN "updated_at"; +ALTER TABLE "supplies" RENAME COLUMN "updated_at_tmp" TO "updated_at"; + +-- AlterTable +ALTER TABLE "users" ADD COLUMN "created_at_tmp" TIMESTAMP(3) default null; +UPDATE "users" +SET "created_at_tmp" = CASE + WHEN "created_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "created_at"::timestamp + ELSE NOW() + END; +ALTER TABLE "users" DROP COLUMN "created_at"; +ALTER TABLE "users" RENAME COLUMN "created_at_tmp" TO "created_at"; + +ALTER TABLE "users" ADD COLUMN "updated_at_tmp" TIMESTAMP(3) default null; +UPDATE "users" +SET "updated_at_tmp" = CASE + WHEN "updated_at" ~* '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' THEN "updated_at"::timestamp + ELSE null + END; +ALTER TABLE "users" DROP COLUMN "updated_at"; +ALTER TABLE "users" RENAME COLUMN "updated_at_tmp" TO "updated_at"; \ No newline at end of file diff --git a/prisma/migrations/20240511142910_/migration.sql b/prisma/migrations/20240511142910_/migration.sql new file mode 100644 index 00000000..d83a7f9e --- /dev/null +++ b/prisma/migrations/20240511142910_/migration.sql @@ -0,0 +1,20 @@ +-- AlterTable +ALTER TABLE "category_supplies" ALTER COLUMN "updated_at" DROP DEFAULT; + +-- AlterTable +ALTER TABLE "sessions" ALTER COLUMN "updated_at" DROP DEFAULT; + +-- AlterTable +ALTER TABLE "shelter_managers" ALTER COLUMN "updated_at" DROP DEFAULT; + +-- AlterTable +ALTER TABLE "shelter_supplies" ALTER COLUMN "updated_at" DROP DEFAULT; + +-- AlterTable +ALTER TABLE "shelters" ALTER COLUMN "updated_at" DROP DEFAULT; + +-- AlterTable +ALTER TABLE "supplies" ALTER COLUMN "updated_at" DROP DEFAULT; + +-- AlterTable +ALTER TABLE "users" ALTER COLUMN "updated_at" DROP DEFAULT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 792b1f65..d4c7f181 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -22,8 +22,8 @@ model User { password String phone String @unique accessLevel AccessLevel @default(value: User) - createdAt String @map("created_at") @db.VarChar(32) - updatedAt String? @map("updated_at") @db.VarChar(32) + createdAt DateTime? @default(value: now()) @map("created_at") + updatedAt DateTime? @map("updated_at") sessions Session[] shelterManagers ShelterManagers[] @@ -37,8 +37,8 @@ model Session { ip String? userAgent String? @map("user_agent") active Boolean @default(value: true) - createdAt String @map("created_at") @db.VarChar(32) - updatedAt String? @map("updated_at") @db.VarChar(32) + createdAt DateTime? @default(value: now()) @map("created_at") + updatedAt DateTime? @map("updated_at") user User @relation(fields: [userId], references: [id]) @@ -48,8 +48,8 @@ model Session { model SupplyCategory { id String @id @default(uuid()) name String @unique - createdAt String @map("created_at") @db.VarChar(32) - updatedAt String? @map("updated_at") @db.VarChar(32) + createdAt DateTime? @default(value: now()) @map("created_at") + updatedAt DateTime? @map("updated_at") supplies Supply[] @@ -61,8 +61,8 @@ model ShelterSupply { supplyId String @map("supply_id") priority Int @default(value: 0) quantity Int? - createdAt String @map("created_at") @db.VarChar(32) - updatedAt String? @map("updated_at") @db.VarChar(32) + createdAt DateTime? @default(value: now()) @map("created_at") + updatedAt DateTime? @map("updated_at") shelter Shelter @relation(fields: [shelterId], references: [id]) supply Supply @relation(fields: [supplyId], references: [id]) @@ -75,8 +75,8 @@ model Supply { id String @id @default(uuid()) supplyCategoryId String @map("supply_category_id") name String - createdAt String @map("created_at") @db.VarChar(32) - updatedAt String? @map("updated_at") @db.VarChar(32) + createdAt DateTime? @default(value: now()) @map("created_at") + updatedAt DateTime? @map("updated_at") supplyCategory SupplyCategory @relation(fields: [supplyCategoryId], references: [id]) shelterSupplies ShelterSupply[] @@ -97,8 +97,8 @@ model Shelter { latitude Float? longitude Float? verified Boolean @default(value: false) - createdAt String @map("created_at") @db.VarChar(32) - updatedAt String? @map("updated_at") @db.VarChar(32) + createdAt DateTime? @default(value: now()) @map("created_at") + updatedAt DateTime? @map("updated_at") shelterManagers ShelterManagers[] shelterSupplies ShelterSupply[] @@ -107,10 +107,10 @@ model Shelter { } model ShelterManagers { - shelterId String @map("shelter_id") - userId String @map("user_id") - createdAt String @map("created_at") @db.VarChar(32) - updatedAt String? @map("updated_at") @db.VarChar(32) + shelterId String @map("shelter_id") + userId String @map("user_id") + createdAt DateTime? @default(value: now()) @map("created_at") + updatedAt DateTime? @map("updated_at") user User @relation(fields: [userId], references: [id]) shelter Shelter @relation(fields: [shelterId], references: [id]) diff --git a/src/sessions/sessions.service.ts b/src/sessions/sessions.service.ts index 235d7f0d..68c4976b 100644 --- a/src/sessions/sessions.service.ts +++ b/src/sessions/sessions.service.ts @@ -27,7 +27,7 @@ export class SessionsService { }, data: { active: false, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); @@ -36,7 +36,7 @@ export class SessionsService { userId: user.id, ip, userAgent, - createdAt: new Date().toISOString(), + createdAt: new Date(), }, }); @@ -73,7 +73,7 @@ export class SessionsService { userId, }, data: { - updatedAt: new Date().toISOString(), + updatedAt: new Date(), active: false, }, }); diff --git a/src/shelter-managers/shelter-managers.service.ts b/src/shelter-managers/shelter-managers.service.ts index 648e9719..68bac864 100644 --- a/src/shelter-managers/shelter-managers.service.ts +++ b/src/shelter-managers/shelter-managers.service.ts @@ -14,7 +14,7 @@ export class ShelterManagersService { data: { shelterId, userId, - createdAt: new Date().toISOString(), + createdAt: new Date(), }, }); } diff --git a/src/shelter-managers/types.ts b/src/shelter-managers/types.ts index 92a5eb85..ecb5029a 100644 --- a/src/shelter-managers/types.ts +++ b/src/shelter-managers/types.ts @@ -3,8 +3,8 @@ import z from 'zod'; const ShelterManagerSchema = z.object({ shelterId: z.string(), userId: z.string(), - createdAt: z.string(), - updatedAt: z.string().optional().nullable(), + createdAt: z.date(), + updatedAt: z.date().optional().nullable(), }); const CreateShelterManagerSchema = ShelterManagerSchema.pick({ diff --git a/src/shelter-supply/shelter-supply.service.ts b/src/shelter-supply/shelter-supply.service.ts index 73faddc4..bf0cab6b 100644 --- a/src/shelter-supply/shelter-supply.service.ts +++ b/src/shelter-supply/shelter-supply.service.ts @@ -26,7 +26,7 @@ export class ShelterSupplyService { prioritySum: { increment: newPriority - oldPriority, }, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); } @@ -41,7 +41,7 @@ export class ShelterSupplyService { priority, supplyId, quantity: priority !== SupplyPriority.UnderControl ? quantity : null, - createdAt: new Date().toISOString(), + createdAt: new Date(), }, }); } @@ -74,7 +74,7 @@ export class ShelterSupplyService { data: { ...data, quantity: priority !== SupplyPriority.UnderControl ? quantity : null, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); } @@ -91,7 +91,7 @@ export class ShelterSupplyService { }, data: { priority: SupplyPriority.UnderControl, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); } diff --git a/src/shelter-supply/types.ts b/src/shelter-supply/types.ts index 1ff25f90..d1ea6c2c 100644 --- a/src/shelter-supply/types.ts +++ b/src/shelter-supply/types.ts @@ -13,8 +13,8 @@ const ShelterSupplySchema = z.object({ z.literal(SupplyPriority.Urgent), ]), quantity: z.number().gt(0).nullable().optional(), - createdAt: z.string(), - updatedAt: z.string().nullable().optional(), + createdAt: z.date(), + updatedAt: z.date().nullable().optional(), }); const CreateShelterSupplySchema = ShelterSupplySchema.pick({ diff --git a/src/shelter/shelter.service.ts b/src/shelter/shelter.service.ts index a24aa7ab..4661b31e 100644 --- a/src/shelter/shelter.service.ts +++ b/src/shelter/shelter.service.ts @@ -29,7 +29,7 @@ export class ShelterService { await this.prismaService.shelter.create({ data: { ...payload, - createdAt: new Date().toISOString(), + createdAt: new Date(), }, }); } @@ -42,7 +42,7 @@ export class ShelterService { }, data: { ...payload, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); } @@ -55,7 +55,7 @@ export class ShelterService { }, data: { ...payload, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); } diff --git a/src/shelter/types/types.ts b/src/shelter/types/types.ts index b3911c96..a052a9ed 100644 --- a/src/shelter/types/types.ts +++ b/src/shelter/types/types.ts @@ -19,8 +19,8 @@ const ShelterSchema = z.object({ capacity: z.number().min(0).nullable().optional(), contact: z.string().nullable().optional(), verified: z.boolean(), - createdAt: z.string(), - updatedAt: z.string().nullable().optional(), + createdAt: z.date(), + updatedAt: z.date().nullable().optional(), }); const CreateShelterSchema = ShelterSchema.omit({ diff --git a/src/supply-categories/supply-categories.service.ts b/src/supply-categories/supply-categories.service.ts index 4ebd796a..a1d6dece 100644 --- a/src/supply-categories/supply-categories.service.ts +++ b/src/supply-categories/supply-categories.service.ts @@ -16,7 +16,7 @@ export class SupplyCategoriesService { await this.prismaService.supplyCategory.create({ data: { ...payload, - createdAt: new Date().toISOString(), + createdAt: new Date(), }, }); } @@ -29,7 +29,7 @@ export class SupplyCategoriesService { }, data: { ...payload, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); } diff --git a/src/supply-categories/types.ts b/src/supply-categories/types.ts index b096e2c0..05b5ff9a 100644 --- a/src/supply-categories/types.ts +++ b/src/supply-categories/types.ts @@ -11,8 +11,8 @@ export enum SupplyStatus { const SupplyCategorySchema = z.object({ id: z.string(), name: z.string().transform(capitalize), - createdAt: z.string(), - updatedAt: z.string().nullable().optional(), + createdAt: z.date(), + updatedAt: z.date().nullable().optional(), }); const CreateSupplyCategorySchema = SupplyCategorySchema.pick({ diff --git a/src/supply/supply.service.ts b/src/supply/supply.service.ts index a3caf57e..df835238 100644 --- a/src/supply/supply.service.ts +++ b/src/supply/supply.service.ts @@ -13,7 +13,7 @@ export class SupplyService { return await this.prismaService.supply.create({ data: { ...payload, - createdAt: new Date().toISOString(), + createdAt: new Date(), }, }); } @@ -26,7 +26,7 @@ export class SupplyService { }, data: { ...payload, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); } diff --git a/src/supply/types.ts b/src/supply/types.ts index faef2d11..e4ca6244 100644 --- a/src/supply/types.ts +++ b/src/supply/types.ts @@ -12,8 +12,8 @@ const SupplySchema = z.object({ id: z.string(), supplyCategoryId: z.string(), name: z.string().transform(capitalize), - createdAt: z.string(), - updatedAt: z.string().nullable().optional(), + createdAt: z.date(), + updatedAt: z.date().nullable().optional(), }); const CreateSupplySchema = SupplySchema.omit({ diff --git a/src/users/types.ts b/src/users/types.ts index 1721f4bf..04f89b23 100644 --- a/src/users/types.ts +++ b/src/users/types.ts @@ -11,8 +11,8 @@ const UserSchema = z.object({ password: z.string(), phone: z.string().transform(removeNotNumbers), accessLevel: z.nativeEnum(AccessLevel), - createdAt: z.string(), - updatedAt: z.string().nullable().optional(), + createdAt: z.date(), + updatedAt: z.date().nullable().optional(), }); const CreateUserSchema = UserSchema.pick({ diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 49e5df91..f2c5da1c 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -16,7 +16,7 @@ export class UsersService { phone, password: phone, login: phone, - createdAt: new Date().toISOString(), + createdAt: new Date(), }, }); } @@ -29,7 +29,7 @@ export class UsersService { }, data: { ...payload, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }, }); }