summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-11-24 16:20:08 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-11-24 16:20:08 +0100
commit95149f345fc1daefd2ea703538e31b1be29fb902 (patch)
tree8384901e0925dd355e7e998e4b9b2f7787615781 /src
parentc2bb6551cf453115884d35e2c440fc44797addf2 (diff)
downloadexchange-master.tar.gz
exchange-master.tar.bz2
exchange-master.zip
-draft for better sqlHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/common-0002.sql31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/exchangedb/common-0002.sql b/src/exchangedb/common-0002.sql
index a9c9cd1f..0f7b1f52 100644
--- a/src/exchangedb/common-0002.sql
+++ b/src/exchangedb/common-0002.sql
@@ -172,3 +172,34 @@ COMMENT ON FUNCTION create_shard_server2
IS 'Create a shard server on the master
node with all foreign tables and user mappings';
+
+
+--------------------------------
+
+CREATE TABLE IF NOT EXISTS partitioned_tables
+ (name VARCHAR PRIMARY KEY NOT NULL);
+
+INSERT INTO partitioned_tables
+ (name)
+ VALUES
+ ('wire_targets')
+ ,('refunds')
+ ON CONFLICT DO NOTHING;
+
+
+CREATE OR REPLACE FUNCTION drop_default_partitions()
+ RETURNS VOID
+ LANGUAGE plpgsql
+AS $$
+DECLARE
+ tc CURSOR FOR SELECT name FROM partitioned_tables;
+BEGIN
+
+ RAISE NOTICE 'Dropping default table partitions';
+ FOR rec IN tc
+ LOOP
+ EXECUTE FORMAT (
+ 'DROP TABLE IF EXISTS %s_default ;'::text,
+ rec.name;
+END
+$$;