diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-11-27 21:21:04 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-11-27 21:21:04 +0100 |
commit | cf2e37cd876651e799893e8fe5babb51a9e12dd7 (patch) | |
tree | 437047cc646fb1a3a86f4226fd5460bbe2b0c530 /src/exchangedb/0002-aggregation_tracking.sql | |
parent | f2ba02aab2b9bbd976107ecc4ac7e7d657a9d73a (diff) | |
download | exchange-cf2e37cd876651e799893e8fe5babb51a9e12dd7.tar.xz |
more work on SQL refactoring
Diffstat (limited to 'src/exchangedb/0002-aggregation_tracking.sql')
-rw-r--r-- | src/exchangedb/0002-aggregation_tracking.sql | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/exchangedb/0002-aggregation_tracking.sql b/src/exchangedb/0002-aggregation_tracking.sql index d5c852e87..bd636d6fc 100644 --- a/src/exchangedb/0002-aggregation_tracking.sql +++ b/src/exchangedb/0002-aggregation_tracking.sql @@ -15,7 +15,7 @@ -- CREATE FUNCTION create_table_aggregation_tracking( - IN shard_suffix VARCHAR DEFAULT NULL + IN partition_suffix VARCHAR DEFAULT NULL ) RETURNS VOID LANGUAGE plpgsql @@ -31,18 +31,18 @@ BEGIN ') %s ;' ,table_name ,'PARTITION BY HASH (deposit_serial_id)' - ,shard_suffix + ,partition_suffix ); PERFORM comment_partitioned_table( 'mapping from wire transfer identifiers (WTID) to deposits (and back)' ,table_name - ,shard_suffix + ,partition_suffix ); PERFORM comment_partitioned_column( 'identifier of the wire transfer' ,'wtid_raw' ,table_name - ,shard_suffix + ,partition_suffix ); END $$; @@ -57,7 +57,7 @@ AS $$ DECLARE table_name VARCHAR DEFAULT 'aggregation_tracking'; BEGIN - table_name = concat_ws('_', table_name, shard_suffix); + table_name = concat_ws('_', table_name, partition_suffix); EXECUTE FORMAT ( 'CREATE INDEX ' || table_name || '_by_wtid_raw_index ' 'ON ' || table_name || ' ' @@ -86,8 +86,10 @@ BEGIN EXECUTE FORMAT ( 'ALTER TABLE ' || table_name || ' ADD CONSTRAINT ' || table_name || '_foreign_deposit' + ' FOREIGN KEY (deposit_serial_id) ' ' REFERENCES deposits (deposit_serial_id) ON DELETE CASCADE' -- FIXME change to coin_pub + deposit_serial_id for more efficient deposit??? ',ADD CONSTRAINT ' || table_name || '_foreign_wtid_raw' + ' FOREIGN KEY (wtid_raw) ' ' REFERENCES wire_out(wtid_raw) ON DELETE CASCADE DEFERRABLE' ); END |