Stockage du montant de la modification plutôt que le avant/après
This commit is contained in:
parent
6a0b4049b6
commit
b44ffcd380
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the column `after` on the `MoneyUpdate` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the column `before` on the `MoneyUpdate` table. All the data in the column will be lost.
|
||||||
|
- Added the required column `amount` to the `MoneyUpdate` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "MoneyUpdate" DROP COLUMN "after",
|
||||||
|
DROP COLUMN "before",
|
||||||
|
ADD COLUMN "amount" INTEGER NOT NULL,
|
||||||
|
ADD COLUMN "timestamp" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
@ -72,13 +72,13 @@ model MoneyUpdate {
|
|||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id])
|
||||||
userId Int
|
userId Int
|
||||||
before Int
|
amount Int
|
||||||
after Int
|
|
||||||
reason MoneyUpdateType
|
reason MoneyUpdateType
|
||||||
action ChallengeAction? @relation(fields: [actionId], references: [id])
|
action ChallengeAction? @relation(fields: [actionId], references: [id])
|
||||||
actionId Int? @unique
|
actionId Int? @unique
|
||||||
trip TrainTrip? @relation(fields: [tripId], references: [id])
|
trip TrainTrip? @relation(fields: [tripId], references: [id])
|
||||||
tripId String? @unique
|
tripId String? @unique
|
||||||
|
timestamp DateTime @default(now()) @db.Timestamptz(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum MoneyUpdateType {
|
enum MoneyUpdateType {
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
import { ApiProperty } from "@nestjs/swagger"
|
import { ApiProperty } from "@nestjs/swagger"
|
||||||
import { MoneyUpdateType } from "@prisma/client"
|
import { MoneyUpdateType } from "@prisma/client"
|
||||||
import { Type } from "class-transformer"
|
import { Type } from "class-transformer"
|
||||||
import { IsEnum, IsInt, IsOptional, IsUUID } from "class-validator"
|
import { IsDate, IsEnum, IsInt, IsOptional, IsUUID } from "class-validator"
|
||||||
|
|
||||||
export class CreateMoneyUpdateDto {
|
export class CreateMoneyUpdateDto {
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiProperty({ description: "Solde avant modification" })
|
@ApiProperty({ description: "Montant de la modification de solde" })
|
||||||
before: number
|
amount: number
|
||||||
|
|
||||||
@IsInt()
|
|
||||||
@Type(() => Number)
|
|
||||||
@ApiProperty({ description: "Solde après modification" })
|
|
||||||
after: number
|
|
||||||
|
|
||||||
@IsEnum(MoneyUpdateType)
|
@IsEnum(MoneyUpdateType)
|
||||||
@ApiProperty({ description: "Type de modification de solde" })
|
@ApiProperty({ description: "Type de modification de solde" })
|
||||||
@ -28,4 +23,9 @@ export class CreateMoneyUpdateDto {
|
|||||||
@IsUUID()
|
@IsUUID()
|
||||||
@ApiProperty({ description: "Identifiant du trajet acheté, si la mise à jour est liée à la réservation d'un train", nullable: true })
|
@ApiProperty({ description: "Identifiant du trajet acheté, si la mise à jour est liée à la réservation d'un train", nullable: true })
|
||||||
tripId?: string
|
tripId?: string
|
||||||
|
|
||||||
|
@IsDate()
|
||||||
|
@Type(() => Date)
|
||||||
|
@ApiProperty({ description: "Date et heure de la modification de solde" })
|
||||||
|
timestamp: Date
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { ApiProperty } from "@nestjs/swagger"
|
import { ApiProperty } from "@nestjs/swagger"
|
||||||
import { MoneyUpdate, MoneyUpdateType } from "@prisma/client"
|
import { MoneyUpdate, MoneyUpdateType } from "@prisma/client"
|
||||||
import { IsOptional } from "class-validator"
|
|
||||||
|
|
||||||
export class MoneyUpdateEntity implements MoneyUpdate {
|
export class MoneyUpdateEntity implements MoneyUpdate {
|
||||||
constructor (partial: Partial<MoneyUpdateEntity>) {
|
constructor (partial: Partial<MoneyUpdateEntity>) {
|
||||||
@ -13,11 +12,8 @@ export class MoneyUpdateEntity implements MoneyUpdate {
|
|||||||
@ApiProperty({ description: "Utilisateur⋅rice concerné⋅e par la mise à jour de solde" })
|
@ApiProperty({ description: "Utilisateur⋅rice concerné⋅e par la mise à jour de solde" })
|
||||||
userId: number
|
userId: number
|
||||||
|
|
||||||
@ApiProperty({ description: "Solde avant modification" })
|
@ApiProperty({ description: "Montant de la modification du solde" })
|
||||||
before: number
|
amount: number
|
||||||
|
|
||||||
@ApiProperty({ description: "Solde après modification" })
|
|
||||||
after: number
|
|
||||||
|
|
||||||
@ApiProperty({ description: "Type de modification de solde" })
|
@ApiProperty({ description: "Type de modification de solde" })
|
||||||
reason: MoneyUpdateType
|
reason: MoneyUpdateType
|
||||||
@ -27,4 +23,7 @@ export class MoneyUpdateEntity implements MoneyUpdate {
|
|||||||
|
|
||||||
@ApiProperty({ description: "Identifiant du trajet acheté, si la mise à jour est liée à la réservation d'un train", nullable: true })
|
@ApiProperty({ description: "Identifiant du trajet acheté, si la mise à jour est liée à la réservation d'un train", nullable: true })
|
||||||
tripId: string
|
tripId: string
|
||||||
|
|
||||||
|
@ApiProperty({ description: "Date et heure de la modification de solde" })
|
||||||
|
timestamp: Date
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user