From 52ef7010f267649ffc558f7e67023f11f1982482 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Mon, 29 Sep 2025 11:26:26 +0300 Subject: [PATCH 1/2] PM-2091 - Drop rewards table --- .../migration.sql | 11 +++++++++++ prisma/schema.prisma | 14 -------------- src/api/wallet/wallet.service.ts | 2 -- 3 files changed, 11 insertions(+), 16 deletions(-) create mode 100644 prisma/migrations/20250929082539_remove_rewards_table/migration.sql diff --git a/prisma/migrations/20250929082539_remove_rewards_table/migration.sql b/prisma/migrations/20250929082539_remove_rewards_table/migration.sql new file mode 100644 index 0000000..2162985 --- /dev/null +++ b/prisma/migrations/20250929082539_remove_rewards_table/migration.sql @@ -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"; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d003137..73007b6 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -115,19 +115,6 @@ model paypal_payment_method { 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) @@ -165,7 +152,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) } diff --git a/src/api/wallet/wallet.service.ts b/src/api/wallet/wallet.service.ts index 3c3ab40..11a8a35 100644 --- a/src/api/wallet/wallet.service.ts +++ b/src/api/wallet/wallet.service.ts @@ -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 @@ -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} From 3148ae546ba7115ba42c45a991afc6c3d9a3b42b Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Mon, 29 Sep 2025 12:38:43 +0300 Subject: [PATCH 2/2] PM-2091 - drop payoneer & paypal payment method tables --- .../migration.sql | 18 ++++++++++++++++ prisma/schema.prisma | 21 ------------------- 2 files changed, 18 insertions(+), 21 deletions(-) create mode 100644 prisma/migrations/20250929082731_drop_payoneer_paypal_payment_methods/migration.sql diff --git a/prisma/migrations/20250929082731_drop_payoneer_paypal_payment_methods/migration.sql b/prisma/migrations/20250929082731_drop_payoneer_paypal_payment_methods/migration.sql new file mode 100644 index 0000000..9041bde --- /dev/null +++ b/prisma/migrations/20250929082731_drop_payoneer_paypal_payment_methods/migration.sql @@ -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"; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 73007b6..d9da8f7 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -96,32 +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 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")