View Issue Details

IDProjectCategoryView StatusLast Update
0009431Talerlibeufin (general)public2025-01-06 11:45
ReporterAntoine A Assigned ToAntoine A  
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Target Version1.0 
Summary0009431: Simplify incoming talerable transactions schema
DescriptionThe current SQL schema for incoming talerable transactions for both libeufin-bank and libeufin-nexus is like:
```sql
CREATE TYPE incoming_type AS ENUM('reserve' ,'kyc', 'wad');
CREATE TABLE taler_in(
  type incoming_type NOT NULL,
  reserve_pub BYTEA UNIQUE CHECK (LENGTH(reserve_pub)=32),
  account_pub BYTEA CHECK (LENGTH(account_pub)=32),
  wad_id BYTEA CHECK (LENGTH(wad_id)=24),
  origin_exchange_url TEXT,
  CONSTRAINT polymorphism CHECK(
    CASE type
      WHEN 'reserve' THEN reserve_pub IS NOT NULL AND account_pub IS NULL AND origin_exchange_url IS NULL AND wad_id IS NULL
      WHEN 'kyc' THEN reserve_pub IS NULL AND account_pub IS NOT NULL AND origin_exchange_url IS NULL AND wad_id IS NULL
      WHEN 'wad' THEN reserve_pub IS NULL AND account_pub IS NULL AND origin_exchange_url IS NOT NULL AND wad_id IS NOT NULL
    END
  )
);
```

While writing the magnet bank schema from scratch I found we can simply this to:
```sql
CREATE TABLE taler_in(
  type incoming_type NOT NULL,
  metadata BYTEA NOT NULL,
  origin_exchange_url TEXT,
  CONSTRAINT polymorphism CHECK(
    CASE type
      WHEN 'wad' THEN LENGTH(metadata)=24 AND origin_exchange_url IS NOT NULL
      ELSE LENGTH(metadata)=32 AND origin_exchange_url IS NULL
    END
  )
);
CREATE UNIQUE INDEX taler_in_unique_reserve_pub ON taler_in (metadata) WHERE type = 'reserve';
```
This reduces the number of columns and simplifies SQL code and logic, while applying the same constraints.
TagsNo tags attached.

Activities

Antoine A

2025-01-06 11:45

developer   ~0023939

Fixed in 3fcbe27ff2dba6778607e19d10367adaff095a65

Issue History

Date Modified Username Field Change
2024-12-30 18:17 Antoine A New Issue
2024-12-30 18:17 Antoine A Status new => assigned
2024-12-30 18:17 Antoine A Assigned To => Antoine A
2025-01-06 11:45 Antoine A Status assigned => resolved
2025-01-06 11:45 Antoine A Resolution open => fixed
2025-01-06 11:45 Antoine A Note Added: 0023939