Skip to content

Commit

Permalink
fix: fix payments wise connector and migration (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-nicolas authored Jul 6, 2023
1 parent 52a869a commit cfaebaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{}{})
}
}

Expand Down
12 changes: 6 additions & 6 deletions components/payments/internal/app/storage/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down

1 comment on commit cfaebaa

@vercel
Copy link

@vercel vercel bot commented on cfaebaa Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.