CREATE TABLE `leave_type_names` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

CREATE TABLE `leave_type_counts` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `leave_type_id` bigint(20) unsigned NOT NULL,
  `number_of_days` int(11) NOT NULL,
  `financialyear_id` bigint(20) unsigned NOT NULL,
  `is_applied` tinyint(1) NOT NULL DEFAULT 0,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `leave_type_counts_financialyear_id_foreign` (`financialyear_id`),
  KEY `leave_type_counts_leave_type_id_foreign` (`leave_type_id`),
  CONSTRAINT `leave_type_counts_financialyear_id_foreign` FOREIGN KEY (`financialyear_id`) REFERENCES `financialyears` (`id`),
  CONSTRAINT `leave_type_counts_leave_type_id_foreign` FOREIGN KEY (`leave_type_id`) REFERENCES `leave_type_names` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

CREATE TABLE `user_leave_type_counts` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `leave_type_count_id` bigint(20) unsigned NOT NULL,
  `financialyear_id` bigint(20) unsigned NOT NULL,
  `number_of_days` int(11) NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_leave_type_counts_user_id_foreign` (`user_id`),
  KEY `user_leave_type_counts_leave_type_count_id_foreign` (`leave_type_count_id`),
  KEY `user_leave_type_counts_financialyear_id_foreign` (`financialyear_id`),
  CONSTRAINT `user_leave_type_counts_financialyear_id_foreign` FOREIGN KEY (`financialyear_id`) REFERENCES `financialyears` (`id`),
  CONSTRAINT `user_leave_type_counts_leave_type_count_id_foreign` FOREIGN KEY (`leave_type_count_id`) REFERENCES `leave_type_counts` (`id`),
  CONSTRAINT `user_leave_type_counts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci