diff --git a/src/db/db_up b/src/db/db_up index 4ffdedd..ee5e9dd 100755 Binary files a/src/db/db_up and b/src/db/db_up differ diff --git a/src/db/db_up.nim b/src/db/db_up.nim index c9fde44..57b4811 100644 --- a/src/db/db_up.nim +++ b/src/db/db_up.nim @@ -1,5 +1,5 @@ import - ./[users, products, orders, orderitems, addresses, payments], + ./[users, products, orders, orderitems, addresses, payments, reviews], ../lib/mics var conn = newTurso() @@ -10,3 +10,4 @@ setupOrders(conn) setupOrderItems(conn) setupAddresses(conn) setupPayments(conn) +setupReviews(conn) diff --git a/src/db/reviews.nim b/src/db/reviews.nim new file mode 100644 index 0000000..fdb6b13 --- /dev/null +++ b/src/db/reviews.nim @@ -0,0 +1,20 @@ +import + turso, + strformat, + json, + strutils, + ../model/model + +proc setupReviews*(conn: Turso) = + conn.execute(""" + CREATE TABLE Reviews ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + productId INTEGER, + buyerId INTEGER, + rating INTEGER, + comment TEXT, + reviewDate DATE, + FOREIGN KEY (productId) REFERENCES Products(id), + FOREIGN KEY (buyerId) REFERENCES Users(id) + ); + """)