Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix payments wise connector and migration #419

Merged
merged 1 commit into from
Jul 6, 2023
Merged
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
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