From cfaebaa5a5ae35bd2b454b072612a1cf336a7b3b Mon Sep 17 00:00:00 2001 From: Paul Nicolas Date: Thu, 6 Jul 2023 15:10:25 +0200 Subject: [PATCH] fix: fix payments wise connector and migration (#419) --- .../connectors/wise/task_fetch_transfers.go | 23 +------------------ .../internal/app/storage/migrations.go | 12 +++++----- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/components/payments/internal/app/connectors/wise/task_fetch_transfers.go b/components/payments/internal/app/connectors/wise/task_fetch_transfers.go index 91703ab81..5d16e0de1 100644 --- a/components/payments/internal/app/connectors/wise/task_fetch_transfers.go +++ b/components/payments/internal/app/connectors/wise/task_fetch_transfers.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "time" "github.com/formancehq/payments/internal/app/connectors/wise/client" "github.com/formancehq/payments/internal/app/ingestion" @@ -104,27 +103,7 @@ func taskFetchTransfers(logger logging.Logger, c *client.Client, profileID uint6 } } - err = ingester.IngestPayments(ctx, paymentBatch, struct{}{}) - if err != nil { - return err - } - - // TODO: Implement proper looper & abstract the logic - - time.Sleep(time.Minute) - - descriptor, err := models.EncodeTaskDescriptor(TaskDescriptor{ - Name: "Fetch profiles from client", - Key: taskNameFetchProfiles, - }) - if err != nil { - return err - } - - return scheduler.Schedule(ctx, descriptor, models.TaskSchedulerOptions{ - ScheduleOption: models.OPTIONS_RUN_NOW, - Restart: true, - }) + return ingester.IngestPayments(ctx, paymentBatch, struct{}{}) } } diff --git a/components/payments/internal/app/storage/migrations.go b/components/payments/internal/app/storage/migrations.go index eca0773df..f26645c9d 100644 --- a/components/payments/internal/app/storage/migrations.go +++ b/components/payments/internal/app/storage/migrations.go @@ -42,7 +42,7 @@ func registerMigrations(migrator *migrations.Migrator) { migrations.Migration{ Up: func(tx bun.Tx) error { _, err := tx.Exec(` - CREATE TYPE connector_provider AS ENUM ('BANKING-CIRCLE', 'CURRENCY-CLOUD', 'DUMMY-PAY', 'MODULR', 'STRIPE', 'WISE');; + CREATE TYPE "public".connector_provider AS ENUM ('BANKING-CIRCLE', 'CURRENCY-CLOUD', 'DUMMY-PAY', 'MODULR', 'STRIPE', 'WISE');; CREATE TABLE connectors.connector ( id uuid NOT NULL DEFAULT gen_random_uuid(), created_at timestamp with time zone NOT NULL DEFAULT NOW() CHECK (created_at<=NOW()), @@ -62,7 +62,7 @@ func registerMigrations(migrator *migrations.Migrator) { migrations.Migration{ Up: func(tx bun.Tx) error { _, err := tx.Exec(` - CREATE TYPE task_status AS ENUM ('STOPPED', 'PENDING', 'ACTIVE', 'TERMINATED', 'FAILED');; + CREATE TYPE "public".task_status AS ENUM ('STOPPED', 'PENDING', 'ACTIVE', 'TERMINATED', 'FAILED');; CREATE TABLE tasks.task ( id uuid NOT NULL DEFAULT gen_random_uuid(), connector_id uuid NOT NULL, @@ -93,7 +93,7 @@ func registerMigrations(migrator *migrations.Migrator) { migrations.Migration{ Up: func(tx bun.Tx) error { _, err := tx.Exec(` - CREATE TYPE account_type AS ENUM('SOURCE', 'TARGET', 'UNKNOWN');; + CREATE TYPE "public".account_type AS ENUM('SOURCE', 'TARGET', 'UNKNOWN');; CREATE TABLE accounts.account ( id uuid NOT NULL DEFAULT gen_random_uuid(), @@ -114,8 +114,8 @@ func registerMigrations(migrator *migrations.Migrator) { migrations.Migration{ Up: func(tx bun.Tx) error { _, err := tx.Exec(` - CREATE TYPE payment_type AS ENUM ('PAY-IN', 'PAYOUT', 'TRANSFER', 'OTHER'); - CREATE TYPE payment_status AS ENUM ('SUCCEEDED', 'CANCELLED', 'FAILED', 'PENDING', 'OTHER');; + CREATE TYPE "public".payment_type AS ENUM ('PAY-IN', 'PAYOUT', 'TRANSFER', 'OTHER'); + CREATE TYPE "public".payment_status AS ENUM ('SUCCEEDED', 'CANCELLED', 'FAILED', 'PENDING', 'OTHER');; CREATE TABLE payments.adjustment ( id uuid NOT NULL DEFAULT gen_random_uuid(), @@ -235,7 +235,7 @@ func registerMigrations(migrator *migrations.Migrator) { migrations.Migration{ Up: func(tx bun.Tx) error { _, err := tx.Exec(` - CREATE TYPE transfer_status AS ENUM ('PENDING', 'SUCCEEDED', 'FAILED'); + CREATE TYPE "public".transfer_status AS ENUM ('PENDING', 'SUCCEEDED', 'FAILED'); CREATE TABLE payments.transfers ( id uuid NOT NULL DEFAULT gen_random_uuid(),