order-system/migrations/002_create_products.sql
ReeseLin bee03ea349 Initial commit: Go + PostgreSQL order management system
- 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
2026-06-15 17:14:18 +08:00

13 lines
479 B
SQL

CREATE TABLE IF NOT EXISTS products (
id BIGSERIAL PRIMARY KEY,
name VARCHAR(200) NOT NULL,
category VARCHAR(50) NOT NULL,
price NUMERIC(10,2) NOT NULL DEFAULT 0,
stock INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_products_category ON products(category);
CREATE INDEX idx_products_name ON products(name);