diff options
Diffstat (limited to 'src/exchangedb/0002-legitimization_processes.sql')
-rw-r--r-- | src/exchangedb/0002-legitimization_processes.sql | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/src/exchangedb/0002-legitimization_processes.sql b/src/exchangedb/0002-legitimization_processes.sql index 1be54c3ca..6248da1f0 100644 --- a/src/exchangedb/0002-legitimization_processes.sql +++ b/src/exchangedb/0002-legitimization_processes.sql @@ -14,16 +14,15 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -CREATE OR REPLACE FUNCTION create_table_legitimization_processes( +CREATE FUNCTION create_table_legitimization_processes( IN shard_suffix VARCHAR DEFAULT NULL ) RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN - PERFORM create_partitioned_table( - 'CREATE TABLE IF NOT EXISTS %I' + 'CREATE TABLE %I' '(legitimization_process_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE' ',h_payto BYTEA NOT NULL CHECK (LENGTH(h_payto)=32)' ',expiration_time INT8 NOT NULL DEFAULT (0)' @@ -36,13 +35,53 @@ BEGIN ,'PARTITION BY HASH (h_payto)' ,shard_suffix ); - + PERFORM comment_partitioned_table( + 'List of legitimization processes (ongoing and completed) by account and provider' + ,'legitimization_processes' + ,shard_suffix + ); + PERFORM comment_partitioned_column( + 'unique ID for this legitimization process at the exchange' + ,'legitimization_process_serial_id' + ,'legitimization_processes' + ,shard_suffix + ); + PERFORM comment_partitioned_column( + 'foreign key linking the entry to the wire_targets table, NOT a primary key (multiple legitimizations are possible per wire target)' + ,'h_payto' + ,'legitimization_processes' + ,shard_suffix + ); + PERFORM comment_partitioned_column( + 'in the future if the respective KYC check was passed successfully' + ,'expiration_time' + ,'legitimization_processes' + ,shard_suffix + ); + PERFORM comment_partitioned_column( + 'Configuration file section with details about this provider' + ,'provider_section' + ,'legitimization_processes' + ,shard_suffix + ); + PERFORM comment_partitioned_column( + 'Identifier for the user at the provider that was used for the legitimization. NULL if provider is unaware.' + ,'provider_user_id' + ,'legitimization_processes' + ,shard_suffix + ); + PERFORM comment_partitioned_column( + 'Identifier for the specific legitimization process at the provider. NULL if legitimization was not started.' + ,'provider_legitimization_id' + ,'legitimization_processes' + ,shard_suffix + ); END $$; -- We need a separate function for this, as we call create_table only once but need to add -- those constraints to each partition which gets created -CREATE OR REPLACE FUNCTION add_constraints_to_legitimization_processes_partition( +CREATE FUNCTION constrain_table_legitimization_processes( IN partition_suffix VARCHAR ) RETURNS void @@ -51,7 +90,6 @@ AS $$ DECLARE partition_name VARCHAR; BEGIN - partition_name = concat_ws('_', 'legitimization_processes', partition_suffix); EXECUTE FORMAT ( @@ -83,4 +121,9 @@ INSERT INTO exchange_tables ,'exchange-0002' ,'create' ,TRUE + ,FALSE), + ('legitimization_processes' + ,'exchange-0002' + ,'constrain' + ,TRUE ,FALSE); |