mte/include/sql/exchange-0004.sql
2025-11-11 10:10:33 +01:00

32 lines
716 B
PL/PgSQL

BEGIN;
SELECT _v.register_patch('exchange-0004', NULL, NULL);
SET search_path TO exchange;
CREATE OR REPLACE FUNCTION constrain_table_kyc_attributes4(
IN partition_suffix TEXT
)
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
table_name TEXT DEFAULT 'kyc_attributes';
BEGIN
table_name = concat_ws('_', table_name, partition_suffix);
EXECUTE FORMAT (
'ALTER TABLE ' || table_name ||
' ADD CONSTRAINT ' || table_name || '_legitimization_serial '
'UNIQUE (h_payto,legitimization_serial)'
);
END $$;
INSERT INTO exchange_tables
(name
,version
,action
,partitioned
,by_range)
VALUES
('kyc_attributes4'
,'exchange-0004'
,'constrain'
,TRUE
,FALSE);
COMMIT;