From 9580dd19c23e5591cc022dce717eca7bc745c5b0 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Sun, 27 Nov 2022 00:16:00 +0100
Subject: intermediate step in major SQL refactoring (not done at all)

---
 src/exchangedb/common-0002.sql | 104 -----------------------------------------
 1 file changed, 104 deletions(-)

(limited to 'src/exchangedb/common-0002.sql')

diff --git a/src/exchangedb/common-0002.sql b/src/exchangedb/common-0002.sql
index 388d5547e..649efa11c 100644
--- a/src/exchangedb/common-0002.sql
+++ b/src/exchangedb/common-0002.sql
@@ -16,27 +16,6 @@
 
 --------------------------------
 
-CREATE TABLE IF NOT EXISTS exchange_tables
-  (table_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY
-  ,name VARCHAR NOT NULL
-  ,version VARCHAR NOT NULL
-  ,action VARCHAR NOT NULL
-  ,partitioned BOOL NOT NULL
-  ,by_range BOOL NOT NULL);
-COMMENT ON TABLE exchange_tables
-  IS 'Tables of the exchange and their status';
-COMMENT ON COLUMN exchange_tables.name
-  IS 'Base name of the table (without partition/shard)';
-COMMENT ON COLUMN exchange_tables.version
-  IS 'Version of the DB in which the given action happened';
-COMMENT ON COLUMN exchange_tables.action
-  IS 'Action to take on the table (e.g. create, alter, constrain, unconstrain, or drop)';
-COMMENT ON COLUMN exchange_tables.partitioned
-  IS 'TRUE if the table is partitioned';
-COMMENT ON COLUMN exchange_tables.by_range
-  IS 'TRUE if the table is partitioned by range';
-
-
 INSERT INTO exchange_tables
     (name
     ,version
@@ -44,10 +23,6 @@ INSERT INTO exchange_tables
     ,partitioned
     ,by_range)
   VALUES
-    ('denominations', 'exchange-0001', 'create', FALSE, FALSE)
-   ,('denomination_revocations', 'exchange-0001', 'create', FALSE, FALSE)
-   ,('kyc_alerts', 'exchange-0001', 'create', FALSE, FALSE)
-   ,('profit_drains', 'exchange-0001', 'create', FALSE, FALSE)
    ,('auditors', 'exchange-0001', 'create', FALSE, FALSE)
    ,('auditor_denom_sigs', 'exchange-0001', 'create', FALSE, FALSE)
    ,('exchange_sign_keys', 'exchange-0001', 'create', FALSE, FALSE)
@@ -106,82 +81,3 @@ INSERT INTO exchange_tables
 
 
 -------------------- Tables ----------------------------
-
-CREATE OR REPLACE FUNCTION create_table_purse_deletion(
-  IN shard_suffix VARCHAR DEFAULT NULL
-)
-RETURNS VOID
-LANGUAGE plpgsql
-AS $$
-BEGIN
-  PERFORM create_partitioned_table(
-    'CREATE TABLE IF NOT EXISTS %I'
-      '(purse_deletion_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE'
-      ',purse_sig BYTEA CHECK (LENGTH(purse_sig)=64)'
-      ',XXX VARCHAR NOT NULL'
-    ') %s ;'
-    ,'purse_deletion'
-    ,'PARTITION BY HASH (XXX)'
-    ,shard_suffix
-  );
-  COMMENT ON TABLE purse_deletion
-    IS 'signatures affirming explicit purse deletions';
-  COMMENT ON COLUMN purse_deletion.purse_sig
-    IS 'signature of type XXX';
-END
-$$;
-COMMENT ON FUNCTION create_table_purse_deletion
-  IS 'Creates the purse_deletion table';
-
-CREATE OR REPLACE FUNCTION constrain_table_purse_deletion(
-  IN partition_suffix VARCHAR
-)
-RETURNS void
-LANGUAGE plpgsql
-AS $$
-BEGIN
-  EXECUTE FORMAT (
-    'ALTER TABLE purse_deletion_' || partition_suffix || ' '
-      'ADD CONSTRAINT purse_deletion_' || partition_suffix || '_XXX '
-        'UNIQUE (XXX)'
-  );
-END
-$$;
-
-CREATE OR REPLACE FUNCTION alter_create_was_deleted_table_purse_requests (
-  IN partition_suffix VARCHAR
-)
-RETURNS void
-LANGUAGE plpgsql
-AS $$
-BEGIN
-  EXECUTE FORMAT (
-    'ALTER TABLE purse_requests_' || partition_suffix ||
-    ' ADD COLUMN'
-    ' was_deleted BOOLEAN NOT NULL DEFAULT(FALSE)'
-  );
-END
-$$;
-
-INSERT INTO exchange_tables
-    (name
-    ,version
-    ,action
-    ,partitioned
-    ,by_range)
-  VALUES
-    ('purse_deletion'
-    ,'exchange-0002'
-    ,'create'
-    ,TRUE
-    ,FALSE),
-    ('purse_deletion'
-    ,'exchange-0002'
-    ,'constrain'
-    ,TRUE
-    ,FALSE),
-    ('purse_requests'
-    ,'exchange-0002'
-    ,'alter_create_was_deleted'
-    ,TRUE
-    ,FALSE);
-- 
cgit v1.2.3

