Merge pull request 'ayushman' (#30) from ayushman into main
Reviewed-on: #30
This commit is contained in:
commit
8c53d2df31
5 changed files with 61 additions and 1 deletions
19
src/db/addresses.nim
Normal file
19
src/db/addresses.nim
Normal file
|
@ -0,0 +1,19 @@
|
|||
import
|
||||
turso,
|
||||
strformat,
|
||||
json,
|
||||
strutils,
|
||||
../model/model
|
||||
|
||||
proc setupAddresses*(conn: Turso) =
|
||||
conn.execute("""
|
||||
CREATE TABLE Addresses (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
userId INTEGER,
|
||||
address TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
state TEXT NOT NULL,
|
||||
postalCode TEXT,
|
||||
FOREIGN KEY (userId) REFERENCES Users(id)
|
||||
);
|
||||
""")
|
BIN
src/db/db_up
BIN
src/db/db_up
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
./[users, products, orders, orderitems],
|
||||
./[users, products, orders, orderitems, addresses, payments, reviews],
|
||||
../lib/mics
|
||||
|
||||
var conn = newTurso()
|
||||
|
@ -8,3 +8,6 @@ setupUsers(conn)
|
|||
setupProducts(conn)
|
||||
setupOrders(conn)
|
||||
setupOrderItems(conn)
|
||||
setupAddresses(conn)
|
||||
setupPayments(conn)
|
||||
setupReviews(conn)
|
||||
|
|
18
src/db/payments.nim
Normal file
18
src/db/payments.nim
Normal file
|
@ -0,0 +1,18 @@
|
|||
import
|
||||
turso,
|
||||
strformat,
|
||||
json,
|
||||
strutils,
|
||||
../model/model
|
||||
|
||||
proc setupPayments*(conn: Turso) =
|
||||
conn.execute("""
|
||||
CREATE TABLE Payments (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
orderId INTEGER,
|
||||
paymentAmount REAL,
|
||||
paymentMethod TEXT,
|
||||
paymentDate DATE,
|
||||
FOREIGN KEY (orderId) REFERENCES Orders(id)
|
||||
);
|
||||
""")
|
20
src/db/reviews.nim
Normal file
20
src/db/reviews.nim
Normal file
|
@ -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)
|
||||
);
|
||||
""")
|
Loading…
Reference in a new issue