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

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

-- Database: `easyplex`

-- Alter settings table
ALTER TABLE settings
    MODIFY COLUMN autosubstitles TINYINT(1),
    MODIFY COLUMN livetv TINYINT(1),
    MODIFY COLUMN ads_player TINYINT(1),
    MODIFY COLUMN anime TINYINT(1),
    MODIFY COLUMN ad_interstitial TINYINT(1),
    MODIFY COLUMN ad_banner TINYINT(1),
    MODIFY COLUMN ad_face_audience_interstitial TINYINT(1),
    MODIFY COLUMN ad_face_audience_banner TINYINT(1),
    MODIFY COLUMN featured_home_numbers SMALLINT,
    MODIFY COLUMN enable_custom_message TINYINT(1),
    MODIFY COLUMN wach_ads_to_unlock TINYINT(1),
    MODIFY COLUMN aws_s3_storage TINYINT(1),
    MODIFY COLUMN wasabi_storage TINYINT(1),
    MODIFY COLUMN next_episode_timer SMALLINT,
    MODIFY COLUMN appodeal_banner TINYINT(1),
    MODIFY COLUMN appodeal_interstitial TINYINT(1),
    MODIFY COLUMN download_premuim_only TINYINT(1),
    MODIFY COLUMN ad_unit_id_native TINYINT(1),
    MODIFY COLUMN ad_unit_id_native_enable TINYINT(1),
    MODIFY COLUMN facebook_show_interstitial TINYINT(1),
    MODIFY COLUMN unityads_banner TINYINT(1),
    MODIFY COLUMN unityads_interstitial TINYINT(1),
    MODIFY COLUMN wach_ads_to_unlock_player TINYINT(1),
    MODIFY COLUMN enable_custom_banner TINYINT(1),
    MODIFY COLUMN mantenance_mode TINYINT(1),
    MODIFY COLUMN allow_adm TINYINT(1),
    MODIFY COLUMN enable_pinned TINYINT(1),
    MODIFY COLUMN startapp_banner TINYINT(1),
    MODIFY COLUMN startapp_interstitial TINYINT(1),
    MODIFY COLUMN enable_vlc TINYINT(1),
    MODIFY COLUMN resume_offline TINYINT(1),
    MODIFY COLUMN streaming TINYINT(1),
    MODIFY COLUMN enable_banner_bottom TINYINT(1),
    MODIFY COLUMN ad_face_audience_native TINYINT(1),
    MODIFY COLUMN enable_upcoming TINYINT(1),
    MODIFY COLUMN enable_download TINYINT(1),
    MODIFY COLUMN notification_separated TINYINT(1),
    MODIFY COLUMN email_verify TINYINT(1),
    MODIFY COLUMN force_login TINYINT(1),
    MODIFY COLUMN favoriteonline TINYINT(1),
    MODIFY COLUMN separate_download TINYINT(1),
    MODIFY COLUMN vpn TINYINT(1),
    MODIFY COLUMN notification_style TINYINT(1),
    MODIFY COLUMN force_update TINYINT(1),
    MODIFY COLUMN appnext_banner TINYINT(1),
    MODIFY COLUMN appnext_interstitial TINYINT(1),
    MODIFY COLUMN livetv_multi_servers TINYINT(1),
    MODIFY COLUMN suggest_auth TINYINT(1),
    MODIFY COLUMN networks TINYINT(1),
    MODIFY COLUMN enable_webview TINYINT(1),
    MODIFY COLUMN vungle_banner TINYINT(1),
    MODIFY COLUMN vungle_interstitial TINYINT(1),
    MODIFY COLUMN flag_secure TINYINT(1),
    MODIFY COLUMN ironsource_banner TINYINT(1),
    MODIFY COLUMN ironsource_interstitial TINYINT(1),
    MODIFY COLUMN root_detection TINYINT(1),
    MODIFY COLUMN applovin_banner TINYINT(1),
    MODIFY COLUMN applovin_interstitial TINYINT(1),
    MODIFY COLUMN force_password_access TINYINT(1),
    MODIFY COLUMN force_inappupdate TINYINT(1),
    MODIFY COLUMN enable_player_inter TINYINT(1),
    MODIFY COLUMN enable_comments TINYINT(1),
    MODIFY COLUMN applovin_native TINYINT(1),
    MODIFY COLUMN enable_shadows TINYINT(1),
    MODIFY COLUMN discover_style TINYINT(1),
    MODIFY COLUMN library_style TINYINT(1),
    MODIFY COLUMN phone_verification TINYINT(1),
    MODIFY COLUMN profile_selection TINYINT(1),
    MODIFY COLUMN trustAllCerts TINYINT(1),
    MODIFY COLUMN device_management TINYINT(1),
    MODIFY COLUMN internallangs TINYINT(1),
    MODIFY COLUMN searchhistory TINYINT(1),
    MODIFY COLUMN forcewatchbyauth TINYINT(1),
    MODIFY COLUMN safemode TINYINT(1),
    MODIFY COLUMN enable_watchinyourlang TINYINT(1),
    MODIFY COLUMN wortise_interstitial TINYINT(1),
    MODIFY COLUMN wortise_banner TINYINT(1),
    MODIFY COLUMN wortise_interstitial_show TINYINT(1),
    MODIFY COLUMN wortise_banner_enable TINYINT(1),
    MODIFY COLUMN enablelangsinservers TINYINT(1),
    MODIFY COLUMN enablesociallogins TINYINT(1),
    MODIFY COLUMN enabledynamicslider TINYINT(1),
    MODIFY COLUMN enablelayoutchange TINYINT(1),
    MODIFY COLUMN enablecustomcontent TINYINT(1),
    MODIFY COLUMN disablelogin TINYINT(1),
    MODIFY COLUMN vidsrc TINYINT(1),
    MODIFY COLUMN enable_collections TINYINT(1),
    ADD COLUMN `firebasejson` TEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    ADD COLUMN `googleapiurl` TEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    ADD COLUMN `m3uplaylistpath` TEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    ADD COLUMN `m3uplaylist` TINYINT(1) NOT NULL DEFAULT 0,
    ADD COLUMN `notification_counter` TINYINT(1) NOT NULL DEFAULT 0;


    ALTER TABLE livetvs
    ADD COLUMN `backdrop_path_tv` TEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL;

    
-- Create certifications table
DROP TABLE IF EXISTS `certifications`;
CREATE TABLE IF NOT EXISTS `certifications` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `country_code` varchar(191) DEFAULT NULL,
  `certification` varchar(191) DEFAULT NULL,
  `meaning` longtext,
  `order` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1851 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

-- Table structure for table `serie_certifications`
DROP TABLE IF EXISTS `serie_certifications`;
CREATE TABLE IF NOT EXISTS `serie_certifications` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `country_code` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `certification` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meaning` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `serie_id` bigint UNSIGNED NOT NULL,
  `certification_id` bigint UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `serie_certifications_serie_id_foreign` (`serie_id`),
  KEY `serie_certifications_certification_id_foreign` (`certification_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Table structure for table `movie_certifications`
DROP TABLE IF EXISTS `movie_certifications`;
CREATE TABLE IF NOT EXISTS `movie_certifications` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `country_code` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `certification` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meaning` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `movie_id` bigint UNSIGNED NOT NULL,
  `certification_id` bigint UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `movie_certifications_movie_id_foreign` (`movie_id`),
  KEY `movie_certifications_certification_id_foreign` (`certification_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Table structure for table `anime_certifications`
DROP TABLE IF EXISTS `anime_certifications`;
CREATE TABLE IF NOT EXISTS `anime_certifications` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `country_code` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `certification` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meaning` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `anime_id` bigint UNSIGNED NOT NULL,
  `certification_id` bigint UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `anime_certifications_anime_id_foreign` (`anime_id`),
  KEY `anime_certifications_certification_id_foreign` (`certification_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Constraints for table `serie_certifications`
ALTER TABLE `serie_certifications`
  ADD CONSTRAINT `serie_certifications_certification_id_foreign` FOREIGN KEY (`certification_id`) REFERENCES `certifications` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `serie_certifications_serie_id_foreign` FOREIGN KEY (`serie_id`) REFERENCES `series` (`id`) ON DELETE CASCADE;

-- Constraints for table `movie_certifications`
ALTER TABLE `movie_certifications`
  ADD CONSTRAINT `movie_certifications_certification_id_foreign` FOREIGN KEY (`certification_id`) REFERENCES `certifications` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `movie_certifications_movie_id_foreign` FOREIGN KEY (`movie_id`) REFERENCES `movies` (`id`) ON DELETE CASCADE;

-- Constraints for table `anime_certifications`
ALTER TABLE `anime_certifications`
  ADD CONSTRAINT `anime_certifications_anime_id_foreign` FOREIGN KEY (`anime_id`) REFERENCES `animes` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `anime_certifications_certification_id_foreign` FOREIGN KEY (`certification_id`) REFERENCES `certifications` (`id`) ON DELETE CASCADE;

COMMIT;




DROP TABLE IF EXISTS `serie_collections`;
CREATE TABLE IF NOT EXISTS `serie_collections` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(191) DEFAULT NULL,
  `serie_id` bigint UNSIGNED NOT NULL,
  `collection_id` bigint UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `serie_collections_serie_id_foreign` (`serie_id`),
  KEY `serie_collections_collection_id_foreign` (`collection_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `serie_collections`
--
ALTER TABLE `serie_collections`
  ADD CONSTRAINT `serie_collections_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collections` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `serie_collections_serie_id_foreign` FOREIGN KEY (`serie_id`) REFERENCES `series` (`id`) ON DELETE CASCADE;
COMMIT;


DROP TABLE IF EXISTS `anime_collections`;
CREATE TABLE IF NOT EXISTS `anime_collections` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(191) DEFAULT NULL,
  `anime_id` bigint UNSIGNED NOT NULL,
  `collection_id` bigint UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `anime_collections_anime_id_foreign` (`anime_id`),
  KEY `anime_collections_collection_id_foreign` (`collection_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `anime_collections`
--
ALTER TABLE `anime_collections`
  ADD CONSTRAINT `anime_collections_anime_id_foreign` FOREIGN KEY (`anime_id`) REFERENCES `animes` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `anime_collections_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collections` (`id`) ON DELETE CASCADE;
COMMIT;