aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/0004-refunds.sql
blob: eb9e7ad6e38d5b184c7495d2c1046b4cff866c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 ' || table_name || '_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);