From 131c856bdd5c48bbd8358fc8c1840fce4fcf2178 Mon Sep 17 00:00:00 2001
From: Masaya Tojo <masaya@tojo.tokyo>
Date: Sun, 5 Mar 2023 14:29:29 +0900
Subject: Rename column of transactions from type to type_code.

---
 revert/insert_transaction@v1.0.0-dev3.sql | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 revert/insert_transaction@v1.0.0-dev3.sql

(limited to 'revert/insert_transaction@v1.0.0-dev3.sql')

diff --git a/revert/insert_transaction@v1.0.0-dev3.sql b/revert/insert_transaction@v1.0.0-dev3.sql
new file mode 100644
index 0000000..d15552f
--- /dev/null
+++ b/revert/insert_transaction@v1.0.0-dev3.sql
@@ -0,0 +1,25 @@
+-- Deploy kakeibo:insert_transaction to pg
+-- requires: appschema
+-- requires: transactions
+
+BEGIN;
+
+DROP FUNCTION kakeibo.insert_transaction(INTEGER, DATE, TEXT);
+CREATE OR REPLACE FUNCTION kakeibo.insert_transaction(
+  p_type kakeibo.transaction_type,
+  p_date DATE,
+  p_note TEXT
+) RETURNS INTEGER AS $$
+DECLARE
+  inserted_id INTEGER;
+BEGIN
+  INSERT INTO kakeibo.transactions (
+    type, date, note
+  ) VALUES (
+    p_type, p_date, p_note
+  ) RETURNING id INTO inserted_id;
+  RETURN inserted_id;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+COMMIT;
-- 
cgit v1.2.3

