E-Commerce-Module/db/init/02-seed.sql

191 lines
No EOL
4.9 KiB
SQL

-- Seed data for testing
-- Insert test users
INSERT INTO users (email, first_name, last_name) VALUES
('shaivkamat@2many.ca', 'Shaiv', 'Kamat'),
('jane@example.com', 'Jane', 'Smith'),
('bob@example.com', 'Bob', 'Johnson');
-- Note: Product categories are already inserted in the schema file, so we're skipping that step
-- Insert rock products
WITH categories AS (
SELECT id, name FROM product_categories
)
-- Insert rock products
INSERT INTO products (name, description, category_id, price, stock_quantity, weight_grams, color, material_type, origin, image_url)
SELECT
'Amethyst Geode',
'Beautiful purple amethyst geode with crystal formation',
id,
49.99,
15,
450.0,
'Purple',
'Quartz',
'Brazil',
NULL
FROM categories WHERE name = 'Rock';
WITH categories AS (
SELECT id, name FROM product_categories
)
INSERT INTO products (name, description, category_id, price, stock_quantity, weight_grams, color, material_type, origin, image_url)
SELECT
'Polished Labradorite',
'Stunning polished labradorite with iridescent blue flash',
id,
29.99,
25,
120.5,
'Gray/Blue',
'Feldspar',
'Madagascar',
NULL
FROM categories WHERE name = 'Rock';
WITH categories AS (
SELECT id, name FROM product_categories
)
INSERT INTO products (name, description, category_id, price, stock_quantity, weight_grams, color, material_type, origin, image_url)
SELECT
'Raw Turquoise',
'Natural turquoise specimen, unpolished',
id,
19.99,
18,
85.2,
'Turquoise',
'Turquoise',
'Arizona',
NULL
FROM categories WHERE name = 'Rock';
-- Insert bone products
WITH categories AS (
SELECT id, name FROM product_categories
)
INSERT INTO products (name, description, category_id, price, stock_quantity, length_cm, material_type, image_url)
SELECT
'Deer Antler',
'Naturally shed deer antler, perfect for display or crafts',
id,
24.99,
8,
38.5,
'Antler',
NULL
FROM categories WHERE name = 'Bone';
WITH categories AS (
SELECT id, name FROM product_categories
)
INSERT INTO products (name, description, category_id, price, stock_quantity, length_cm, material_type, image_url)
SELECT
'Fossil Fish',
'Well-preserved fossil fish from the Green River Formation',
id,
89.99,
5,
22.8,
'Fossilized Bone',
NULL
FROM categories WHERE name = 'Bone';
-- Insert stick products
WITH categories AS (
SELECT id, name FROM product_categories
)
INSERT INTO products (name, description, category_id, price, stock_quantity, length_cm, width_cm, material_type, color, image_url)
SELECT
'Driftwood Piece',
'Unique driftwood piece, weathered by the ocean',
id,
14.99,
12,
45.6,
8.3,
'Driftwood',
'Tan/Gray',
NULL
FROM categories WHERE name = 'Stick';
WITH categories AS (
SELECT id, name FROM product_categories
)
INSERT INTO products (name, description, category_id, price, stock_quantity, length_cm, width_cm, material_type, color, image_url)
SELECT
'Walking Stick',
'Hand-selected natural maple walking stick',
id,
34.99,
10,
152.4,
3.8,
'Maple',
'Brown',
NULL
FROM categories WHERE name = 'Stick';
WITH categories AS (
SELECT id, name FROM product_categories
)
INSERT INTO products (name, description, category_id, price, stock_quantity, length_cm, width_cm, material_type, color, image_url)
SELECT
'Decorative Branch Set',
'Set of 3 decorative birch branches for home decoration',
id,
19.99,
20,
76.2,
1.5,
'Birch',
'White',
NULL
FROM categories WHERE name = 'Stick';
-- Create a cart for testing
INSERT INTO carts (user_id)
SELECT id FROM users WHERE email = 'jane@example.com';
-- Add product tags - using a different approach
-- Tag: Decorative for Amethyst Geode
INSERT INTO product_tags (product_id, tag_id)
SELECT p.id, t.id
FROM products p, tags t
WHERE p.name = 'Amethyst Geode' AND t.name = 'Decorative';
-- Tag: Polished for Polished Labradorite
INSERT INTO product_tags (product_id, tag_id)
SELECT p.id, t.id
FROM products p, tags t
WHERE p.name = 'Polished Labradorite' AND t.name = 'Polished';
-- Tag: Raw for Raw Turquoise
INSERT INTO product_tags (product_id, tag_id)
SELECT p.id, t.id
FROM products p, tags t
WHERE p.name = 'Raw Turquoise' AND t.name = 'Raw';
-- Tags: Fossil and Educational for Fossil Fish
INSERT INTO product_tags (product_id, tag_id)
SELECT p.id, t.id
FROM products p, tags t
WHERE p.name = 'Fossil Fish' AND t.name = 'Fossil';
INSERT INTO product_tags (product_id, tag_id)
SELECT p.id, t.id
FROM products p, tags t
WHERE p.name = 'Fossil Fish' AND t.name = 'Educational';
-- Tag: Decorative for Driftwood Piece
INSERT INTO product_tags (product_id, tag_id)
SELECT p.id, t.id
FROM products p, tags t
WHERE p.name = 'Driftwood Piece' AND t.name = 'Decorative';
-- Tag: Collectible for Walking Stick
INSERT INTO product_tags (product_id, tag_id)
SELECT p.id, t.id
FROM products p, tags t
WHERE p.name = 'Walking Stick' AND t.name = 'Collectible';