diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-03-28 13:05:45 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-03-28 13:05:45 +0100 |
commit | 517876451e1a40ca18a1860fb1fa4088f3e0408c (patch) | |
tree | 87e987d59e0e38e20738776aec98ecd62cc9785d /src/exchangedb/0004-refunds.sql | |
parent | 9310bd13f9437b94fd0885d77b019d49bc674e3c (diff) | |
download | exchange-517876451e1a40ca18a1860fb1fa4088f3e0408c.tar.xz |
update schema to fix broken primary key constraint
Diffstat (limited to 'src/exchangedb/0004-refunds.sql')
-rw-r--r-- | src/exchangedb/0004-refunds.sql | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/exchangedb/0004-refunds.sql b/src/exchangedb/0004-refunds.sql new file mode 100644 index 000000000..71666d9db --- /dev/null +++ b/src/exchangedb/0004-refunds.sql @@ -0,0 +1,35 @@ + +CREATE FUNCTION constrain_table_refunds4 ( + IN partition_suffix TEXT DEFAULT NULL +) +RETURNS void +LANGUAGE plpgsql +AS $$ +DECLARE + table_name TEXT DEFAULT 'refunds'; +BEGIN + table_name = concat_ws('_', table_name, partition_suffix); + + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' DROP CONSTRAINT refunds_pkey' + ); + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' ADD PRIMARY KEY (batch_deposit_serial_id, coin_pub, rtransaction_id) ' + ); +END +$$; + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('refunds4' + ,'exchange-0004' + ,'constrain' + ,TRUE + ,FALSE); |