diff --git a/prisma/migrations/20240607092158_/migration.sql b/prisma/migrations/20240607092158_/migration.sql new file mode 100644 index 0000000..a2f1026 --- /dev/null +++ b/prisma/migrations/20240607092158_/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - A unique constraint covering the columns `[name]` on the table `Crypto` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX "Crypto_name_key" ON "Crypto"("name"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index bffd664..ce0b3c2 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -11,7 +11,7 @@ generator client { model Crypto { id String @id @default(uuid()) - name String + name String @unique value Float image String created_at DateTime @default(now()) diff --git a/src/crypto/crypto.service.ts b/src/crypto/crypto.service.ts index dc8f7c1..1322189 100644 --- a/src/crypto/crypto.service.ts +++ b/src/crypto/crypto.service.ts @@ -102,6 +102,15 @@ export class CryptoService { }); } } + const newCryptoValue = crypto.value * 1.1; + await this.prisma.crypto.update({ + where: { + id: dto.id_crypto, + }, + data: { + value: newCryptoValue, + }, + }); return crypto; }