- Backend: Go 1.26 + Chi router + pgx v5 (no ORM, hand-written SQL) - Database: PostgreSQL with 5 tables (users, products, orders, order_items, payments) - Frontend admin: Vue 3 + Vite + Element Plus - Docker Compose for PostgreSQL + pgAdmin - Includes SQL learning docs and seed data - Endpoints: products CRUD, orders CRUD, reports (daily sales, top products, customer spending) - New: GET /api/orders/by-date for date-range order query
11 lines
426 B
SQL
11 lines
426 B
SQL
CREATE TABLE IF NOT EXISTS order_items (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
order_id BIGINT NOT NULL REFERENCES orders(id),
|
|
product_id BIGINT NOT NULL REFERENCES products(id),
|
|
quantity INTEGER NOT NULL,
|
|
unit_price NUMERIC(10,2) NOT NULL
|
|
);
|
|
|
|
CREATE INDEX idx_order_items_order_id ON order_items(order_id);
|
|
CREATE INDEX idx_order_items_product_id ON order_items(product_id);
|