View Issue Details

IDProjectCategoryView StatusLast Update
0009431Talerlibeufin (general)public2025-05-10 02:11
ReporterAntoine A Assigned ToAntoine A Resolution deadline
ImplementerReviewer 
Release signed byDeployed by 
VerifierCommunicator 
Data protection authority notification requiredNo  
CSIRT notification requiredNo  
Estimated effort (hours)Actual effort (hours)0 
Fast-trackNo
Work packagenone
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Target Version1.0Fixed in 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.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

Antoine A

2025-01-06 10:45

manager   ~0023939

Fixed in 3fcbe27ff2dba6778607e19d10367adaff095a65

Issue History

Date ModifiedUsernameFieldChange
2024-12-30 17:17Antoine ANew Issue
2024-12-30 17:17Antoine AStatusnew => assigned
2024-12-30 17:17Antoine AAssigned To => Antoine A
2025-01-06 10:45Antoine AStatusassigned => informing
2025-01-06 10:45Antoine AResolutionopen => fixed
2025-01-06 10:45Antoine ANote Added: 0023939
2025-02-14 21:42Christian GrothoffFixed in Version => 1.0
2025-05-10 02:11Christian GrothoffStatusinforming => closed