-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `enterprise_app`
--

-- --------------------------------------------------------

--
-- Table structure for table `companies`
--

CREATE TABLE `companies` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `address` text NOT NULL,
  `telephone` varchar(20) NOT NULL,
  `email` varchar(100) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `companies`
--

INSERT INTO `companies` (`id`, `name`, `address`, `telephone`, `email`, `created_at`, `updated_at`) VALUES
(1, 'Company 01', 'Company 01 Address', '01514480388', 'info@compaaany.com', '2025-04-03 05:47:56', '2025-04-03 05:47:56'),
(2, 'Company 02', 'Company 02\r\nAddress', '0122111313313', 'co2@mail.com', '2025-04-04 13:00:07', '2025-04-04 13:00:07');

-- --------------------------------------------------------

--
-- Table structure for table `routes`
--

CREATE TABLE `routes` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `company_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `route_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`route_data`)),
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `routes`
--

INSERT INTO `routes` (`id`, `user_id`, `company_id`, `name`, `description`, `route_data`, `created_at`, `updated_at`) VALUES
(1, 12, 2, 'asdasdasd', 'asdasada', '{\"waypoints\":[{\"lat\":53.41470586631204,\"lng\":-2.9217355728979837,\"name\":\"Point 1\"},{\"lat\":53.49336659295982,\"lng\":-2.8207449803701223,\"name\":\"Point 2\"},{\"lat\":53.59725246137368,\"lng\":-2.6828539790339927,\"name\":\"Point 3\"},{\"lat\":53.67845171614216,\"lng\":-2.799381585796912,\"name\":\"Point 4\"},{\"lat\":53.619151335039476,\"lng\":-2.535252343800956,\"name\":\"Point 5\"},{\"lat\":53.432070023096884,\"lng\":-2.5255417099040494,\"name\":\"Point 6\"},{\"lat\":53.38690846243428,\"lng\":-2.6857671692030687,\"name\":\"Point 7\"},{\"lat\":53.56475308380163,\"lng\":-2.9299163818359375,\"name\":\"Point 8\"},{\"lat\":53.616933982579326,\"lng\":-2.8427124023437504,\"name\":\"Point 9\"}],\"total_distance\":66.12396523066936,\"distance_unit\":\"Nm\"}', '2025-04-04 13:55:28', '2025-04-04 13:55:28'),
(2, 12, 2, 'EGGP - Paintball - Poole - Dunkkeswell - Dartmouth', 'Dale Williams trip 06-04-2025', '{\"waypoints\":[{\"lat\":53.332895453972796,\"lng\":-2.847518920898438,\"name\":\"Point 1\"},{\"lat\":53.106335985987236,\"lng\":-2.9566955566406254,\"name\":\"Point 2\"},{\"lat\":50.79356713676963,\"lng\":-2.0973587036132817,\"name\":\"Point 3\"},{\"lat\":50.859951023173906,\"lng\":-3.2324758575990957,\"name\":\"Point 4\"},{\"lat\":50.35689838899046,\"lng\":-3.5467059013569173,\"name\":\"Point 5\"}],\"total_distance\":232.3330126121888,\"distance_unit\":\"Nm\"}', '2025-04-04 14:01:28', '2025-04-04 14:01:28');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `companies`
--
ALTER TABLE `companies`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `routes`
--
ALTER TABLE `routes`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `company_id` (`company_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `companies`
--
ALTER TABLE `companies`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `routes`
--
ALTER TABLE `routes`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `routes`
--
ALTER TABLE `routes`
  ADD CONSTRAINT `routes_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `routes_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`);
COMMIT;

