--
-- This file is part of TALER
-- Copyright (C) 2026 Taler Systems SA
--
-- TALER is free software; you can redistribute it and/or modify it under the
-- terms of the GNU General Public License as published by the Free Software
-- Foundation; either version 3, or (at your option) any later version.
--
-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along with
-- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
--

ALTER TABLE wire_accounts
  ADD COLUMN open_banking_gateway
    TEXT DEFAULT (NULL)
 ,ADD COLUMN wire_transfer_gateway
    TEXT DEFAULT (NULL)
 ,ADD COLUMN sig_version
    INT4 DEFAULT 33; -- all existing entries are <= v33
COMMENT ON COLUMN wire_accounts.open_banking_gateway
  IS 'URL of an open banking gateway that can be used to initiate wire transfers to this account; NULL if there is no such service.';
COMMENT ON COLUMN wire_accounts.wire_transfer_gateway
  IS 'URL of a prepared transfer service that can be used to obtain (short) wire transfer subjects; NULL if there is no such service.';
COMMENT ON COLUMN wire_accounts.sig_version
  IS 'Protocol version used by the master_sig in this column. Used to tell which algorithm is needed to verify the signature.';

-- The master_sig changes in protocol v33, hence deactivate all old
-- signatures/accounts.
UPDATE wire_accounts
  SET is_active=FALSE
  WHERE sig_version<34;

-- New signatures will follow protocol >= v34
ALTER TABLE wire_accounts
  ALTER COLUMN sig_version SET DEFAULT 34;
