From cf2e37cd876651e799893e8fe5babb51a9e12dd7 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Sun, 27 Nov 2022 21:21:04 +0100
Subject: more work on SQL refactoring

---
 src/exchangedb/0002-reserves_in.sql | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

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

diff --git a/src/exchangedb/0002-reserves_in.sql b/src/exchangedb/0002-reserves_in.sql
index a5ef4dc8..d722a49e 100644
--- a/src/exchangedb/0002-reserves_in.sql
+++ b/src/exchangedb/0002-reserves_in.sql
@@ -61,8 +61,7 @@ BEGIN
     ,table_name
     ,partition_suffix
   );
-END
-$$;
+END $$;
 
 
 CREATE FUNCTION constrain_table_reserves_in(
@@ -76,9 +75,9 @@ DECLARE
 BEGIN
   table_name = concat_ws('_', table_name, partition_suffix);
   EXECUTE FORMAT (
-    'ALTER TABLE reserves_in_' || partition_suffix || ' '
-      'ADD CONSTRAINT reserves_in_' || partition_suffix || '_reserve_in_serial_id_key '
-        'UNIQUE (reserve_in_serial_id)'
+    'ALTER TABLE ' || table_name ||
+    ' ADD CONSTRAINT ' || table_name || '_reserve_in_serial_id_key'
+    ' UNIQUE (reserve_in_serial_id)'
   );
   EXECUTE FORMAT (
     'CREATE INDEX ' || table_name || '_by_reserve_in_serial_id_index '
-- 
cgit v1.2.3

