This commit is contained in:
cereci5049 2024-08-18 01:15:16 +05:30
parent a144847869
commit 95386bb49a
4 changed files with 40 additions and 1 deletions

19
src/db/addresses.nim Normal file
View 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)
);
""")

Binary file not shown.

View file

@ -1,5 +1,5 @@
import
./[users, products, orders, orderitems],
./[users, products, orders, orderitems, addresses, payments],
../lib/mics
var conn = newTurso()
@ -8,3 +8,5 @@ setupUsers(conn)
setupProducts(conn)
setupOrders(conn)
setupOrderItems(conn)
setupAddresses(conn)
setupPayments(conn)

18
src/db/payments.nim Normal file
View 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)
);
""")