047
This commit is contained in:
parent
a144847869
commit
95386bb49a
4 changed files with 40 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],
|
||||
../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
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)
|
||||
);
|
||||
""")
|
Loading…
Reference in a new issue