clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2042896 fiddles created (16639 in the last week).

CREATE TABLE users ( `id` int unsigned NOT NULL AUTO_INCREMENT, `name` VARCHAR(64), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 hidden batch(es)


CREATE TABLE `monitor_checks` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `monitor_id` int unsigned NOT NULL, `node_id` int unsigned NOT NULL, `url` varchar(2048) COLLATE utf8mb4_unicode_ci NOT NULL, `ip` int unsigned NOT NULL, `request_method` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `request_body` text COLLATE utf8mb4_unicode_ci, `request_headers` json DEFAULT NULL, `response_code` int DEFAULT NULL, `response_reason_phrase` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `response_size` int DEFAULT NULL, `response_headers` json DEFAULT NULL, `is_successful` tinyint(1) DEFAULT NULL, `is_failed` tinyint(1) DEFAULT NULL, `fail_reason` text COLLATE utf8mb4_unicode_ci, `response_time` double(8,6) DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `monitor_checks_monitor_id_node_id_response_time_index` (`monitor_id`,`node_id`,`response_time`), KEY `monitor_checks_node_id_foreign` (`node_id`) ) ENGINE=InnoDB /* AUTO_INCREMENT=3964257 */ DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 hidden batch(es)


CREATE TABLE `monitor_node` ( `monitor_id` int unsigned NOT NULL, `node_id` int unsigned NOT NULL, `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'unknown', `uptime` double(8,4) DEFAULT NULL, `average_response_time` double(8,2) DEFAULT NULL, `failed_attempts` int unsigned NOT NULL DEFAULT '0', `failed_checks` int unsigned NOT NULL DEFAULT '0', `total_checks` int unsigned NOT NULL DEFAULT '0', `went_offline_at` timestamp NULL DEFAULT NULL, `active` tinyint(1) NOT NULL DEFAULT '1', `latest_check_id` bigint unsigned DEFAULT NULL, UNIQUE KEY `monitor_node_monitor_id_node_id_unique` (`monitor_id`,`node_id`), KEY `monitor_node_node_id_foreign` (`node_id`), KEY `monitor_node_latest_check_id_foreign` (`latest_check_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 hidden batch(es)


CREATE TABLE `monitors` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `user_id` int unsigned NOT NULL, `latest_check_id` bigint unsigned DEFAULT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `url` varchar(2048) COLLATE utf8mb4_unicode_ci NOT NULL, `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'unknown', `ssl_certificate_state` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'unknown', `ip` int unsigned NOT NULL, `latitude` decimal(8,6) DEFAULT NULL, `longitude` decimal(9,6) DEFAULT NULL, `is_running` tinyint(1) NOT NULL DEFAULT '1', `request_method` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'get', `request_body_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `request_body` text COLLATE utf8mb4_unicode_ci, `request_json` json DEFAULT NULL, `request_form_params` json DEFAULT NULL, `request_headers` json DEFAULT NULL, `request_timeout` int DEFAULT '10', `response_body` text COLLATE utf8mb4_unicode_ci, `response_code` int DEFAULT NULL, `any_successful_response_code` tinyint(1) NOT NULL DEFAULT '1', `response_headers` json DEFAULT NULL, `uptime` double(8,4) DEFAULT NULL, `response_time` double(8,4) DEFAULT NULL, `checked_at` timestamp NULL DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `monitors_user_id_foreign` (`user_id`), KEY `monitors_latest_check_id_foreign` (`latest_check_id`) ) ENGINE=InnoDB /* AUTO_INCREMENT=1315 */ DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 hidden batch(es)


CREATE TABLE `nodes` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `ip` int unsigned NOT NULL, `location` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `latitude` decimal(8,6) NOT NULL, `longitude` decimal(9,6) NOT NULL, `queue` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `available` tinyint(1) NOT NULL DEFAULT '1', `flag` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB /* AUTO_INCREMENT=6 */ DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 hidden batch(es)


ALTER TABLE `monitor_checks` ADD CONSTRAINT `monitor_checks_monitor_id_foreign` FOREIGN KEY (`monitor_id`) REFERENCES `monitors` (`id`), ADD CONSTRAINT `monitor_checks_node_id_foreign` FOREIGN KEY (`node_id`) REFERENCES `nodes` (`id`);
 hidden batch(es)


ALTER TABLE `monitor_node` ADD CONSTRAINT `monitor_node_latest_check_id_foreign` FOREIGN KEY (`latest_check_id`) REFERENCES `monitor_checks` (`id`) ON DELETE SET NULL, ADD CONSTRAINT `monitor_node_monitor_id_foreign` FOREIGN KEY (`monitor_id`) REFERENCES `monitors` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `monitor_node_node_id_foreign` FOREIGN KEY (`node_id`) REFERENCES `nodes` (`id`) ON DELETE CASCADE;
 hidden batch(es)


ALTER TABLE `monitors` ADD CONSTRAINT `monitors_latest_check_id_foreign` FOREIGN KEY (`latest_check_id`) REFERENCES `monitor_checks` (`id`) ON DELETE SET NULL, ADD CONSTRAINT `monitors_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
 hidden batch(es)