-- Migration: Seed Default Units
-- Week 2: Pre-populate common measurement units with conversions

-- Weight units (metric base: gram)
INSERT INTO units (id, name, abbreviation, unit_type, base_unit_id, conversion_factor, is_default, created_by) VALUES
  ('f47ac10b-58cc-4372-a567-0e02b2c3d479', 'Gram', 'g', 'weight', NULL, 1.0, TRUE, NULL),
  ('550e8400-e29b-41d4-a716-446655440001', 'Kilogram', 'kg', 'weight', 'f47ac10b-58cc-4372-a567-0e02b2c3d479', 1000.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440002', 'Milligram', 'mg', 'weight', 'f47ac10b-58cc-4372-a567-0e02b2c3d479', 0.001, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440003', 'Pound', 'lb', 'weight', 'f47ac10b-58cc-4372-a567-0e02b2c3d479', 453.592, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440004', 'Ounce', 'oz', 'weight', 'f47ac10b-58cc-4372-a567-0e02b2c3d479', 28.3495, FALSE, NULL);

-- Volume units (metric base: milliliter)
INSERT INTO units (id, name, abbreviation, unit_type, base_unit_id, conversion_factor, is_default, created_by) VALUES
  ('550e8400-e29b-41d4-a716-446655440010', 'Milliliter', 'mL', 'volume', NULL, 1.0, TRUE, NULL),
  ('550e8400-e29b-41d4-a716-446655440011', 'Liter', 'L', 'volume', '550e8400-e29b-41d4-a716-446655440010', 1000.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440012', 'Centiliter', 'cL', 'volume', '550e8400-e29b-41d4-a716-446655440010', 10.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440013', 'Deciliter', 'dL', 'volume', '550e8400-e29b-41d4-a716-446655440010', 100.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440014', 'Cup', 'cup', 'volume', '550e8400-e29b-41d4-a716-446655440010', 236.588, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440015', 'Tablespoon', 'tbsp', 'volume', '550e8400-e29b-41d4-a716-446655440010', 14.7868, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440016', 'Teaspoon', 'tsp', 'volume', '550e8400-e29b-41d4-a716-446655440010', 4.92892, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440017', 'Fluid Ounce', 'fl oz', 'volume', '550e8400-e29b-41d4-a716-446655440010', 29.5735, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440018', 'Gallon', 'gal', 'volume', '550e8400-e29b-41d4-a716-446655440010', 3785.41, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440019', 'Quart', 'qt', 'volume', '550e8400-e29b-41d4-a716-446655440010', 946.353, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440020', 'Pint', 'pt', 'volume', '550e8400-e29b-41d4-a716-446655440010', 473.176, FALSE, NULL);

-- Count units (no conversions, each is independent)
INSERT INTO units (id, name, abbreviation, unit_type, base_unit_id, conversion_factor, is_default, created_by) VALUES
  ('550e8400-e29b-41d4-a716-446655440030', 'Piece', 'pc', 'count', NULL, 1.0, TRUE, NULL),
  ('550e8400-e29b-41d4-a716-446655440031', 'Dozen', 'doz', 'count', '550e8400-e29b-41d4-a716-446655440030', 12.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440032', 'Package', 'pkg', 'count', NULL, 1.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440033', 'Bottle', 'btl', 'count', NULL, 1.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440034', 'Can', 'can', 'count', NULL, 1.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440035', 'Jar', 'jar', 'count', NULL, 1.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440036', 'Box', 'box', 'count', NULL, 1.0, FALSE, NULL),
  ('550e8400-e29b-41d4-a716-446655440037', 'Bag', 'bag', 'count', NULL, 1.0, FALSE, NULL);

COMMENT ON TABLE units IS 'Measurement units with 30 common presets covering metric, imperial, and count units';
