Skip to content

Commit

Permalink
fix(prisma): Set default Donation Type to donation (#635)
Browse files Browse the repository at this point in the history
There are recurring donations, created prior the implementation of the corporate flow, and thus resulting in an error when creating new donation, as type field is missing from the metadata.
Set default value of DonationType to donation to prevent this
  • Loading branch information
sashko9807 authored May 20, 2024
1 parent 8d4b6e7 commit 4d44d38
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import { DonationType } from '@prisma/client'
import { ApiProperty } from '@nestjs/swagger'

export class CreateDonationDto {
@ApiProperty({ enum: DonationType })
type: DonationType
}
export class CreateDonationDto {}
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import { DonationType } from '@prisma/client'
import { ApiProperty } from '@nestjs/swagger'

export class UpdateDonationDto {
@ApiProperty({ enum: DonationType })
type?: DonationType
}
export class UpdateDonationDto {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "donations" ALTER COLUMN "type" SET DEFAULT 'donation';
2 changes: 1 addition & 1 deletion podkrepi.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ Table payments {
Table donations {
id String [pk]
paymentId String [not null]
type DonationType [not null]
type DonationType [not null, default: 'donation']
targetVaultId String [not null, note: 'Vault where the funds are going']
amount Int [not null, default: 0]
personId String
Expand Down
2 changes: 1 addition & 1 deletion schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ model Donation {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
paymentId String @map("payment_id") @db.Uuid
type DonationType
type DonationType @default(donation)
/// Vault where the funds are going
targetVaultId String @map("target_vault_id") @db.Uuid
amount Int @default(0)
Expand Down

0 comments on commit 4d44d38

Please sign in to comment.