-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.sql
More file actions
25 lines (23 loc) · 1.42 KB
/
Copy pathseed.sql
File metadata and controls
25 lines (23 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- =============================================
-- STEP 8: Seed Data - seed.sql
-- =============================================
-- This file inserts sample products so you can test the API immediately.
-- Run it manually: mysql -u root nodejs_from_zero_db < seed.sql
--
-- WHY seed data?
-- - Testing an API with an empty database is frustrating
-- - These rows let you test GET endpoints right after setup
-- - In production, use a migration tool (like Knex, Sequelize, or Flyway)
-- instead of manual SQL files
-- Clear existing data (safe for development only!)
-- WHY TRUNCATE instead of DELETE? TRUNCATE is faster and resets the auto-increment counter
TRUNCATE TABLE products;
-- Insert sample products
-- WHY these specific products? They cover different price ranges and categories
-- so you can test filtering, sorting, and edge cases
INSERT INTO products (name, description, price, quantity) VALUES
('MacBook Pro 16"', 'Apple laptop with M3 Pro chip, 18GB RAM, 512GB SSD', 2499.99, 15),
('Wireless Mouse', 'Ergonomic Bluetooth mouse with USB-C charging', 29.99, 200),
('Mechanical Keyboard', 'Cherry MX Brown switches, RGB backlight, TKL layout', 89.50, 75),
('USB-C Hub', '7-in-1 adapter: HDMI, USB-A x3, SD card, Ethernet, PD charge', 45.00, 120),
('27" 4K Monitor', 'IPS panel, 60Hz, USB-C input with 65W power delivery', 349.99, 30);