Skip to content

Commit 450a752

Browse files
committed
DDL for ratings + check_product + purchase
1 parent 5173f36 commit 450a752

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE DATABASE IF NOT EXISTS ratings;
2+
3+
CREATE TABLE IF NOT EXISTS ratings.feedback (
4+
id BIGINT AUTO_INCREMENT,
5+
customer_id BINARY(16),
6+
product_id MEDIUMINT,
7+
rating TINYINT,
8+
summary TEXT,
9+
helpful MEDIUMINT,
10+
active BOOLEAN DEFAULT TRUE,
11+
PRIMARY KEY (id)
12+
);
File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
DROP PROCEDURE IF EXISTS orders.check_product_purchase;
2+
3+
DELIMITER $$
4+
5+
CREATE PROCEDURE orders.check_product_purchase ( IN in_customer_id BINARY(16) , IN in_product_id MEDIUMINT )
6+
BEGIN
7+
8+
SELECT TRUE
9+
FROM orders.header AS h
10+
INNER JOIN orders.item AS i
11+
ON h.id = i.order_id
12+
WHERE h.customer_id = in_customer_id
13+
AND h.order_status_id in (3, 5)
14+
AND i.product_id = in_product_id
15+
LIMIT 1;
16+
17+
END $$
18+
19+
DELIMITER ;
File renamed without changes.
File renamed without changes.

src/migrations/procedures/get_latest_twenty_orders.sql renamed to src/migrations/procedures/orders/get_latest_twenty_orders.sql

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)