SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";

CREATE TABLE `op_redirects` (
  `id` int NOT NULL,
  `source_url` varchar(255) NOT NULL,
  `ws_url` varchar(255) NOT NULL,
  `activity` varchar(20) NOT NULL DEFAULT 'forward',
  `reconnect_count` int NOT NULL DEFAULT 0,
  `last_connected` timestamp NULL DEFAULT NULL,
  `auth_key` varchar(255) DEFAULT NULL,
  `backend_basic_user` varchar(255) DEFAULT NULL,
  `backend_basic_password` varchar(255) DEFAULT NULL,
  `location_name` varchar(255) DEFAULT NULL,
  `location_link` varchar(512) DEFAULT NULL,
  `webui_remote_access_url` varchar(512) DEFAULT NULL,
  `load_management_remote_access_url` varchar(512) DEFAULT NULL,
  `measure_ping` tinyint(1) NOT NULL DEFAULT 0,
  `strict_availability` tinyint(1) NOT NULL DEFAULT 0,
  `charging_analytics` tinyint(1) NOT NULL DEFAULT 0,
  `disconnect_alert_enabled` tinyint(1) NOT NULL DEFAULT 0,
  `disconnect_alert_email` varchar(255) DEFAULT NULL,
  `mqtt_enabled` tinyint(1) NOT NULL DEFAULT 0,
  `tenant_id` int DEFAULT NULL,
  `ocpp_endpoint` varchar(25) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE `op_redirects`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_source` (`source_url`);

ALTER TABLE `op_redirects`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;
COMMIT;
