-- Sample seed data for the canonical MySQL schema.
-- Safe to run right after backend/database/schema.sql.


INSERT INTO `clients` (`id`, `name`, `email`, `phone`, `address`, `is_active`, `created_at`, `updated_at`) VALUES
  (1, 'Acme Corporation', 'contact@acme.com', '+1-555-0100', '123 Main St, New York, NY 10001', TRUE, '2026-01-10 09:00:00.000', '2026-01-10 09:00:00.000'),
  (2, 'TechStart Inc', 'info@techstart.com', '+1-555-0200', '456 Tech Ave, San Francisco, CA 94102', TRUE, '2026-01-10 09:05:00.000', '2026-01-10 09:05:00.000'),
  (3, 'Global Industries', 'hello@globalind.com', '+1-555-0300', '789 Business Blvd, Chicago, IL 60601', TRUE, '2026-01-10 09:10:00.000', '2026-01-10 09:10:00.000'),
  (4, 'Local Services', 'contact@localservices.com', '+1-555-0400', '321 Service Rd, Boston, MA 02101', TRUE, '2026-01-10 09:15:00.000', '2026-01-10 09:15:00.000'),
  (5, 'Enterprise Co', 'sales@enterprise.com', '+1-555-0500', '654 Enterprise Way, Austin, TX 78701', TRUE, '2026-01-10 09:20:00.000', '2026-01-10 09:20:00.000');

INSERT INTO `machinery` (`id`, `code`, `name`, `description`, `status`, `created_at`, `updated_at`) VALUES
  (1, 'CNC-001', 'CNC Milling Machine', '3-axis CNC mill for precision work', 'available', '2026-01-10 10:00:00.000', '2026-01-10 10:00:00.000'),
  (2, 'LATHE-001', 'Industrial Lathe', 'Heavy-duty lathe for large parts', 'available', '2026-01-10 10:05:00.000', '2026-01-10 10:05:00.000'),
  (3, 'WELD-001', 'MIG Welder', 'Industrial MIG welding equipment', 'available', '2026-01-10 10:10:00.000', '2026-01-10 10:10:00.000'),
  (4, 'DRILL-001', 'Drill Press', 'Floor-standing drill press', 'available', '2026-01-10 10:15:00.000', '2026-01-10 10:15:00.000'),
  (5, 'SAW-001', 'Band Saw', 'Metal cutting band saw', 'maintenance', '2026-01-10 10:20:00.000', '2026-01-10 10:20:00.000'),
  (6, 'GRIND-001', 'Surface Grinder', 'Precision surface grinder', 'available', '2026-01-10 10:25:00.000', '2026-01-10 10:25:00.000'),
  (7, 'PRESS-001', 'Hydraulic Press', '100-ton hydraulic press', 'available', '2026-01-10 10:30:00.000', '2026-01-10 10:30:00.000');

INSERT INTO `work_orders` (
  `id`,
  `order_number`,
  `quotation_number`,
  `title`,
  `description`,
  `performed_work`,
  `status`,
  `priority`,
  `start_date`,
  `end_date`,
  `client_id`,
  `created_by`,
  `created_at`,
  `updated_at`
) VALUES
  (1, '2026-0001', 'Q-2026-001', 'Custom Metal Fabrication', 'Fabricate custom metal brackets for construction project', NULL, 'pending', 'high', '2026-01-15 08:00:00.000', '2026-01-18 17:00:00.000', 1, 1, '2026-01-12 08:00:00.000', '2026-01-12 08:00:00.000'),
  (2, '2026-0002', 'Q-2026-002', 'CNC Machining Project', 'Machine precision parts for automotive application', 'CNC setup completed and first production run started.', 'in_progress', 'urgent', '2026-01-16 07:00:00.000', '2026-01-20 18:00:00.000', 2, 1, '2026-01-12 09:00:00.000', '2026-01-16 12:30:00.000'),
  (3, '2026-0003', 'Q-2026-003', 'Welding Assembly', 'Weld steel frame assembly', NULL, 'pending', 'medium', '2026-01-17 08:00:00.000', '2026-01-21 16:00:00.000', 3, 1, '2026-01-12 10:00:00.000', '2026-01-12 10:00:00.000');

INSERT INTO `work_order_details` (
  `id`,
  `work_order_id`,
  `description`,
  `quantity`,
  `operator_id`,
  `machinery_id`,
  `start_datetime`,
  `end_datetime`,
  `created_at`,
  `updated_at`
) VALUES
  (1, 1, 'Cut metal stock to size', 10.00, 2, 4, '2026-01-15 08:00:00.000', '2026-01-15 10:00:00.000', '2026-01-12 08:10:00.000', '2026-01-12 08:10:00.000'),
  (2, 1, 'Drill mounting holes', 10.00, 3, 4, '2026-01-15 10:30:00.000', '2026-01-15 12:00:00.000', '2026-01-12 08:20:00.000', '2026-01-12 08:20:00.000'),
  (3, 1, 'Finish and paint', 10.00, 2, 6, '2026-01-16 08:00:00.000', '2026-01-16 11:30:00.000', '2026-01-12 08:30:00.000', '2026-01-12 08:30:00.000'),
  (4, 2, 'CNC program setup', 1.00, 2, 1, '2026-01-16 07:00:00.000', '2026-01-16 08:00:00.000', '2026-01-12 09:10:00.000', '2026-01-12 09:10:00.000'),
  (5, 2, 'Machine first run', 50.00, 2, 1, '2026-01-16 08:30:00.000', '2026-01-16 16:00:00.000', '2026-01-12 09:20:00.000', '2026-01-16 12:30:00.000'),
  (6, 3, 'Prepare materials', 1.00, 3, 3, '2026-01-17 08:00:00.000', '2026-01-17 09:00:00.000', '2026-01-12 10:10:00.000', '2026-01-12 10:10:00.000'),
  (7, 3, 'Welding operations', 1.00, 3, 3, '2026-01-17 09:30:00.000', '2026-01-17 14:30:00.000', '2026-01-12 10:20:00.000', '2026-01-12 10:20:00.000');

INSERT INTO `work_order_operators` (`id`, `work_order_id`, `operator_id`, `assigned_at`) VALUES
  (1, 1, 2, '2026-01-12 08:05:00.000'),
  (2, 1, 3, '2026-01-12 08:05:00.000'),
  (3, 2, 2, '2026-01-12 09:05:00.000'),
  (4, 3, 3, '2026-01-12 10:05:00.000');

INSERT INTO `work_order_machinery` (`id`, `work_order_id`, `machinery_id`, `assigned_at`) VALUES
  (1, 1, 4, '2026-01-12 08:06:00.000'),
  (2, 1, 6, '2026-01-12 08:06:00.000'),
  (3, 2, 1, '2026-01-12 09:06:00.000'),
  (4, 3, 3, '2026-01-12 10:06:00.000');

INSERT INTO `order_history` (
  `id`,
  `work_order_id`,
  `changed_by`,
  `change_type`,
  `old_value`,
  `new_value`,
  `notes`,
  `created_at`
) VALUES
  (1, 1, 1, 'created', NULL, 'pending', 'Work order created from quotation Q-2026-001.', '2026-01-12 08:00:00.000'),
  (2, 2, 1, 'created', NULL, 'pending', 'Work order created from quotation Q-2026-002.', '2026-01-12 09:00:00.000'),
  (3, 2, 1, 'status_changed', 'pending', 'in_progress', 'Work started by operator team.', '2026-01-16 08:30:00.000'),
  (4, 2, 2, 'assigned', NULL, 'operator1', 'Operator assigned to work order.', '2026-01-12 09:05:00.000'),
  (5, 3, 1, 'created', NULL, 'pending', 'Work order created from quotation Q-2026-003.', '2026-01-12 10:00:00.000');
ALTER TABLE `clients` AUTO_INCREMENT = 6;
ALTER TABLE `machinery` AUTO_INCREMENT = 8;
ALTER TABLE `work_orders` AUTO_INCREMENT = 4;
ALTER TABLE `work_order_details` AUTO_INCREMENT = 8;
ALTER TABLE `work_order_operators` AUTO_INCREMENT = 5;
ALTER TABLE `work_order_machinery` AUTO_INCREMENT = 5;
ALTER TABLE `order_history` AUTO_INCREMENT = 6;
