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-reserves_out.sql | |
parent | f2ba02aab2b9bbd976107ecc4ac7e7d657a9d73a (diff) | |
download | exchange-cf2e37cd876651e799893e8fe5babb51a9e12dd7.tar.xz |
more work on SQL refactoring
Diffstat (limited to 'src/exchangedb/0002-reserves_out.sql')
-rw-r--r-- | src/exchangedb/0002-reserves_out.sql | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/exchangedb/0002-reserves_out.sql b/src/exchangedb/0002-reserves_out.sql index 525672893..77112f504 100644 --- a/src/exchangedb/0002-reserves_out.sql +++ b/src/exchangedb/0002-reserves_out.sql @@ -71,9 +71,9 @@ DECLARE BEGIN table_name = concat_ws('_', table_name, partition_suffix); EXECUTE FORMAT ( - 'ALTER TABLE ' || table_name || ' ' - 'ADD CONSTRAINT ' || table_name || '_reserve_out_serial_id_key ' - 'UNIQUE (reserve_out_serial_id)' + 'ALTER TABLE ' || table_name || + ' ADD CONSTRAINT ' || table_name || '_reserve_out_serial_id_key' + ' UNIQUE (reserve_out_serial_id)' ); -- FIXME: change query to use reserves_out_by_reserve instead and materialize execution_date there as well??? EXECUTE FORMAT ( @@ -97,11 +97,13 @@ DECLARE table_name VARCHAR default 'reserves_out'; BEGIN EXECUTE FORMAT ( - 'ALTER TABLE ' || table_name || ' ' - 'ADD CONSTRAINT ' || table_name || '_foreign_denom ' - 'REFERENCES denominations (denominations_serial)' - 'ADD CONSTRAINT ' || table_name || '_foreign_reserve ' - 'REFERENCES reserves (reserve_uuid) ON DELETE CASCADE' + 'ALTER TABLE ' || table_name || + ' ADD CONSTRAINT ' || table_name || '_foreign_denom' + ' FOREIGN KEY (denominations_serial)' + ' REFERENCES denominations (denominations_serial)' + ',ADD CONSTRAINT ' || table_name || '_foreign_reserve ' + ' FOREIGN KEY (reserve_uuid)' + ' REFERENCES reserves (reserve_uuid) ON DELETE CASCADE' ); END $$; @@ -125,7 +127,7 @@ BEGIN ,'PARTITION BY HASH (reserve_uuid)' ,partition_suffix ); - PERFORM comment_partitioned_column ( + PERFORM comment_partitioned_table ( 'Information in this table is strictly redundant with that of reserves_out, but saved by a different primary key for fast lookups by reserve public key/uuid.' ,table_name ,partition_suffix |