From: Jakub Czajka Date: Sat, 13 Jan 2024 23:16:53 +0000 (+0100) Subject: Stop tracking units for purchases. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=db333a00b20eab031f2747eaab08cd0530a3db70;p=payments.git Stop tracking units for purchases. --- diff --git a/create.sql b/create.sql index f677b48..9e1a462 100644 --- a/create.sql +++ b/create.sql @@ -21,11 +21,6 @@ CREATE TABLE IF NOT EXISTS currencies ( name VARCHAR(128) NOT NULL UNIQUE ); -CREATE TABLE IF NOT EXISTS units ( - id SERIAL PRIMARY KEY, - name VARCHAR(128) NOT NULL UNIQUE -); - CREATE TABLE IF NOT EXISTS purchases ( id SERIAL PRIMARY KEY, shop_id INTEGER REFERENCES shops (id), @@ -34,7 +29,6 @@ CREATE TABLE IF NOT EXISTS purchases ( date DATE DEFAULT CURRENT_DATE, price DECIMAL(12,2) NOT NULL, currency_id INTEGER REFERENCES currencies (id), - unit_id INTEGER REFERENCES units (id), discount BOOLEAN DEFAULT FALSE ); @@ -45,19 +39,19 @@ BEGIN CREATE ROLE payments_tracker LOGIN; GRANT SELECT - ON TABLE shops, products, payment_methods, currencies, units, purchases + ON TABLE shops, products, payment_methods, currencies, purchases TO payments_tracker; GRANT INSERT - ON TABLE shops, products, payment_methods, currencies, units, purchases + ON TABLE shops, products, payment_methods, currencies, purchases TO payments_tracker; GRANT UPDATE - ON TABLE shops, products, payment_methods, currencies, units, purchases + ON TABLE shops, products, payment_methods, currencies, purchases TO payments_tracker; GRANT USAGE, SELECT - ON SEQUENCE shops_id_seq, products_id_seq, payment_methods_id_seq, currencies_id_seq , units_id_seq, purchases_id_seq + ON SEQUENCE shops_id_seq, products_id_seq, payment_methods_id_seq, currencies_id_seq , purchases_id_seq TO payments_tracker; /* Execute for the current database. */ diff --git a/drop.sql b/drop.sql index f8bb488..339bbfe 100644 --- a/drop.sql +++ b/drop.sql @@ -6,19 +6,19 @@ BEGIN IF EXISTS (SELECT * FROM pg_user WHERE usename = 'payments_tracker') THEN REVOKE SELECT - ON TABLE shops, products, payment_methods, currencies, units, purchases + ON TABLE shops, products, payment_methods, currencies, purchases FROM payments_tracker; REVOKE INSERT - ON TABLE shops, products, payment_methods, currencies, units, purchases + ON TABLE shops, products, payment_methods, currencies, purchases FROM payments_tracker; REVOKE UPDATE - ON TABLE shops, products, payment_methods, currencies, units, purchases + ON TABLE shops, products, payment_methods, currencies, purchases FROM payments_tracker; REVOKE USAGE, SELECT - ON SEQUENCE shops_id_seq, products_id_seq, payment_methods_id_seq, currencies_id_seq, units_id_seq, purchases_id_seq + ON SEQUENCE shops_id_seq, products_id_seq, payment_methods_id_seq, currencies_id_seq, purchases_id_seq FROM payments_tracker; EXECUTE @@ -35,4 +35,3 @@ DROP TABLE IF EXISTS shops; DROP TABLE IF EXISTS products; DROP TABLE IF EXISTS payment_methods; DROP TABLE IF EXISTS currencies; -DROP TABLE IF EXISTS units; diff --git a/payment.sh b/payment.sh index 5804a72..0e5c2d1 100644 --- a/payment.sh +++ b/payment.sh @@ -47,9 +47,6 @@ price=$(get_query_param "price") currency=$(get_query_param "currency") currency_id=$(insert_into "currencies" "${currency}") -unit=$(get_query_param "unit") -unit_id=$(insert_into "units" "${unit}") - payment_method=$(get_query_param "payment_method") payment_method_id=$(insert_into "payment_methods" "${payment_method}") @@ -69,7 +66,6 @@ WITH new_purchase_id AS ( date, price, currency_id, - unit_id, discount ) VALUES ( @@ -79,7 +75,6 @@ WITH new_purchase_id AS ( '${purchase_date}', ${price}, ${currency_id}, - ${unit_id}, ${discount} ) RETURNING id @@ -103,8 +98,8 @@ PAGE=" Recorded new purchase (id=${purchase_id}) of ${product} \ (id=${product_id}) on ${purchase_date} in ${shop} (id=${shop_id}). Payed \ -${price} ${currency} (id=${currency_id}) for ${unit} (id=${unit_id}) with \ -${payment_method} (id=${payment_method_id}) (discount=${discount}). +${price} ${currency} (id=${currency_id}) with ${payment_method} \ +(id=${payment_method_id}) (discount=${discount}). " diff --git a/payments.sh b/payments.sh index c1034f4..0a31e5c 100644 --- a/payments.sh +++ b/payments.sh @@ -70,11 +70,6 @@ PAGE=" $(query_db "SELECT name FROM currencies" | as_options) - - - $(query_db "SELECT name FROM units" | as_options) - -