Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:

- You are about to drop the `reward` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "reward" DROP CONSTRAINT "reward_winnings_id_fkey";

-- DropTable
DROP TABLE "reward";
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Warnings:

- You are about to drop the `payoneer_payment_method` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `paypal_payment_method` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "payoneer_payment_method" DROP CONSTRAINT "fk_payoneer_user_payment_method";

-- DropForeignKey
ALTER TABLE "paypal_payment_method" DROP CONSTRAINT "fk_paypal_user_payment_method";

-- DropTable
DROP TABLE "payoneer_payment_method";

-- DropTable
DROP TABLE "paypal_payment_method";
35 changes: 0 additions & 35 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -96,45 +96,11 @@ model payment_releases {
payment_method payment_method @relation(fields: [payment_method_id], references: [payment_method_id], onDelete: NoAction, onUpdate: NoAction)
}

model payoneer_payment_method {
id Int @id @default(autoincrement())
user_payment_method_id String? @db.Uuid
user_id String @unique @db.VarChar(80)
payee_id String @db.VarChar(50)
payoneer_id String? @db.VarChar(50)
user_payment_methods user_payment_methods? @relation(fields: [user_payment_method_id], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "fk_payoneer_user_payment_method")
}

model paypal_payment_method {
id Int @id @default(autoincrement())
user_payment_method_id String? @db.Uuid
user_id String @unique @db.VarChar(80)
email String? @db.VarChar(150)
payer_id String? @db.VarChar(50)
country_code String? @db.VarChar(2)
user_payment_methods user_payment_methods? @relation(fields: [user_payment_method_id], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "fk_paypal_user_payment_method")
}

model reward {
reward_id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
winnings_id String @db.Uuid
points Int?
title String? @db.VarChar(255)
description String?
reference Json?
attributes Json?
created_at DateTime? @default(now()) @db.Timestamp(6)
updated_at DateTime? @default(now()) @db.Timestamp(6)
winnings winnings @relation(fields: [winnings_id], references: [winning_id], onDelete: NoAction, onUpdate: NoAction)
}

model user_payment_methods {
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
user_id String @db.VarChar(80)
payment_method_id Int
status payment_method_status? @default(OTP_PENDING)
payoneer_payment_method payoneer_payment_method[]
paypal_payment_method paypal_payment_method[]
trolley_payment_method trolley_recipient[]
payment_method payment_method @relation(fields: [payment_method_id], references: [payment_method_id], onDelete: NoAction, onUpdate: NoAction, map: "fk_user_payment_method")

Expand Down Expand Up @@ -165,7 +131,6 @@ model winnings {
updated_at DateTime? @default(now()) @db.Timestamp(6)
audit audit[]
payment payment[]
reward reward[]
origin origin? @relation(fields: [origin_id], references: [origin_id], onDelete: NoAction, onUpdate: NoAction)
}

Expand Down
2 changes: 0 additions & 2 deletions src/api/wallet/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class WalletService {
w.type AS payment_type,
CASE
WHEN w.type = 'PAYMENT' THEN SUM(p.total_amount)
WHEN w.type = 'REWARD' THEN SUM(r.points)
ELSE 0
END AS total_owed
FROM
Expand All @@ -144,7 +143,6 @@ export class WalletService {
AND p.installment_number = 1
INNER JOIN latest_payment_version lpv ON p.winnings_id = lpv.winnings_id
AND p.version = lpv.max_version
LEFT JOIN reward r ON w.winning_id = r.winnings_id
AND w.type = 'REWARD'
WHERE
w.winner_id = ${winnerId}
Expand Down