exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

0006-auditor_coin_inconsistency.sql (1581B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2026 Taler Systems SA
      4 --
      5 -- TALER is free software; you can redistribute it and/or modify it under the
      6 -- terms of the GNU General Public License as published by the Free Software
      7 -- Foundation; either version 3, or (at your option) any later version.
      8 --
      9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 --
     13 -- You should have received a copy of the GNU General Public License along with
     14 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 --
     16 
     17 -- "profitable" is tri-state: the helpers report 1 if the inconsistency
     18 -- favours the exchange, -1 if it is a loss for the exchange and 0 if
     19 -- that is unclear.  It used to be a BOOLEAN, which stored both 1 and -1
     20 -- as TRUE and 0 as FALSE.  Old rows therefore map TRUE to 1 and FALSE to
     21 -- 0; a loss recorded before this migration stays reported as a profit, as
     22 -- the original sign cannot be recovered.
     23 ALTER TABLE auditor_coin_inconsistency
     24   ALTER COLUMN profitable TYPE SMALLINT
     25     USING (CASE WHEN profitable THEN 1 ELSE 0 END)
     26   ,ADD CONSTRAINT auditor_coin_inconsistency_profitable_check
     27     CHECK (profitable BETWEEN -1 AND 1);
     28 COMMENT ON COLUMN auditor_coin_inconsistency.profitable
     29   IS '1 if the inconsistency is profitable for the exchange, -1 if it is a loss for the exchange, 0 if unclear; rows created before auditor-0006 only have 1 (profit or loss) and 0';