From f1b1904e076573fca50b3b529a5994b71b142ad0 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 24 Oct 2017 21:25:29 -0400 Subject: [PATCH] Update DB Schema, Change Artist Slugs, Rework SubtitleFiles to LyricFiles --- frontend/src/Album/EpisodeStatus.js | 12 +- src/Lidarr.Api.V3/Artist/ArtistModule.cs | 1 - src/Lidarr.sln | 2 +- .../Scene/SceneMappingProxyFixture.cs | 33 -- .../Scene/SceneMappingServiceFixture.cs | 338 ---------------- .../Migration/070_delay_profileFixture.cs | 102 ----- .../071_unknown_quality_in_profileFixture.cs | 35 -- .../072_history_downloadIdFixture.cs | 106 ------ .../Migration/075_force_lib_updateFixture.cs | 108 ------ .../Migration/079_dedupe_tagsFixture.cs | 244 ------------ ..._prefix_to_transmission_categoryFixture.cs | 88 ----- .../084_update_quality_minmax_sizeFixture.cs | 96 ----- .../085_expand_transmission_urlbaseFixture.cs | 90 ----- .../086_pushbullet_device_idsFixture.cs | 89 ----- ...pushbullet_devices_channels_listFixture.cs | 40 -- .../090_update_kickass_urlFixture.cs | 64 ---- .../099_extra_and_subtitle_filesFixture.cs | 54 --- ..._add_ultrahd_quality_in_profilesFixture.cs | 35 -- ...103_fix_metadata_file_extensionsFixture.cs | 36 -- .../Migration/106_update_btn_urlFixture.cs | 62 --- ...108_fix_metadata_file_extensionsFixture.cs | 84 ---- .../109_import_extra_files_configFixture.cs | 54 --- .../110_fix_extra_files_configFixture.cs | 133 ------- .../PendingReleaseServiceFixture.cs | 2 +- .../Checks/IndexerStatusCheckFixture.cs | 4 +- .../CleanupOrphanedIndexerStatusFixture.cs | 6 +- .../NzbDrone.Core.Test.csproj | 21 +- .../Scene/ISceneMappingProvider.cs | 9 - .../DataAugmentation/Scene/SceneMapping.cs | 22 -- .../Scene/SceneMappingProxy.cs | 32 -- .../Scene/SceneMappingRepository.cs | 31 -- .../Scene/SceneMappingService.cs | 252 ------------ .../Scene/SceneMappingsUpdatedEvent.cs | 8 - .../Scene/ServicesProvider.cs | 19 - .../Scene/UpdateSceneMappingCommand.cs | 9 - .../Datastore/Migration/001_initial_setup.cs | 360 +++++++++++++----- ...02_remove_tvrage_imdb_unique_constraint.cs | 15 - ...3_remove_clean_title_from_scene_mapping.cs | 20 - .../Migration/004_updated_history.cs | 23 -- .../005_added_eventtype_to_history.cs | 17 - .../Migration/006_add_index_to_log_time.cs | 23 -- .../007_add_renameEpisodes_to_naming.cs | 19 - .../Datastore/Migration/008_remove_backlog.cs | 15 - .../Migration/009_fix_renameEpisodes.cs | 17 - .../Datastore/Migration/010_add_monitored.cs | 21 - .../Datastore/Migration/011_remove_ignored.cs | 15 - .../Migration/012_remove_custom_start_date.cs | 14 - .../Migration/013_add_air_date_utc.cs | 16 - .../Datastore/Migration/014_drop_air_date.cs | 14 - .../Migration/015_add_air_date_as_string.cs | 14 - .../016_updated_imported_history_item.cs | 14 - .../Migration/017_reset_scene_names.cs | 15 - .../Migration/018_remove_duplicates.cs | 99 ----- .../019_restore_unique_constraints.cs | 22 -- .../020_add_year_and_seasons_to_series.cs | 68 ---- .../Migration/021_drop_seasons_table.cs | 14 - .../022_move_indexer_to_generic_provider.cs | 14 - .../023_add_config_contract_to_indexers.cs | 19 - .../Migration/024_drop_tvdb_episodeid.cs | 14 - ...5_move_notification_to_generic_provider.cs | 14 - ...26_add_config_contract_to_notifications.cs | 24 -- .../Datastore/Migration/027_fix_omgwtfnzbs.cs | 24 -- .../Migration/028_add_blacklist_table.cs | 19 - .../029_add_formats_to_naming_config.cs | 154 -------- ...d_season_folder_format_to_naming_config.cs | 55 --- .../031_delete_old_naming_config_columns.cs | 20 - .../032_set_default_release_group.cs | 14 - .../Migration/033_add_api_key_to_pushover.cs | 66 ---- .../Migration/034_remove_series_contraints.cs | 16 - ...d_series_folder_format_to_naming_config.cs | 16 - .../036_update_with_quality_converters.cs | 129 ------- .../037_add_configurable_qualities.cs | 64 ---- .../038_add_on_upgrade_to_notifications.cs | 16 - .../Migration/039_add_metadata_tables.cs | 28 -- ...040_add_metadata_to_episodes_and_series.cs | 22 -- .../041_fix_xbmc_season_images_metadata.cs | 14 - .../042_add_download_clients_table.cs | 20 - .../043_convert_config_to_download_clients.cs | 197 ---------- .../044_fix_xbmc_episode_metadata.cs | 27 -- .../Datastore/Migration/045_add_indexes.cs | 26 -- .../Datastore/Migration/046_fix_nzb_su_url.cs | 16 - ...047_add_published_date_blacklist_column.cs | 14 - .../048_add_title_to_scenemappings.cs | 14 - .../Datastore/Migration/049_fix_dognzb_url.cs | 16 - .../050_add_hash_to_metadata_files.cs | 14 - .../Migration/051_download_client_import.cs | 243 ------------ .../Migration/052_add_columns_for_anime.cs | 20 - .../Migration/053_add_series_sorttitle.cs | 46 --- .../Migration/054_rename_profiles.cs | 31 -- .../Migration/055_drop_old_profile_columns.cs | 14 - .../056_add_mediainfo_to_episodefile.cs | 14 - ...7_convert_episode_file_path_to_relative.cs | 48 --- .../Migration/058_drop_epsiode_file_path.cs | 14 - .../059_add_enable_options_to_indexers.cs | 19 - .../060_remove_enable_from_indexers.cs | 15 - .../Migration/061_clear_bad_scene_names.cs | 22 -- .../Migration/062_convert_quality_models.cs | 83 ---- .../Migration/063_add_remotepathmappings.cs | 17 - .../064_add_remove_method_from_logs.cs | 14 - .../065_make_scene_numbering_nullable.cs | 16 - .../Datastore/Migration/066_add_tags.cs | 24 -- .../Migration/067_add_added_to_series.cs | 14 - .../Migration/068_add_release_restrictions.cs | 49 --- .../Datastore/Migration/069_quality_proper.cs | 99 ----- .../Datastore/Migration/070_delay_profile.cs | 182 --------- .../071_unknown_quality_in_profile.cs | 180 --------- .../Datastore/Migration/072_history_grabid.cs | 77 ---- .../Datastore/Migration/073_clear_ratings.cs | 20 - .../Datastore/Migration/074_disable_eztv.cs | 14 - .../Migration/075_force_lib_update.cs | 29 -- .../Migration/076_add_users_table.cs | 17 - .../077_add_add_options_to_series.cs | 14 - .../Migration/078_add_commands_table.cs | 24 -- .../Datastore/Migration/079_dedupe_tags.cs | 157 -------- ...ove_dot_prefix_to_transmission_category.cs | 92 ----- .../Migration/082_add_fanzub_settings.cs | 14 - .../083_additonal_blacklist_columns.cs | 22 -- .../084_update_quality_minmax_size.cs | 26 -- .../085_expand_transmission_urlbase.cs | 71 ---- .../Migration/086_pushbullet_device_ids.cs | 77 ---- .../Datastore/Migration/087_remove_eztv.cs | 14 - .../088_pushbullet_devices_channels_list.cs | 80 ---- .../089_add_on_rename_to_notifcations.cs | 21 - .../Migration/090_update_kickass_url.cs | 36 -- .../Migration/091_added_indexerstatus.cs | 20 - .../092_add_unverifiedscenenumbering.cs | 14 - .../093_naming_config_replace_characters.cs | 15 - .../Datastore/Migration/094_add_tvmazeid.cs | 15 - .../095_add_additional_episodes_index.cs | 16 - .../Migration/096_disable_kickass.cs | 14 - .../Migration/098_remove_titans_of_tv.cs | 14 - .../Migration/099_extra_and_subtitle_files.cs | 89 ----- .../Migration/100_add_scene_season_number.cs | 15 - .../101_add_ultrahd_quality_in_profiles.cs | 32 -- ...e_to_episodeFiles_history_and_blacklist.cs | 97 ----- .../103_fix_metadata_file_extensions.cs | 45 --- .../Datastore/Migration/104_remove_kickass.cs | 14 - .../105_rename_torrent_downloadstation.cs | 14 - .../Datastore/Migration/106_update_btn_url.cs | 22 -- .../Datastore/Migration/107_remove_wombles.cs | 14 - .../Migration/108_fix_extra_file_extension.cs | 56 --- .../Migration/109_import_extra_files.cs | 44 --- .../Migration/110_fix_extra_files_config.cs | 57 --- .../Migration/111_create_language_profiles.cs | 175 --------- .../Datastore/Migration/112_setup_music.cs | 108 ------ .../Datastore/Migration/113_music_history.cs | 36 -- .../Migration/114_music_blacklist.cs | 24 -- .../Migration/115_remove_tv_naming.cs | 27 -- .../116_change_drone_factory_variable_name.cs | 20 - .../Datastore/Migration/117_artist_links.cs | 20 - .../Migration/118_history_trackid.cs | 20 - .../Datastore/Migration/119_artist_type.cs | 21 - .../Migration/120_artist_album_types.cs | 21 - .../121_update_types_existing_artist.cs | 14 - .../122_consolidate_indexer_baseurl.cs | 58 --- .../Datastore/Migration/123_music_extras.cs | 44 --- .../Framework/NzbDroneSqliteProcessor.cs | 52 ++- src/NzbDrone.Core/Datastore/TableMapping.cs | 7 +- .../Download/Pending/PendingReleaseService.cs | 2 +- .../ExistingLyricImporter.cs} | 28 +- .../Extras/Lyrics/ImportedLyricFiles.cs | 17 + .../SubtitleFile.cs => Lyrics/LyricFile.cs} | 4 +- .../Extras/Lyrics/LyricFileExtensions.cs | 23 ++ .../Extras/Lyrics/LyricFileRepository.cs | 18 + .../Extras/Lyrics/LyricFileService.cs | 20 + .../LyricService.cs} | 30 +- .../Metadata/ExistingMetadataImporter.cs | 4 +- .../Extras/Subtitles/ImportedSubtitleFiles.cs | 17 - .../Subtitles/SubtitleFileExtensions.cs | 32 -- .../Subtitles/SubtitleFileRepository.cs | 18 - .../Extras/Subtitles/SubtitleFileService.cs | 20 - .../HealthCheck/Checks/IndexerStatusCheck.cs | 2 +- .../IndexerSearch/NzbSearchService.cs | 1 - src/NzbDrone.Core/Indexers/IndexerFactory.cs | 2 +- src/NzbDrone.Core/Indexers/IndexerStatus.cs | 2 +- .../Indexers/IndexerStatusRepository.cs | 2 +- .../Indexers/IndexerStatusService.cs | 2 +- src/NzbDrone.Core/Jobs/TaskManager.cs | 1 - .../MetadataSource/SkyHook/SkyHookProxy.cs | 2 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 144 +------ src/NzbDrone.Core/Parser/ParsingService.cs | 3 +- 181 files changed, 455 insertions(+), 7404 deletions(-) delete mode 100644 src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs delete mode 100644 src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/070_delay_profileFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/071_unknown_quality_in_profileFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/072_history_downloadIdFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/079_dedupe_tagsFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/081_move_dot_prefix_to_transmission_categoryFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/084_update_quality_minmax_sizeFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/085_expand_transmission_urlbaseFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/086_pushbullet_device_idsFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/088_pushbullet_devices_channels_listFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/099_extra_and_subtitle_filesFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/101_add_ultrahd_quality_in_profilesFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/103_fix_metadata_file_extensionsFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/106_update_btn_urlFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/108_fix_metadata_file_extensionsFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/109_import_extra_files_configFixture.cs delete mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/110_fix_extra_files_configFixture.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/002_remove_tvrage_imdb_unique_constraint.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/003_remove_clean_title_from_scene_mapping.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/004_updated_history.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/006_add_index_to_log_time.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/008_remove_backlog.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/009_fix_renameEpisodes.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/010_add_monitored.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/012_remove_custom_start_date.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/014_drop_air_date.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/015_add_air_date_as_string.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/017_reset_scene_names.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/018_remove_duplicates.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/019_restore_unique_constraints.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/020_add_year_and_seasons_to_series.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/021_drop_seasons_table.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/022_move_indexer_to_generic_provider.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/023_add_config_contract_to_indexers.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/024_drop_tvdb_episodeid.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/025_move_notification_to_generic_provider.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/026_add_config_contract_to_notifications.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/027_fix_omgwtfnzbs.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/028_add_blacklist_table.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/029_add_formats_to_naming_config.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/030_add_season_folder_format_to_naming_config.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/031_delete_old_naming_config_columns.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/032_set_default_release_group.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/033_add_api_key_to_pushover.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/034_remove_series_contraints.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/035_add_series_folder_format_to_naming_config.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/038_add_on_upgrade_to_notifications.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/039_add_metadata_tables.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/040_add_metadata_to_episodes_and_series.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/041_fix_xbmc_season_images_metadata.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/042_add_download_clients_table.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/043_convert_config_to_download_clients.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/044_fix_xbmc_episode_metadata.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/045_add_indexes.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/046_fix_nzb_su_url.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/047_add_published_date_blacklist_column.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/048_add_title_to_scenemappings.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/049_fix_dognzb_url.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/050_add_hash_to_metadata_files.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/052_add_columns_for_anime.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/053_add_series_sorttitle.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/054_rename_profiles.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/055_drop_old_profile_columns.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/056_add_mediainfo_to_episodefile.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/057_convert_episode_file_path_to_relative.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/058_drop_epsiode_file_path.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/059_add_enable_options_to_indexers.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/060_remove_enable_from_indexers.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/061_clear_bad_scene_names.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/062_convert_quality_models.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/063_add_remotepathmappings.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/064_add_remove_method_from_logs.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/065_make_scene_numbering_nullable.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/066_add_tags.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/067_add_added_to_series.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/068_add_release_restrictions.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/069_quality_proper.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/070_delay_profile.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/071_unknown_quality_in_profile.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/072_history_grabid.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/073_clear_ratings.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/075_force_lib_update.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/076_add_users_table.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/077_add_add_options_to_series.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/078_add_commands_table.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/079_dedupe_tags.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/081_move_dot_prefix_to_transmission_category.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/082_add_fanzub_settings.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/083_additonal_blacklist_columns.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/084_update_quality_minmax_size.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/085_expand_transmission_urlbase.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/086_pushbullet_device_ids.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/087_remove_eztv.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/088_pushbullet_devices_channels_list.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/089_add_on_rename_to_notifcations.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/091_added_indexerstatus.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/092_add_unverifiedscenenumbering.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/093_naming_config_replace_characters.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/095_add_additional_episodes_index.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/096_disable_kickass.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/098_remove_titans_of_tv.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/099_extra_and_subtitle_files.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/100_add_scene_season_number.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/101_add_ultrahd_quality_in_profiles.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/102_add_language_to_episodeFiles_history_and_blacklist.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/103_fix_metadata_file_extensions.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/104_remove_kickass.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/105_rename_torrent_downloadstation.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/106_update_btn_url.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/107_remove_wombles.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/108_fix_extra_file_extension.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/109_import_extra_files.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/110_fix_extra_files_config.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/111_create_language_profiles.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/112_setup_music.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/113_music_history.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/114_music_blacklist.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/115_remove_tv_naming.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/116_change_drone_factory_variable_name.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/117_artist_links.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/118_history_trackid.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/119_artist_type.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/120_artist_album_types.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/121_update_types_existing_artist.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/122_consolidate_indexer_baseurl.cs delete mode 100644 src/NzbDrone.Core/Datastore/Migration/123_music_extras.cs rename src/NzbDrone.Core/Extras/{Subtitles/ExistingSubtitleImporter.cs => Lyrics/ExistingLyricImporter.cs} (71%) create mode 100644 src/NzbDrone.Core/Extras/Lyrics/ImportedLyricFiles.cs rename src/NzbDrone.Core/Extras/{Subtitles/SubtitleFile.cs => Lyrics/LyricFile.cs} (60%) create mode 100644 src/NzbDrone.Core/Extras/Lyrics/LyricFileExtensions.cs create mode 100644 src/NzbDrone.Core/Extras/Lyrics/LyricFileRepository.cs create mode 100644 src/NzbDrone.Core/Extras/Lyrics/LyricFileService.cs rename src/NzbDrone.Core/Extras/{Subtitles/SubtitleService.cs => Lyrics/LyricService.cs} (76%) delete mode 100644 src/NzbDrone.Core/Extras/Subtitles/ImportedSubtitleFiles.cs delete mode 100644 src/NzbDrone.Core/Extras/Subtitles/SubtitleFileExtensions.cs delete mode 100644 src/NzbDrone.Core/Extras/Subtitles/SubtitleFileRepository.cs delete mode 100644 src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs diff --git a/frontend/src/Album/EpisodeStatus.js b/frontend/src/Album/EpisodeStatus.js index f605c942a..9cdbd1923 100644 --- a/frontend/src/Album/EpisodeStatus.js +++ b/frontend/src/Album/EpisodeStatus.js @@ -35,7 +35,7 @@ function EpisodeStatus(props) { {...queueItem} progressBar={ ); @@ -67,7 +67,7 @@ function EpisodeStatus(props) { quality={quality} size={trackFile.size} isCutoffNotMet={isCutoffNotMet} - title="Episode Downloaded" + title="Track Downloaded" /> ); @@ -89,7 +89,7 @@ function EpisodeStatus(props) {
); @@ -100,7 +100,7 @@ function EpisodeStatus(props) {
); @@ -110,7 +110,7 @@ function EpisodeStatus(props) {
); diff --git a/src/Lidarr.Api.V3/Artist/ArtistModule.cs b/src/Lidarr.Api.V3/Artist/ArtistModule.cs index 175306972..0ead0137c 100644 --- a/src/Lidarr.Api.V3/Artist/ArtistModule.cs +++ b/src/Lidarr.Api.V3/Artist/ArtistModule.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using FluentValidation; using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; diff --git a/src/Lidarr.sln b/src/Lidarr.sln index fa172505c..fc5dfaa83 100644 --- a/src/Lidarr.sln +++ b/src/Lidarr.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.10 +VisualStudioVersion = 15.0.27004.2002 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{57A04B72-8088-4F75-A582-1158CF8291F7}" EndProject diff --git a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs deleted file mode 100644 index ce59cf37c..000000000 --- a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs +++ /dev/null @@ -1,33 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common.Categories; - -namespace NzbDrone.Core.Test.DataAugmentation.Scene -{ - [TestFixture] - [IntegrationTest] - public class SceneMappingProxyFixture : CoreTest - { - [SetUp] - public void Setup() - { - UseRealHttp(); - } - - [Test] - public void fetch_should_return_list_of_mappings() - { - var mappings = Subject.Fetch(); - - mappings.Should().NotBeEmpty(); - - mappings.Should().NotContain(c => c.SearchTerm.IsNullOrWhiteSpace()); - mappings.Should().NotContain(c => c.Title.IsNullOrWhiteSpace()); - mappings.Should().Contain(c => c.SeasonNumber > 0); - } - - } -} diff --git a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs deleted file mode 100644 index 7953de12d..000000000 --- a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs +++ /dev/null @@ -1,338 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Net; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.DataAugmentation.Scene; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common; -using FluentAssertions; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation; - -namespace NzbDrone.Core.Test.DataAugmentation.Scene -{ - [TestFixture] - - public class SceneMappingServiceFixture : CoreTest - { - private List _fakeMappings; - - private Mock _provider1; - private Mock _provider2; - - [SetUp] - public void Setup() - { - _fakeMappings = Builder.CreateListOfSize(5).BuildListOfNew(); - - _fakeMappings[0].SearchTerm = "Words"; - _fakeMappings[1].SearchTerm = "That"; - _fakeMappings[2].SearchTerm = "Can"; - _fakeMappings[3].SearchTerm = "Be"; - _fakeMappings[4].SearchTerm = "Cleaned"; - - _fakeMappings[0].ParseTerm = "Words"; - _fakeMappings[1].ParseTerm = "That"; - _fakeMappings[2].ParseTerm = "Can"; - _fakeMappings[3].ParseTerm = "Be"; - _fakeMappings[4].ParseTerm = "Cleaned"; - - _provider1 = new Mock(); - _provider1.Setup(s => s.GetSceneMappings()).Returns(_fakeMappings); - - _provider2 = new Mock(); - _provider2.Setup(s => s.GetSceneMappings()).Returns(_fakeMappings); - } - - private void GivenProviders(IEnumerable> providers) - { - Mocker.SetConstant>(providers.Select(s => s.Object)); - } - - [Test] - public void should_purge_existing_mapping_and_add_new_ones() - { - GivenProviders(new [] { _provider1 }); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - AssertMappingUpdated(); - } - - [Test] - public void should_not_delete_if_fetch_fails() - { - GivenProviders(new[] { _provider1 }); - - _provider1.Setup(c => c.GetSceneMappings()).Throws(new WebException()); - - Subject.Execute(new UpdateSceneMappingCommand()); - - AssertNoUpdate(); - - ExceptionVerification.ExpectedErrors(1); - } - - [Test] - public void should_not_delete_if_fetch_returns_empty_list() - { - GivenProviders(new[] { _provider1 }); - - _provider1.Setup(c => c.GetSceneMappings()).Returns(new List()); - - Subject.Execute(new UpdateSceneMappingCommand()); - - AssertNoUpdate(); - - ExceptionVerification.ExpectedWarns(1); - } - - [Test] - public void should_get_mappings_for_all_providers() - { - GivenProviders(new[] { _provider1, _provider2 }); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - _provider1.Verify(c => c.GetSceneMappings(), Times.Once()); - _provider2.Verify(c => c.GetSceneMappings(), Times.Once()); - } - - [Test] - public void should_refresh_cache_if_cache_is_empty_when_looking_for_tvdb_id() - { - Subject.FindTvdbId("title"); - - Mocker.GetMock() - .Verify(v => v.All(), Times.Once()); - } - - [Test] - public void should_not_refresh_cache_if_cache_is_not_empty_when_looking_for_tvdb_id() - { - GivenProviders(new[] { _provider1 }); - - Mocker.GetMock() - .Setup(s => s.All()) - .Returns(Builder.CreateListOfSize(1).Build()); - - - Subject.Execute(new UpdateSceneMappingCommand()); - - Mocker.GetMock() - .Verify(v => v.All(), Times.Once()); - - Subject.FindTvdbId("title"); - - Mocker.GetMock() - .Verify(v => v.All(), Times.Once()); - } - - [Test] - public void should_not_add_mapping_with_blank_title() - { - GivenProviders(new[] { _provider1 }); - - var fakeMappings = Builder.CreateListOfSize(2) - .TheLast(1) - .With(m => m.Title = null) - .Build() - .ToList(); - - _provider1.Setup(s => s.GetSceneMappings()).Returns(fakeMappings); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - Mocker.GetMock().Verify(c => c.InsertMany(It.Is>(m => !m.Any(s => s.Title.IsNullOrWhiteSpace()))), Times.Once()); - ExceptionVerification.ExpectedWarns(1); - } - - [Test] - public void should_not_add_mapping_with_blank_search_title() - { - GivenProviders(new[] { _provider1 }); - - var fakeMappings = Builder.CreateListOfSize(2) - .TheLast(1) - .With(m => m.SearchTerm = null) - .Build() - .ToList(); - - _provider1.Setup(s => s.GetSceneMappings()).Returns(fakeMappings); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - Mocker.GetMock().Verify(c => c.InsertMany(It.Is>(m => !m.Any(s => s. SearchTerm.IsNullOrWhiteSpace()))), Times.Once()); - ExceptionVerification.ExpectedWarns(1); - } - - - [TestCase("Working!!", "Working!!", 1)] - [TestCase("Working`!!", "Working`!!", 2)] - [TestCase("Working!!!", "Working!!!", 3)] - [TestCase("Working!!!!", "Working!!!", 3)] - [TestCase("Working !!", "Working!!", 1)] - public void should_return_single_match(string parseTitle, string title, int expectedSeasonNumber) - { - var mappings = new List - { - new SceneMapping { Title = "Working!!", ParseTerm = "working", SearchTerm = "Working!!", TvdbId = 100, SceneSeasonNumber = 1 }, - new SceneMapping { Title = "Working`!!", ParseTerm = "working", SearchTerm = "Working`!!", TvdbId = 100, SceneSeasonNumber = 2 }, - new SceneMapping { Title = "Working!!!", ParseTerm = "working", SearchTerm = "Working!!!", TvdbId = 100, SceneSeasonNumber = 3 }, - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var tvdbId = Subject.FindTvdbId(parseTitle); - var seasonNumber = Subject.GetSceneSeasonNumber(parseTitle); - - tvdbId.Should().Be(100); - seasonNumber.Should().Be(expectedSeasonNumber); - } - - [Test] - public void should_return_alternate_title_for_global_season() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 1", ParseTerm = "fudanshikoukouseikatsu1", SearchTerm = "Fudanshi Koukou Seikatsu 1", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = null }, - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 2", ParseTerm = "fudanshikoukouseikatsu2", SearchTerm = "Fudanshi Koukou Seikatsu 2", TvdbId = 100, SeasonNumber = -1, SceneSeasonNumber = null }, - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 3", ParseTerm = "fudanshikoukouseikatsu3", SearchTerm = "Fudanshi Koukou Seikatsu 3", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = -1 }, - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 4", ParseTerm = "fudanshikoukouseikatsu4", SearchTerm = "Fudanshi Koukou Seikatsu 4", TvdbId = 100, SeasonNumber = -1, SceneSeasonNumber = -1 }, - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 10 }, new List { 10 }); - names.Should().HaveCount(4); - } - - [Test] - public void should_return_alternate_title_for_season() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = 1, SceneSeasonNumber = null } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 1 }, new List { 10 }); - names.Should().HaveCount(1); - } - - [Test] - public void should_not_return_alternate_title_for_season() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = 1, SceneSeasonNumber = null } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 2 }, new List { 10 }); - names.Should().BeEmpty(); - } - - [Test] - public void should_return_alternate_title_for_sceneseason() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 10 }, new List { 1 }); - names.Should().HaveCount(1); - } - - [Test] - public void should_not_return_alternate_title_for_sceneseason() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 10 }, new List { 2 }); - names.Should().BeEmpty(); - } - - [Test] - public void should_return_alternate_title_for_fairy_tail() - { - var mappings = new List - { - new SceneMapping { Title = "Fairy Tail S2", ParseTerm = "fairytails2", SearchTerm = "Fairy Tail S2", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 2 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - Subject.GetSceneNames(100, new List { 4 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 5 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 6 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 7 }, new List { 20 }).Should().BeEmpty(); - - Subject.GetSceneNames(100, new List { 20 }, new List { 1 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 20 }, new List { 2 }).Should().NotBeEmpty(); - Subject.GetSceneNames(100, new List { 20 }, new List { 3 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 20 }, new List { 4 }).Should().BeEmpty(); - } - - [Test] - public void should_return_alternate_title_for_fudanshi() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - Subject.GetSceneNames(100, new List { 1 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 2 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 3 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 4 }, new List { 20 }).Should().BeEmpty(); - - Subject.GetSceneNames(100, new List { 1 }, new List { 1 }).Should().NotBeEmpty(); - Subject.GetSceneNames(100, new List { 2 }, new List { 2 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 3 }, new List { 3 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 4 }, new List { 4 }).Should().BeEmpty(); - } - - private void AssertNoUpdate() - { - _provider1.Verify(c => c.GetSceneMappings(), Times.Once()); - Mocker.GetMock().Verify(c => c.Clear(It.IsAny()), Times.Never()); - Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Never()); - } - - private void AssertMappingUpdated() - { - _provider1.Verify(c => c.GetSceneMappings(), Times.Once()); - Mocker.GetMock().Verify(c => c.Clear(It.IsAny()), Times.Once()); - Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Once()); - - foreach (var sceneMapping in _fakeMappings) - { - Subject.GetSceneNames(sceneMapping.TvdbId, _fakeMappings.Select(m => m.SeasonNumber.Value).Distinct().ToList(), new List()).Should().Contain(sceneMapping.SearchTerm); - Subject.FindTvdbId(sceneMapping.ParseTerm).Should().Be(sceneMapping.TvdbId); - } - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/070_delay_profileFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/070_delay_profileFixture.cs deleted file mode 100644 index be2b07b66..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/070_delay_profileFixture.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class delay_profileFixture : MigrationTest - { - [Test] - public void should_migrate_old_delays() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 1, - Name = "OneHour", - Cutoff = 0, - Items = "[]" - }); - - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 2, - Name = "TwoHours", - Cutoff = "{}", - Items = "[]" - }); - }); - - var allProfiles = db.Query("SELECT * FROM DelayProfiles"); - - allProfiles.Should().HaveCount(3); - allProfiles.Should().OnlyContain(c => c.PreferredProtocol == 1); - allProfiles.Should().OnlyContain(c => c.TorrentDelay == 0); - allProfiles.Should().Contain(c => c.UsenetDelay == 60); - allProfiles.Should().Contain(c => c.UsenetDelay == 120); - } - - [Test] - public void should_create_tag_for_delay_profile() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 1, - Name = "OneHour", - Cutoff = 0, - Items = "[]" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - - tags.Should().HaveCount(1); - tags.First().Label.Should().Be("delay-60"); - } - - [Test] - public void should_add_tag_to_series_that_had_a_profile_with_delay_attached() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 1, - Name = "OneHour", - Cutoff = 0, - Items = "[]" - }); - - c.Insert.IntoTable("Series").Row(new - { - TvdbId = 0, - TvRageId = 0, - Title = "Series", - TitleSlug = "series", - CleanTitle = "series", - Status = 0, - Images = "[]", - Path = @"C:\Test\Series", - Monitored = 1, - SeasonFolder = 1, - RunTime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - Tags = "[1]" - }); - }); - - var tag = db.Query("SELECT Id, Label FROM Tags").Single(); - var series = db.Query("SELECT Tags FROM Series"); - - series.Should().HaveCount(1); - series.First().Tags.Should().BeEquivalentTo(tag.Id); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/071_unknown_quality_in_profileFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/071_unknown_quality_in_profileFixture.cs deleted file mode 100644 index ad31df44c..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/071_unknown_quality_in_profileFixture.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class unknown_quality_in_profileFixture : MigrationTest - { - [Test] - public void should_add_unknown_to_old_profile() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - Id = 0, - Name = "SDTV", - Cutoff = 1, - Items = "[ { \"quality\": 1, \"allowed\": true } ]", - Language = 1 - }); - }); - - var profiles = db.Query("SELECT Items FROM Profiles LIMIT 1"); - - var items = profiles.First().Items; - items.Should().HaveCount(2); - items.First().Quality.Should().Be(0); - items.First().Allowed.Should().Be(false); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/072_history_downloadIdFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/072_history_downloadIdFixture.cs deleted file mode 100644 index c976f9b10..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/072_history_downloadIdFixture.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; -using FluentMigrator; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class history_downloadIdFixture : MigrationTest - { - [Test] - public void should_move_grab_id_from_date_to_columns() - { - var db = WithMigrationTestDb(c => - { - InsertHistory(c, new Dictionary - { - {"indexer","test"}, - {"downloadClientId","123"} - }); - - InsertHistory(c, new Dictionary - { - {"indexer","test"}, - {"downloadClientId","abc"} - }); - - }); - - var history = db.Query("SELECT DownloadId, Data FROM History"); - - history.Should().HaveCount(2); - history.Should().NotContain(c => c.Data.ContainsKey("downloadClientId")); - history.Should().Contain(c => c.DownloadId == "123"); - history.Should().Contain(c => c.DownloadId == "abc"); - } - - - [Test] - public void should_leave_items_with_no_grabid() - { - var db = WithMigrationTestDb(c => - { - InsertHistory(c, new Dictionary - { - {"indexer","test"}, - {"downloadClientId","123"} - }); - - InsertHistory(c, new Dictionary - { - {"indexer","test"} - }); - - }); - - var history = db.Query("SELECT DownloadId, Data FROM History"); - - history.Should().HaveCount(2); - history.Should().NotContain(c => c.Data.ContainsKey("downloadClientId")); - history.Should().Contain(c => c.DownloadId == "123"); - history.Should().Contain(c => c.DownloadId == null); - } - - [Test] - public void should_leave_other_data() - { - var db = WithMigrationTestDb(c => - { - InsertHistory(c, new Dictionary - { - {"indexer","test"}, - {"group","test2"}, - {"downloadClientId","123"} - }); - }); - - var history = db.Query("SELECT DownloadId, Data FROM History").Single(); - - history.Data.Should().NotContainKey("downloadClientId"); - history.Data.Should().Contain(new KeyValuePair("indexer", "test")); - history.Data.Should().Contain(new KeyValuePair("group", "test2")); - - history.DownloadId.Should().Be("123"); - } - - private void InsertHistory(MigrationBase migrationBase, Dictionary data) - { - migrationBase.Insert.IntoTable("History").Row(new - { - EpisodeId = 1, - SeriesId = 1, - SourceTitle = "Test", - Date = DateTime.Now, - Quality = "{}", - Data = data.ToJson(), - EventType = 1 - }); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs deleted file mode 100644 index 729c692b8..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Datastore.Migration; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class force_lib_updateFixture : MigrationTest - { - [Test] - public void should_not_fail_on_empty_db() - { - var db = WithMigrationTestDb(); - - db.Query("SELECT * FROM ScheduledTasks").Should().BeEmpty(); - db.Query("SELECT * FROM Series").Should().BeEmpty(); - } - - - [Test] - public void should_reset_job_last_execution_time() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("ScheduledTasks").Row(new - { - TypeName = "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand", - Interval = 10, - LastExecution = "2000-01-01 00:00:00" - }); - - c.Insert.IntoTable("ScheduledTasks").Row(new - { - TypeName = "NzbDrone.Core.Backup.BackupCommand", - Interval = 10, - LastExecution = "2000-01-01 00:00:00" - }); - }); - - var jobs = db.Query("SELECT TypeName, LastExecution FROM ScheduledTasks"); - - jobs.Single(c => c.TypeName == "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand") - .LastExecution.Year.Should() - .Be(2014); - - jobs.Single(c => c.TypeName == "NzbDrone.Core.Backup.BackupCommand") - .LastExecution.Year.Should() - .Be(2000); - } - - [Test] - public void should_reset_series_last_sync_time() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - - { - Name = "Profile1", - CutOff = 0, - Items = "[]", - Language = 1 - }); - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - ProfileId = 1 - }); - - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 2, - TvRageId = 2, - Title = "Title2", - CleanTitle = "CleanTitle2", - Status = 1, - Images = "", - Path = "c:\\test2", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - ProfileId = 1 - }); - }); - - var series = db.Query("SELECT LastInfoSync FROM Series"); - - series.Should().OnlyContain(c => c.LastInfoSync.Value.Year == 2014); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/079_dedupe_tagsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/079_dedupe_tagsFixture.cs deleted file mode 100644 index ea8dcc013..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/079_dedupe_tagsFixture.cs +++ /dev/null @@ -1,244 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class dedupe_tagsFixture : MigrationTest - { - [Test] - public void should_not_fail_if_series_tags_are_null() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - - { - Name = "Profile1", - CutOff = 0, - Items = "[]", - Language = 1 - }); - - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - ProfileId = 1 - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - tags.Should().HaveCount(1); - } - - [Test] - public void should_not_fail_if_series_tags_are_empty() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - - { - Name = "Profile1", - CutOff = 0, - Items = "[]", - Language = 1 - }); - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[]", - ProfileId = 1 - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - tags.Should().HaveCount(1); - } - - [Test] - public void should_remove_duplicate_labels_from_tags() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - tags.Should().HaveCount(1); - } - - [Test] - public void should_not_allow_duplicate_tag_to_be_inserted() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - Assert.That(() => db.Query("INSERT INTO Tags (Label) VALUES ('test')"), Throws.Exception); - } - - [Test] - public void should_replace_duplicated_tag_with_proper_tag() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - - { - Name = "Profile1", - CutOff = 0, - Items = "[]", - Language = 1 - }); - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[2]", - ProfileId = 1 - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var series = db.Query("SELECT Tags FROM Series WHERE Id = 1").Single(); - series.Tags.First().Should().Be(1); - } - - [Test] - public void should_only_update_affected_series() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - - { - Name = "Profile1", - CutOff = 0, - Items = "[]", - Language = 1 - }); - - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[2]", - ProfileId = 1 - }); - - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 2, - TvRageId = 2, - Title = "Title2", - CleanTitle = "CleanTitle2", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[]", - ProfileId = 1 - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var series = db.Query("SELECT Tags FROM Series WHERE Id = 2").Single(); - series.Tags.Should().BeEmpty(); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/081_move_dot_prefix_to_transmission_categoryFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/081_move_dot_prefix_to_transmission_categoryFixture.cs deleted file mode 100644 index 7aae7010e..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/081_move_dot_prefix_to_transmission_categoryFixture.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Datastore.Migration; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class move_dot_prefix_to_transmission_categoryFixture : MigrationTest - { - [Test] - public void should_not_fail_if_no_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Sab", - Implementation = "Sabnzbd", - Settings = new - { - Host = "127.0.0.1", - TvCategory = "abc" - }.ToJson(), - ConfigContract = "SabnzbdSettings" - }); - }); - - var downloadClients = db.Query("SELECT Settings FROM DownloadClients"); - - downloadClients.Should().HaveCount(1); - downloadClients.First().Settings.ToObject().TvCategory.Should().Be("abc"); - } - - [Test] - public void should_be_updated_for_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new - { - Host = "127.0.0.1", - TvCategory = "abc" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var downloadClients = db.Query("SELECT Settings FROM DownloadClients"); - - downloadClients.Should().HaveCount(1); - downloadClients.First().Settings.ToObject().TvCategory.Should().Be(".abc"); - } - - [Test] - public void should_leave_empty_category_untouched() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new - { - Host = "127.0.0.1", - TvCategory = "" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var downloadClients = db.Query("SELECT Settings FROM DownloadClients"); - - downloadClients.Should().HaveCount(1); - downloadClients.First().Settings.ToObject().TvCategory.Should().Be(""); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/084_update_quality_minmax_sizeFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/084_update_quality_minmax_sizeFixture.cs deleted file mode 100644 index 8b4b237e6..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/084_update_quality_minmax_sizeFixture.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class update_quality_minmax_sizeFixture : MigrationTest - { - [Test] - public void should_not_fail_if_empty() - { - var db = WithMigrationTestDb(); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().BeEmpty(); - } - - [Test] - public void should_set_rawhd_to_null() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("QualityDefinitions").Row(new - { - Quality = 1, - Title = "SDTV", - MinSize = 0, - MaxSize = 100 - }) - .Row(new - { - Quality = 10, - Title = "RawHD", - MinSize = 0, - MaxSize = 100 - }); - }); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().HaveCount(2); - qualityDefinitions.First(v => v.Quality == 10).MaxSize.Should().NotHaveValue(); - } - - [Test] - public void should_set_zero_maxsize_to_null() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("QualityDefinitions").Row(new - { - Quality = 1, - Title = "SDTV", - MinSize = 0, - MaxSize = 0 - }); - }); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().HaveCount(1); - qualityDefinitions.First(v => v.Quality == 1).MaxSize.Should().NotHaveValue(); - } - - [Test] - public void should_preserve_values() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("QualityDefinitions").Row(new - { - Quality = 1, - Title = "SDTV", - MinSize = 0, - MaxSize = 100 - }) - .Row(new - { - Quality = 10, - Title = "RawHD", - MinSize = 0, - MaxSize = 100 - }); - }); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().HaveCount(2); - qualityDefinitions.First(v => v.Quality == 1).MaxSize.Should().Be(100); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/085_expand_transmission_urlbaseFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/085_expand_transmission_urlbaseFixture.cs deleted file mode 100644 index 0b1f7460d..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/085_expand_transmission_urlbaseFixture.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class expand_transmission_urlbaseFixture : MigrationTest - { - [Test] - public void should_not_fail_if_no_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Deluge", - Implementation = "Deluge", - Settings = new DelugeSettings85 - { - Host = "127.0.0.1", - TvCategory = "abc", - UrlBase = "/my/" - }.ToJson(), - ConfigContract = "DelugeSettings" - }); - }); - - var items = db.Query("SELECT * FROM DownloadClients"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().UrlBase.Should().Be("/my/"); - } - - [Test] - public void should_be_updated_for_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new TransmissionSettings81 - { - Host = "127.0.0.1", - TvCategory = "abc" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var items = db.Query("SELECT * FROM DownloadClients"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().UrlBase.Should().Be("/transmission/"); - } - - [Test] - public void should_be_append_to_existing_urlbase() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new TransmissionSettings81 - { - Host = "127.0.0.1", - TvCategory = "abc", - UrlBase = "/my/url/" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var items = db.Query("SELECT * FROM DownloadClients"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().UrlBase.Should().Be("/my/url/transmission/"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/086_pushbullet_device_idsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/086_pushbullet_device_idsFixture.cs deleted file mode 100644 index 20a8e063a..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/086_pushbullet_device_idsFixture.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class pushbullet_device_idsFixture : MigrationTest - { - [Test] - public void should_not_fail_if_no_pushbullet() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "Pushover", - Implementation = "Pushover", - Settings = "{}", - ConfigContract = "PushoverSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - } - - [Test] - public void should_not_fail_if_deviceId_is_not_set() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "PushBullet", - Implementation = "PushBullet", - Settings = new - { - ApiKey = "my_api_key" - }.ToJson(), - ConfigContract = "PushBulletSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - } - - [Test] - public void should_add_deviceIds_setting_matching_deviceId() - { - var deviceId = "device_id"; - - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "PushBullet", - Implementation = "PushBullet", - Settings = new - { - ApiKey = "my_api_key", - DeviceId = deviceId - }.ToJson(), - ConfigContract = "PushBulletSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().DeviceIds.First().Should().Be(deviceId); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/088_pushbullet_devices_channels_listFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/088_pushbullet_devices_channels_listFixture.cs deleted file mode 100644 index 37679998c..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/088_pushbullet_devices_channels_listFixture.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class pushbullet_devices_channels_listFixture : MigrationTest - { - [Test] - public void should_convert_comma_separted_string_to_list() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "PushBullet", - Implementation = "PushBullet", - Settings = new - { - ApiKey = "my_api_key", - ChannelTags = "channel1,channel2" - }.ToJson(), - ConfigContract = "PushBulletSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().ChannelTags.Should().HaveCount(2); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs deleted file mode 100644 index 292344127..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class update_kickass_url_migration_fixture : MigrationTest - { - [TestCase("http://kickass.so")] - [TestCase("https://kickass.so")] - [TestCase("http://kickass.to")] - [TestCase("https://kickass.to")] - [TestCase("http://kat.cr")] - // [TestCase("HTTP://KICKASS.SO")] Not sure if there is an easy way to do this, not sure if worth it. - public void should_replace_old_url(string oldUrl) - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Indexers").Row(new - { - Name = "Kickass_wrong_url", - Implementation = "KickassTorrents", - Settings = new KickassTorrentsSettings90 - { - BaseUrl = oldUrl - }.ToJson(), - ConfigContract = "KickassTorrentsSettings" - }); - }); - - var items = db.Query("SELECT * FROM Indexers"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().BaseUrl.Should().Be("https://kat.cr"); - } - - [Test] - public void should_not_replace_other_indexers() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Indexers").Row(new - { - Name = "not_kickass", - Implementation = "NotKickassTorrents", - Settings = new KickassTorrentsSettings90 - { - BaseUrl = "kickass.so", - }.ToJson(), - ConfigContract = "KickassTorrentsSettings" - }); - }); - - var items = db.Query("SELECT * FROM Indexers"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().BaseUrl.Should().Be("kickass.so"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/099_extra_and_subtitle_filesFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/099_extra_and_subtitle_filesFixture.cs deleted file mode 100644 index f72d950f0..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/099_extra_and_subtitle_filesFixture.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class metadata_files_extensionFixture : MigrationTest - { - [Test] - public void should_set_extension_using_relative_path() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - RelativePath = "banner.jpg", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 3, - Consumer = "XbmcMetadata" - }); - - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - SeasonNumber = 1, - EpisodeFileId = 1, - RelativePath = "Series.Title.S01E01.jpg", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 5, - Consumer = "XbmcMetadata" - }); - - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - RelativePath = "Series Title", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 3, - Consumer = "RoksboxMetadata" - }); - }); - - var items = db.Query("SELECT * FROM MetadataFiles"); - - items.Should().HaveCount(2); - items.First().Extension.Should().Be(".jpg"); - items.Last().Extension.Should().Be(".jpg"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/101_add_ultrahd_quality_in_profilesFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/101_add_ultrahd_quality_in_profilesFixture.cs deleted file mode 100644 index 8e5562824..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/101_add_ultrahd_quality_in_profilesFixture.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class add_ultrahd_quality_in_profilesFixture : MigrationTest - { - [Test] - public void should_add_ultrahd_to_old_profile() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - Id = 0, - Name = "SDTV", - Cutoff = 1, - Items = "[ { \"quality\": 1, \"allowed\": true } ]", - Language = 1 - }); - }); - - var profiles = db.Query("SELECT Items FROM Profiles LIMIT 1"); - - var items = profiles.First().Items; - items.Should().HaveCount(4); - items.Select(v => v.Quality).Should().BeEquivalentTo(1, 16, 18, 19); - items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/103_fix_metadata_file_extensionsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/103_fix_metadata_file_extensionsFixture.cs deleted file mode 100644 index 86905df18..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/103_fix_metadata_file_extensionsFixture.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class fix_metadata_file_extensionsFixture : MigrationTest - { - [Test] - public void should_fix_extension_when_relative_path_contained_multiple_periods() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - SeasonNumber = 1, - EpisodeFileId = 1, - RelativePath = "Series.Title.S01E01.jpg", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 5, - Consumer = "XbmcMetadata", - Extension = ".S01E01.jpg" - }); - }); - - var items = db.Query("SELECT * FROM MetadataFiles"); - - items.Should().HaveCount(1); - items.First().Extension.Should().Be(".jpg"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/106_update_btn_urlFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/106_update_btn_urlFixture.cs deleted file mode 100644 index 3b719d42e..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/106_update_btn_urlFixture.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class update_btn_url_migration_fixture : MigrationTest - { - [TestCase("http://api.btnapps.net")] - [TestCase("https://api.btnapps.net")] - [TestCase("http://api.btnapps.net/")] - [TestCase("https://api.btnapps.net/")] - public void should_replace_old_url(string oldUrl) - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Indexers").Row(new - { - Name = "btn_old_url", - Implementation = "BroadcastheNet", - Settings = new BroadcastheNetSettings106 - { - BaseUrl = oldUrl - }.ToJson(), - ConfigContract = "BroadcastheNetSettings" - }); - }); - - var items = db.Query("SELECT * FROM Indexers"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().BaseUrl.Should().Contain("api.broadcasthe.net"); - } - - [Test] - public void should_not_replace_other_indexers() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Indexers").Row(new - { - Name = "not_btn", - Implementation = "NotBroadcastheNet", - Settings = new BroadcastheNetSettings106 - { - BaseUrl = "http://api.btnapps.net", - }.ToJson(), - ConfigContract = "BroadcastheNetSettings" - }); - }); - - var items = db.Query("SELECT * FROM Indexers"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().BaseUrl.Should().Be("http://api.btnapps.net"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/108_fix_metadata_file_extensionsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/108_fix_metadata_file_extensionsFixture.cs deleted file mode 100644 index 200a43056..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/108_fix_metadata_file_extensionsFixture.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Languages; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class fix_extra_file_extensionsFixture : MigrationTest - { - [Test] - public void should_extra_files_that_do_not_have_an_extension() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("ExtraFiles").Row(new - { - SeriesId = 1, - SeasonNumber = 1, - EpisodeFileId = 1, - RelativePath = "Series.Title.S01E01", - Added = "2016-05-30 20:23:02.3725923", - LastUpdated = "2016-05-30 20:23:02.3725923", - Extension = "" - }); - }); - - var items = db.Query("Select * from ExtraFiles"); - - items.Should().BeEmpty(); - } - - [Test] - public void should_fix_double_extension() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("SubtitleFiles").Row(new - { - SeriesId = 1, - SeasonNumber = 1, - EpisodeFileId = 1, - RelativePath = "Series.Title.S01E01.en.srt", - Added = "2016-05-30 20:23:02.3725923", - LastUpdated = "2016-05-30 20:23:02.3725923", - Language = Core.Languages.Language.English, - Extension = "en.srt" - }); - }); - - var items = db.Query("Select * from SubtitleFiles"); - - items.Should().HaveCount(1); - items.First()["Extension"].Should().Be(".srt"); - } - - [Test] - public void should_fix_extension_missing_a_leading_period() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("ExtraFiles").Row(new - { - SeriesId = 1, - SeasonNumber = 1, - EpisodeFileId = 1, - RelativePath = "Series.Title.S01E01.nfo-orig", - Added = "2016-05-30 20:23:02.3725923", - LastUpdated = "2016-05-30 20:23:02.3725923", - Extension = "nfo-orig" - }); - }); - - var items = db.Query("Select * from ExtraFiles"); - - items.Should().HaveCount(1); - items.First()["Extension"].Should().Be(".nfo-orig"); - } - } - -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/109_import_extra_files_configFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/109_import_extra_files_configFixture.cs deleted file mode 100644 index 4ef9e4979..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/109_import_extra_files_configFixture.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class import_extra_files_configFixture : MigrationTest - { - [Test] - public void should_not_insert_if_missing() - { - var db = WithMigrationTestDb(); - - var items = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - items.Should().BeNull(); - } - - [Test] - public void should_not_insert_if_empty() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Config").Row(new - { - Key = "extrafileextensions", - Value = "" - }); - }); - - var items = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - items.Should().BeNull(); - } - - [Test] - public void should_insert_True_if_configured() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Config").Row(new - { - Key = "extrafileextensions", - Value = "srt" - }); - }); - - var items = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - items.Should().Be("True"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/110_fix_extra_files_configFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/110_fix_extra_files_configFixture.cs deleted file mode 100644 index 1a38efc1c..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/110_fix_extra_files_configFixture.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class fix_extra_files_configFixture : MigrationTest - { - [Test] - public void should_not_update_importextrafiles_disabled() - { - var db = WithMigrationTestDb(); - - var itemEnabled = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - itemEnabled.Should().BeNull(); - } - - [Test] - public void should_fix_importextrafiles_if_wrong() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Config").Row(new - { - Key = "importextrafiles", - Value = 1 - }); - }); - - - var itemEnabled = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - itemEnabled.Should().Be("True"); - } - - [Test] - public void should_fill_in_default_extensions() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Config").Row(new - { - Key = "importextrafiles", - Value = "False" - }); - - c.Insert.IntoTable("Config").Row(new - { - Key = "extrafileextensions", - Value = "" - }); - }); - - var itemEnabled = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - itemEnabled.Should().Be("False"); - - var itemExtensions = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'extrafileextensions'"); - itemExtensions.Should().Be("srt"); - } - - [Test] - public void should_not_fill_in_default_extensions() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Config").Row(new - { - Key = "importextrafiles", - Value = "True" - }); - - c.Insert.IntoTable("Config").Row(new - { - Key = "extrafileextensions", - Value = "" - }); - }); - - var itemEnabled = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - itemEnabled.Should().Be("True"); - - var itemExtensions = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'extrafileextensions'"); - itemExtensions.Should().Be(""); - } - - [Test] - public void should_not_fill_in_default_extensions_if_not_defined() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Config").Row(new - { - Key = "importextrafiles", - Value = "False" - }); - }); - - var itemEnabled = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - itemEnabled.Should().Be("False"); - - var itemExtensions = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'extrafileextensions'"); - itemExtensions.Should().BeNull(); - } - - [Test] - public void should_not_fill_in_default_extensions_if_already_defined() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Config").Row(new - { - Key = "importextrafiles", - Value = "False" - }); - - c.Insert.IntoTable("Config").Row(new - { - Key = "extrafileextensions", - Value = "sub" - }); - }); - - var itemEnabled = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'importextrafiles'"); - itemEnabled.Should().Be("False"); - - var itemExtensions = db.QueryScalar("SELECT Value FROM Config WHERE Key = 'extrafileextensions'"); - itemExtensions.Should().Be("sub"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/PendingReleaseServiceFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/PendingReleaseServiceFixture.cs index 37f979ba9..b640003dc 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/PendingReleaseServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/PendingReleaseServiceFixture.cs @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { Mocker.GetMock() .Setup(v => v.GetBlockedIndexers()) - .Returns(new List { new IndexerStatus { IndexerId = 1, DisabledTill = DateTime.UtcNow.AddHours(2) } }); + .Returns(new List { new IndexerStatus { ProviderId = 1, DisabledTill = DateTime.UtcNow.AddHours(2) } }); GivenPendingRelease(); diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerStatusCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerStatusCheckFixture.cs index 6592e2a76..246765963 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerStatusCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerStatusCheckFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Moq; using NUnit.Framework; @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks { _blockedIndexers.Add(new IndexerStatus { - IndexerId = id, + ProviderId = id, InitialFailure = DateTime.UtcNow.AddHours(-failureHours), MostRecentFailure = DateTime.UtcNow.AddHours(-0.1), EscalationLevel = 5, diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedIndexerStatusFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedIndexerStatusFixture.cs index 189c1672d..c5e757188 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedIndexerStatusFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedIndexerStatusFixture.cs @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers public void should_delete_orphaned_indexerstatus() { var status = Builder.CreateNew() - .With(h => h.IndexerId = _indexer.Id) + .With(h => h.ProviderId = _indexer.Id) .BuildNew(); Db.Insert(status); @@ -42,13 +42,13 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers GivenIndexer(); var status = Builder.CreateNew() - .With(h => h.IndexerId = _indexer.Id) + .With(h => h.ProviderId = _indexer.Id) .BuildNew(); Db.Insert(status); Subject.Clean(); AllStoredModels.Should().HaveCount(1); - AllStoredModels.Should().Contain(h => h.IndexerId == _indexer.Id); + AllStoredModels.Should().Contain(h => h.ProviderId == _indexer.Id); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index a2a234ffc..053715ae8 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -104,8 +104,6 @@ - - @@ -113,24 +111,6 @@ - - - - - - - - - - - - - - - - - - @@ -537,6 +517,7 @@ + diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs b/src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs deleted file mode 100644 index 58b69f2b9..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingProvider - { - List GetSceneMappings(); - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs deleted file mode 100644 index b992aa029..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Newtonsoft.Json; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class SceneMapping : ModelBase - { - public string Title { get; set; } - public string ParseTerm { get; set; } - - [JsonProperty("searchTitle")] - public string SearchTerm { get; set; } - - public int TvdbId { get; set; } - - [JsonProperty("season")] - public int? SeasonNumber { get; set; } - - public int? SceneSeasonNumber { get; set; } - public string Type { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs deleted file mode 100644 index 4c4d15b76..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Common.Cloud; -using NzbDrone.Common.Http; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingProxy - { - List Fetch(); - } - - public class SceneMappingProxy : ISceneMappingProxy - { - private readonly IHttpClient _httpClient; - private readonly IHttpRequestBuilderFactory _requestBuilder; - - public SceneMappingProxy(IHttpClient httpClient, ILidarrCloudRequestBuilder requestBuilder) - { - _httpClient = httpClient; - _requestBuilder = requestBuilder.Services; - } - - public List Fetch() - { - var request = _requestBuilder.Create() - .Resource("/scenemapping") - .Build(); - - return _httpClient.Get>(request).Resource; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs deleted file mode 100644 index ce86916ec..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs +++ /dev/null @@ -1,31 +0,0 @@ -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Messaging.Events; -using System.Collections.Generic; - - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingRepository : IBasicRepository - { - List FindByTvdbid(int tvdbId); - void Clear(string type); - } - - public class SceneMappingRepository : BasicRepository, ISceneMappingRepository - { - public SceneMappingRepository(IMainDatabase database, IEventAggregator eventAggregator) - : base(database, eventAggregator) - { - } - - public List FindByTvdbid(int tvdbId) - { - return Query.Where(x => x.TvdbId == tvdbId); - } - - public void Clear(string type) - { - Delete(s => s.Type == type); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs deleted file mode 100644 index 511e1bebf..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs +++ /dev/null @@ -1,252 +0,0 @@ -using System; -using System.Linq; -using NLog; -using NzbDrone.Common.Cache; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Parser; -using System.Collections.Generic; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingService - { - List GetSceneNames(int tvdbId, List seasonNumbers, List sceneSeasonNumbers); - int? FindTvdbId(string title); - List FindByTvdbId(int tvdbId); - SceneMapping FindSceneMapping(string title); - int? GetSceneSeasonNumber(string title); - int? GetTvdbSeasonNumber(string title); - int? GetSceneSeasonNumber(int tvdbId, int seasonNumber); - } - - public class SceneMappingService : ISceneMappingService, - // IHandle, - IExecute - { - private readonly ISceneMappingRepository _repository; - private readonly IEnumerable _sceneMappingProviders; - private readonly IEventAggregator _eventAggregator; - private readonly Logger _logger; - private readonly ICachedDictionary> _getTvdbIdCache; - private readonly ICachedDictionary> _findByTvdbIdCache; - - public SceneMappingService(ISceneMappingRepository repository, - ICacheManager cacheManager, - IEnumerable sceneMappingProviders, - IEventAggregator eventAggregator, - Logger logger) - { - _repository = repository; - _sceneMappingProviders = sceneMappingProviders; - _eventAggregator = eventAggregator; - _logger = logger; - - _getTvdbIdCache = cacheManager.GetCacheDictionary>(GetType(), "tvdb_id"); - _findByTvdbIdCache = cacheManager.GetCacheDictionary>(GetType(), "find_tvdb_id"); - } - - public List GetSceneNames(int tvdbId, List seasonNumbers, List sceneSeasonNumbers) - { - var mappings = FindByTvdbId(tvdbId); - - if (mappings == null) - { - return new List(); - } - - var names = mappings.Where(n => n.SeasonNumber.HasValue && seasonNumbers.Contains(n.SeasonNumber.Value) || - n.SceneSeasonNumber.HasValue && sceneSeasonNumbers.Contains(n.SceneSeasonNumber.Value) || - (n.SeasonNumber ?? -1) == -1 && (n.SceneSeasonNumber ?? -1) == -1) - .Select(n => n.SearchTerm).Distinct().ToList(); - - return FilterNonEnglish(names); - } - - public int? FindTvdbId(string title) - { - var mapping = FindMapping(title); - - if (mapping == null) - return null; - - return mapping.TvdbId; - } - - public List FindByTvdbId(int tvdbId) - { - if (_findByTvdbIdCache.Count == 0) - { - RefreshCache(); - } - - var mappings = _findByTvdbIdCache.Find(tvdbId.ToString()); - - if (mappings == null) - { - return new List(); - } - - return mappings; - } - - public SceneMapping FindSceneMapping(string title) - { - return FindMapping(title); - } - - public int? GetSceneSeasonNumber(string title) - { - var mapping = FindMapping(title); - - if (mapping == null) - { - return null; - } - - return mapping.SceneSeasonNumber; - } - - public int? GetTvdbSeasonNumber(string title) - { - var mapping = FindMapping(title); - - if (mapping == null) - { - return null; - } - - return mapping.SeasonNumber; - } - - public int? GetSceneSeasonNumber(int tvdbId, int seasonNumber) - { - var mappings = FindByTvdbId(tvdbId); - - if (mappings == null) - { - return null; - } - - var mapping = mappings.FirstOrDefault(e => e.SeasonNumber == seasonNumber && e.SceneSeasonNumber.HasValue); - - if (mapping == null) - { - return null; - } - - return mapping.SceneSeasonNumber; - } - - private void UpdateMappings() - { - _logger.Info("Updating Scene mappings"); - - foreach (var sceneMappingProvider in _sceneMappingProviders) - { - try - { - var mappings = sceneMappingProvider.GetSceneMappings(); - - if (mappings.Any()) - { - _repository.Clear(sceneMappingProvider.GetType().Name); - - mappings.RemoveAll(sceneMapping => - { - if (sceneMapping.Title.IsNullOrWhiteSpace() || - sceneMapping.SearchTerm.IsNullOrWhiteSpace()) - { - _logger.Warn("Invalid scene mapping found for: {0}, skipping", sceneMapping.TvdbId); - return true; - } - - return false; - }); - - foreach (var sceneMapping in mappings) - { - sceneMapping.ParseTerm = sceneMapping.Title.CleanSeriesTitle(); - sceneMapping.Type = sceneMappingProvider.GetType().Name; - } - - _repository.InsertMany(mappings.ToList()); - } - else - { - _logger.Warn("Received empty list of mapping. will not update."); - } - } - catch (Exception ex) - { - _logger.Error(ex, "Failed to Update Scene Mappings."); - } - } - - RefreshCache(); - - _eventAggregator.PublishEvent(new SceneMappingsUpdatedEvent()); - } - - private SceneMapping FindMapping(string title) - { - if (_getTvdbIdCache.Count == 0) - { - RefreshCache(); - } - - var candidates = _getTvdbIdCache.Find(title.CleanSeriesTitle()); - - if (candidates == null) - { - return null; - } - - if (candidates.Count == 1) - { - return candidates.First(); - } - - var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber) - .FirstOrDefault(v => v.Title == title); - - if (exactMatch != null) - { - return exactMatch; - } - - var closestMatch = candidates.OrderBy(v => title.LevenshteinDistance(v.Title, 10, 1, 10)) - .ThenByDescending(v => v.SeasonNumber) - .First(); - - return closestMatch; - } - - private void RefreshCache() - { - var mappings = _repository.All().ToList(); - - _getTvdbIdCache.Update(mappings.GroupBy(v => v.ParseTerm).ToDictionary(v => v.Key, v => v.ToList())); - _findByTvdbIdCache.Update(mappings.GroupBy(v => v.TvdbId).ToDictionary(v => v.Key.ToString(), v => v.ToList())); - } - - private List FilterNonEnglish(List titles) - { - return titles.Where(title => title.All(c => c <= 255)).ToList(); - } - - //public void Handle(SeriesRefreshStartingEvent message) - //{ - // if (message.ManualTrigger && _findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1))) - // { - // UpdateMappings(); - // } - //} - - public void Execute(UpdateSceneMappingCommand message) - { - UpdateMappings(); - } - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs deleted file mode 100644 index 06f6d4a3f..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class SceneMappingsUpdatedEvent : IEvent - { - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs b/src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs deleted file mode 100644 index 605488cf9..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class ServicesProvider : ISceneMappingProvider - { - private readonly ISceneMappingProxy _sceneMappingProxy; - - public ServicesProvider(ISceneMappingProxy sceneMappingProxy) - { - _sceneMappingProxy = sceneMappingProxy; - } - - public List GetSceneMappings() - { - return _sceneMappingProxy.Fetch(); - } - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs b/src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs deleted file mode 100644 index 215f8e033..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs +++ /dev/null @@ -1,9 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class UpdateSceneMappingCommand : Command - { - - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs index b2792fe56..d6cdaa68c 100644 --- a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs +++ b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs @@ -1,4 +1,4 @@ -using FluentMigrator; +using FluentMigrator; using NzbDrone.Core.Datastore.Migration.Framework; namespace NzbDrone.Core.Datastore.Migration @@ -15,127 +15,297 @@ namespace NzbDrone.Core.Datastore.Migration Create.TableForModel("RootFolders") .WithColumn("Path").AsString().Unique(); - Create.TableForModel("Series") - .WithColumn("TvdbId").AsInt32().Unique() - .WithColumn("TvRageId").AsInt32().Unique() - .WithColumn("ImdbId").AsString().Unique() - .WithColumn("Title").AsString() - .WithColumn("TitleSlug").AsString().Unique() - .WithColumn("CleanTitle").AsString() + Create.TableForModel("Artists") + .WithColumn("ForeignArtistId").AsString().Unique() + .WithColumn("MBId").AsString().Nullable() + .WithColumn("AMId").AsString().Nullable() + .WithColumn("TADBId").AsInt32().Nullable() + .WithColumn("DiscogsId").AsInt32().Nullable() + .WithColumn("Name").AsString() + .WithColumn("NameSlug").AsString().Nullable().Unique() + .WithColumn("CleanName").AsString().Indexed() .WithColumn("Status").AsInt32() .WithColumn("Overview").AsString().Nullable() - .WithColumn("AirTime").AsString().Nullable() .WithColumn("Images").AsString() - .WithColumn("Path").AsString() + .WithColumn("Path").AsString().Indexed() .WithColumn("Monitored").AsBoolean() - .WithColumn("QualityProfileId").AsInt32() - .WithColumn("SeasonFolder").AsBoolean() + .WithColumn("AlbumFolder").AsBoolean() .WithColumn("LastInfoSync").AsDateTime().Nullable() .WithColumn("LastDiskSync").AsDateTime().Nullable() - .WithColumn("Runtime").AsInt32() - .WithColumn("SeriesType").AsInt32() - .WithColumn("BacklogSetting").AsInt32() - .WithColumn("Network").AsString().Nullable() - .WithColumn("CustomStartDate").AsDateTime().Nullable() - .WithColumn("UseSceneNumbering").AsBoolean() - .WithColumn("FirstAired").AsDateTime().Nullable() - .WithColumn("NextAiring").AsDateTime().Nullable(); - - Create.TableForModel("Seasons") - .WithColumn("SeriesId").AsInt32() - .WithColumn("SeasonNumber").AsInt32() - .WithColumn("Ignored").AsBoolean(); - - Create.TableForModel("Episodes") - .WithColumn("TvDbEpisodeId").AsInt32().Unique() - .WithColumn("SeriesId").AsInt32() - .WithColumn("SeasonNumber").AsInt32() - .WithColumn("EpisodeNumber").AsInt32() - .WithColumn("Title").AsString().Nullable() + .WithColumn("DateFormed").AsDateTime().Nullable() + .WithColumn("Members").AsString().Nullable() + .WithColumn("Ratings").AsString().Nullable() + .WithColumn("Genres").AsString().Nullable() + .WithColumn("SortName").AsString().Nullable() + .WithColumn("ProfileId").AsInt32().Nullable() + .WithColumn("Tags").AsString().Nullable() + .WithColumn("Added").AsDateTime().Nullable() + .WithColumn("AddOptions").AsString().Nullable() + .WithColumn("LanguageProfileId").AsInt32().WithDefaultValue(1) + .WithColumn("Links").AsString().Nullable() + .WithColumn("ArtistType").AsString().Nullable() + .WithColumn("Disambiguation").AsString().Nullable() + .WithColumn("PrimaryAlbumTypes").AsString().Nullable() + .WithColumn("SecondaryAlbumTypes").AsString().Nullable(); + + Create.TableForModel("Albums") + .WithColumn("ForeignAlbumId").AsString().Unique() + .WithColumn("ArtistId").AsInt32() + .WithColumn("MBId").AsString().Nullable().Indexed() + .WithColumn("AMId").AsString().Nullable() + .WithColumn("TADBId").AsInt32().Nullable().Indexed() + .WithColumn("DiscogsId").AsInt32().Nullable() + .WithColumn("Title").AsString() + .WithColumn("TitleSlug").AsString().Nullable().Unique() + .WithColumn("CleanTitle").AsString().Indexed() .WithColumn("Overview").AsString().Nullable() - .WithColumn("Ignored").AsBoolean().Nullable() - .WithColumn("EpisodeFileId").AsInt32().Nullable() - .WithColumn("AirDate").AsDateTime().Nullable() - .WithColumn("AbsoluteEpisodeNumber").AsInt32().Nullable() - .WithColumn("SceneAbsoluteEpisodeNumber").AsInt32().Nullable() - .WithColumn("SceneSeasonNumber").AsInt32().Nullable() - .WithColumn("SceneEpisodeNumber").AsInt32().Nullable(); - - Create.TableForModel("EpisodeFiles") - .WithColumn("SeriesId").AsInt32() - .WithColumn("Path").AsString().Unique() - .WithColumn("Quality").AsString() - .WithColumn("Size").AsInt64() - .WithColumn("DateAdded").AsDateTime() - .WithColumn("SeasonNumber").AsInt32() - .WithColumn("SceneName").AsString().Nullable() - .WithColumn("ReleaseGroup").AsString().Nullable(); + .WithColumn("Images").AsString() + .WithColumn("Path").AsString().Indexed() + .WithColumn("Monitored").AsBoolean() + .WithColumn("LastInfoSync").AsDateTime().Nullable() + .WithColumn("LastDiskSync").AsDateTime().Nullable() + .WithColumn("ReleaseDate").AsDateTime().Nullable() + .WithColumn("Ratings").AsString().Nullable() + .WithColumn("Genres").AsString().Nullable() + .WithColumn("Label").AsString().Nullable() + .WithColumn("SortTitle").AsString().Nullable() + .WithColumn("ProfileId").AsInt32().Nullable() + .WithColumn("Tags").AsString().Nullable() + .WithColumn("Added").AsDateTime().Nullable() + .WithColumn("AlbumType").AsString() + .WithColumn("AddOptions").AsString().Nullable() + .WithColumn("Duration").AsInt32().WithDefaultValue(0); + + + Create.TableForModel("Tracks") + .WithColumn("ForeignTrackId").AsString().Unique() + .WithColumn("ArtistId").AsInt32().Indexed() + .WithColumn("AlbumId").AsInt32() + .WithColumn("TrackNumber").AsInt32() + .WithColumn("Title").AsString().Nullable() + .WithColumn("Explicit").AsBoolean() + .WithColumn("Compilation").AsBoolean() + .WithColumn("DiscNumber").AsInt32().Nullable() + .WithColumn("TrackFileId").AsInt32().Nullable().Indexed() + .WithColumn("Monitored").AsBoolean() + .WithColumn("Ratings").AsString().Nullable() + .WithColumn("Duration").AsInt32().WithDefaultValue(0); + + Create.Index().OnTable("Tracks").OnColumn("ArtistId").Ascending() + .OnColumn("AlbumId").Ascending() + .OnColumn("TrackNumber").Ascending(); + + Create.TableForModel("TrackFiles") + .WithColumn("ArtistId").AsInt32().Indexed() + .WithColumn("AlbumId").AsInt32().Indexed() + .WithColumn("Quality").AsString() + .WithColumn("Size").AsInt64() + .WithColumn("SceneName").AsString().Nullable() + .WithColumn("DateAdded").AsDateTime() + .WithColumn("ReleaseGroup").AsString().Nullable() + .WithColumn("MediaInfo").AsString().Nullable() + .WithColumn("RelativePath").AsString().Nullable() + .WithColumn("Language").AsInt32().WithDefaultValue(0); Create.TableForModel("History") - .WithColumn("EpisodeId").AsInt32() - .WithColumn("SeriesId").AsInt32() - .WithColumn("NzbTitle").AsString() - .WithColumn("Date").AsDateTime() - .WithColumn("Quality").AsString() - .WithColumn("Indexer").AsString() - .WithColumn("NzbInfoUrl").AsString().Nullable() - .WithColumn("ReleaseGroup").AsString().Nullable(); + .WithColumn("SourceTitle").AsString() + .WithColumn("Date").AsDateTime().Indexed() + .WithColumn("Quality").AsString() + .WithColumn("Data").AsString() + .WithColumn("EventType").AsInt32().Nullable().Indexed() + .WithColumn("DownloadId").AsString().Nullable().Indexed() + .WithColumn("Language").AsInt32().NotNullable().WithDefaultValue(0) + .WithColumn("ArtistId").AsInt32().WithDefaultValue(0) + .WithColumn("AlbumId").AsInt32().Indexed().WithDefaultValue(0) + .WithColumn("TrackId").AsInt32().WithDefaultValue(0); Create.TableForModel("Notifications") - .WithColumn("Name").AsString() - .WithColumn("OnGrab").AsBoolean() - .WithColumn("OnDownload").AsBoolean() - .WithColumn("Settings").AsString() - .WithColumn("Implementation").AsString(); + .WithColumn("Name").AsString() + .WithColumn("OnGrab").AsBoolean() + .WithColumn("OnDownload").AsBoolean() + .WithColumn("Settings").AsString() + .WithColumn("Implementation").AsString() + .WithColumn("ConfigContract").AsString().Nullable() + .WithColumn("OnUpgrade").AsBoolean().Nullable() + .WithColumn("Tags").AsString().Nullable() + .WithColumn("OnRename").AsBoolean().NotNullable(); Create.TableForModel("ScheduledTasks") - .WithColumn("TypeName").AsString().Unique() - .WithColumn("Interval").AsInt32() - .WithColumn("LastExecution").AsDateTime(); + .WithColumn("TypeName").AsString().Unique() + .WithColumn("Interval").AsInt32() + .WithColumn("LastExecution").AsDateTime(); Create.TableForModel("Indexers") - .WithColumn("Enable").AsBoolean() - .WithColumn("Name").AsString().Unique() - .WithColumn("Implementation").AsString() - .WithColumn("Settings").AsString().Nullable(); + .WithColumn("Name").AsString().Unique() + .WithColumn("Implementation").AsString() + .WithColumn("Settings").AsString().Nullable() + .WithColumn("ConfigContract").AsString().Nullable() + .WithColumn("EnableRss").AsBoolean().Nullable() + .WithColumn("EnableSearch").AsBoolean().Nullable(); + + Create.TableForModel("Profiles") + .WithColumn("Name").AsString().Unique() + .WithColumn("Cutoff").AsInt32() + .WithColumn("Items").AsString().NotNullable(); - Create.TableForModel("QualityProfiles") - .WithColumn("Name").AsString().Unique() - .WithColumn("Cutoff").AsInt32() - .WithColumn("Allowed").AsString(); + Create.TableForModel("QualityDefinitions") + .WithColumn("Quality").AsInt32().Unique() + .WithColumn("Title").AsString().Unique() + .WithColumn("MinSize").AsDouble().Nullable() + .WithColumn("MaxSize").AsDouble().Nullable(); - Create.TableForModel("QualitySizes") - .WithColumn("QualityId").AsInt32().Unique() - .WithColumn("Name").AsString().Unique() - .WithColumn("MinSize").AsInt32() - .WithColumn("MaxSize").AsInt32(); + Create.TableForModel("NamingConfig") + .WithColumn("ReplaceIllegalCharacters").AsBoolean().WithDefaultValue(true) + .WithColumn("ArtistFolderFormat").AsString().Nullable() + .WithColumn("RenameTracks").AsBoolean().Nullable() + .WithColumn("StandardTrackFormat").AsString().Nullable() + .WithColumn("AlbumFolderFormat").AsString().Nullable(); - Create.TableForModel("SceneMappings") - .WithColumn("CleanTitle").AsString() - .WithColumn("SceneName").AsString() - .WithColumn("TvdbId").AsInt32() - .WithColumn("SeasonNumber").AsInt32(); + Create.TableForModel("Blacklist") + .WithColumn("SourceTitle").AsString() + .WithColumn("Quality").AsString() + .WithColumn("Date").AsDateTime() + .WithColumn("PublishedDate").AsDateTime().Nullable() + .WithColumn("Size").AsInt64().Nullable() + .WithColumn("Protocol").AsInt32().Nullable() + .WithColumn("Indexer").AsString().Nullable() + .WithColumn("Message").AsString().Nullable() + .WithColumn("TorrentInfoHash").AsString().Nullable() + .WithColumn("Language").AsInt32().NotNullable().WithDefaultValue(0) + .WithColumn("ArtistId").AsInt32().WithDefaultValue(0) + .WithColumn("AlbumIds").AsString().WithDefaultValue(""); + Create.TableForModel("Metadata") + .WithColumn("Enable").AsBoolean().NotNullable() + .WithColumn("Name").AsString().NotNullable() + .WithColumn("Implementation").AsString().NotNullable() + .WithColumn("Settings").AsString().NotNullable() + .WithColumn("ConfigContract").AsString().NotNullable(); - Create.TableForModel("NamingConfig") - .WithColumn("UseSceneName").AsBoolean() - .WithColumn("Separator").AsString() - .WithColumn("NumberStyle").AsInt32() - .WithColumn("IncludeSeriesTitle").AsBoolean() - .WithColumn("MultiEpisodeStyle").AsInt32() - .WithColumn("IncludeEpisodeTitle").AsBoolean() - .WithColumn("IncludeQuality").AsBoolean() - .WithColumn("ReplaceSpaces").AsBoolean() - .WithColumn("SeasonFolderFormat").AsString(); + Create.TableForModel("MetadataFiles") + .WithColumn("ArtistId").AsInt32().NotNullable() + .WithColumn("Consumer").AsString().NotNullable() + .WithColumn("Type").AsInt32().NotNullable() + .WithColumn("RelativePath").AsString().NotNullable() + .WithColumn("LastUpdated").AsDateTime().NotNullable() + .WithColumn("AlbumId").AsInt32().Nullable() + .WithColumn("TrackFileId").AsInt32().Nullable() + .WithColumn("Hash").AsString().Nullable() + .WithColumn("Added").AsDateTime().Nullable() + .WithColumn("Extension").AsString().NotNullable(); + + Create.TableForModel("DownloadClients") + .WithColumn("Enable").AsBoolean().NotNullable() + .WithColumn("Name").AsString().NotNullable() + .WithColumn("Implementation").AsString().NotNullable() + .WithColumn("Settings").AsString().NotNullable() + .WithColumn("ConfigContract").AsString().NotNullable(); + + Create.TableForModel("PendingReleases") + .WithColumn("Title").AsString() + .WithColumn("Added").AsDateTime() + .WithColumn("Release").AsString() + .WithColumn("ArtistId").AsInt32().WithDefaultValue(0) + .WithColumn("ParsedAlbumInfo").AsString().WithDefaultValue(""); + + + Create.TableForModel("RemotePathMappings") + .WithColumn("Host").AsString() + .WithColumn("RemotePath").AsString() + .WithColumn("LocalPath").AsString(); + + Create.TableForModel("Tags") + .WithColumn("Label").AsString().Unique(); + + Create.TableForModel("Restrictions") + .WithColumn("Required").AsString().Nullable() + .WithColumn("Preferred").AsString().Nullable() + .WithColumn("Ignored").AsString().Nullable() + .WithColumn("Tags").AsString().NotNullable(); + + Create.TableForModel("DelayProfiles") + .WithColumn("EnableUsenet").AsBoolean().NotNullable() + .WithColumn("EnableTorrent").AsBoolean().NotNullable() + .WithColumn("PreferredProtocol").AsInt32().NotNullable() + .WithColumn("UsenetDelay").AsInt32().NotNullable() + .WithColumn("TorrentDelay").AsInt32().NotNullable() + .WithColumn("Order").AsInt32().NotNullable() + .WithColumn("Tags").AsString().NotNullable(); + + Create.TableForModel("Users") + .WithColumn("Identifier").AsString().NotNullable().Unique() + .WithColumn("Username").AsString().NotNullable().Unique() + .WithColumn("Password").AsString().NotNullable(); + + Create.TableForModel("Commands") + .WithColumn("Name").AsString().NotNullable() + .WithColumn("Body").AsString().NotNullable() + .WithColumn("Priority").AsInt32().NotNullable() + .WithColumn("Status").AsInt32().NotNullable() + .WithColumn("QueuedAt").AsDateTime().NotNullable() + .WithColumn("StartedAt").AsDateTime().Nullable() + .WithColumn("EndedAt").AsDateTime().Nullable() + .WithColumn("Duration").AsString().Nullable() + .WithColumn("Exception").AsString().Nullable() + .WithColumn("Trigger").AsInt32().NotNullable(); + + Create.TableForModel("IndexerStatus") + .WithColumn("ProviderId").AsInt32().NotNullable().Unique() + .WithColumn("InitialFailure").AsDateTime().Nullable() + .WithColumn("MostRecentFailure").AsDateTime().Nullable() + .WithColumn("EscalationLevel").AsInt32().NotNullable() + .WithColumn("DisabledTill").AsDateTime().Nullable() + .WithColumn("LastRssSyncReleaseInfo").AsString().Nullable(); + + Create.TableForModel("ExtraFiles") + .WithColumn("ArtistId").AsInt32().NotNullable() + .WithColumn("AlbumId").AsInt32().NotNullable() + .WithColumn("TrackFileId").AsInt32().NotNullable() + .WithColumn("RelativePath").AsString().NotNullable() + .WithColumn("Extension").AsString().NotNullable() + .WithColumn("Added").AsDateTime().NotNullable() + .WithColumn("LastUpdated").AsDateTime().NotNullable(); + + Create.TableForModel("LyricFiles") + .WithColumn("ArtistId").AsInt32().NotNullable() + .WithColumn("AlbumId").AsInt32().NotNullable() + .WithColumn("TrackFileId").AsInt32().NotNullable() + .WithColumn("RelativePath").AsString().NotNullable() + .WithColumn("Extension").AsString().NotNullable() + .WithColumn("Added").AsDateTime().NotNullable() + .WithColumn("LastUpdated").AsDateTime().NotNullable() + .WithColumn("Language").AsInt32().NotNullable(); + + Create.TableForModel("LanguageProfiles") + .WithColumn("Name").AsString().Unique() + .WithColumn("Languages").AsString() + .WithColumn("Cutoff").AsInt32(); + + Create.TableForModel("DownloadClientStatus") + .WithColumn("ProviderId").AsInt32().NotNullable().Unique() + .WithColumn("InitialFailure").AsDateTime().Nullable() + .WithColumn("MostRecentFailure").AsDateTime().Nullable() + .WithColumn("EscalationLevel").AsInt32().NotNullable() + .WithColumn("DisabledTill").AsDateTime().Nullable(); + + Insert.IntoTable("DelayProfiles").Row(new + { + EnableUsenet = 1, + EnableTorrent = 1, + PreferredProtocol = 1, + UsenetDelay = 0, + TorrentDelay = 0, + Order = int.MaxValue, + Tags = "[]" + }); } protected override void LogDbUpgrade() { Create.TableForModel("Logs") .WithColumn("Message").AsString() - .WithColumn("Time").AsDateTime() + .WithColumn("Time").AsDateTime().Indexed() .WithColumn("Logger").AsString() - .WithColumn("Method").AsString().Nullable() .WithColumn("Exception").AsString().Nullable() .WithColumn("ExceptionType").AsString().Nullable() .WithColumn("Level").AsString(); diff --git a/src/NzbDrone.Core/Datastore/Migration/002_remove_tvrage_imdb_unique_constraint.cs b/src/NzbDrone.Core/Datastore/Migration/002_remove_tvrage_imdb_unique_constraint.cs deleted file mode 100644 index 6fc6a6cd3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/002_remove_tvrage_imdb_unique_constraint.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(2)] - public class remove_tvrage_imdb_unique_constraint : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Index().OnTable("Series").OnColumn("TvRageId"); - Delete.Index().OnTable("Series").OnColumn("ImdbId"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/003_remove_clean_title_from_scene_mapping.cs b/src/NzbDrone.Core/Datastore/Migration/003_remove_clean_title_from_scene_mapping.cs deleted file mode 100644 index a19bae93c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/003_remove_clean_title_from_scene_mapping.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(3)] - public class remove_renamed_scene_mapping_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Table("SceneMappings"); - - Create.TableForModel("SceneMappings") - .WithColumn("TvdbId").AsInt32() - .WithColumn("SeasonNumber").AsInt32() - .WithColumn("SearchTerm").AsString() - .WithColumn("ParseTerm").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/004_updated_history.cs b/src/NzbDrone.Core/Datastore/Migration/004_updated_history.cs deleted file mode 100644 index 5ebc51ac8..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/004_updated_history.cs +++ /dev/null @@ -1,23 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(4)] - public class updated_history : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Table("History"); - - - Create.TableForModel("History") - .WithColumn("EpisodeId").AsInt32() - .WithColumn("SeriesId").AsInt32() - .WithColumn("SourceTitle").AsString() - .WithColumn("Date").AsDateTime() - .WithColumn("Quality").AsString() - .WithColumn("Data").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs b/src/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs deleted file mode 100644 index bead4c96f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(5)] - public class added_eventtype_to_history : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("History") - .AddColumn("EventType") - .AsInt32() - .Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/006_add_index_to_log_time.cs b/src/NzbDrone.Core/Datastore/Migration/006_add_index_to_log_time.cs deleted file mode 100644 index add668fdc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/006_add_index_to_log_time.cs +++ /dev/null @@ -1,23 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(6)] - public class add_index_to_log_time : NzbDroneMigrationBase - { - protected override void LogDbUpgrade() - { - Delete.Table("Logs"); - - Create.TableForModel("Logs") - .WithColumn("Message").AsString() - .WithColumn("Time").AsDateTime().Indexed() - .WithColumn("Logger").AsString() - .WithColumn("Method").AsString().Nullable() - .WithColumn("Exception").AsString().Nullable() - .WithColumn("ExceptionType").AsString().Nullable() - .WithColumn("Level").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs b/src/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs deleted file mode 100644 index 3fc4abef9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(7)] - public class add_renameEpisodes_to_naming : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig") - .AddColumn("RenameEpisodes") - .AsBoolean() - .Nullable(); - - Execute.Sql("UPDATE NamingConfig SET RenameEpisodes =~ UseSceneName"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/008_remove_backlog.cs b/src/NzbDrone.Core/Datastore/Migration/008_remove_backlog.cs deleted file mode 100644 index 19e16242c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/008_remove_backlog.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(8)] - public class remove_backlog : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("BacklogSetting").FromTable("Series"); - Delete.Column("UseSceneName").FromTable("NamingConfig"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/009_fix_renameEpisodes.cs b/src/NzbDrone.Core/Datastore/Migration/009_fix_renameEpisodes.cs deleted file mode 100644 index bdc0c54e5..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/009_fix_renameEpisodes.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(9)] - public class fix_rename_episodes : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("SeasonFolderFormat").FromTable("NamingConfig"); - - Execute.Sql("UPDATE NamingConfig SET RenameEpisodes = 1 WHERE RenameEpisodes = -1"); - Execute.Sql("UPDATE NamingConfig SET RenameEpisodes = 0 WHERE RenameEpisodes = -2"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/010_add_monitored.cs b/src/NzbDrone.Core/Datastore/Migration/010_add_monitored.cs deleted file mode 100644 index a64f44877..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/010_add_monitored.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(10)] - public class add_monitored : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("Monitored").AsBoolean().Nullable(); - Alter.Table("Seasons").AddColumn("Monitored").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Episodes SET Monitored = 1 WHERE Ignored = 0"); - Execute.Sql("UPDATE Episodes SET Monitored = 0 WHERE Ignored = 1"); - - Execute.Sql("UPDATE Seasons SET Monitored = 1 WHERE Ignored = 0"); - Execute.Sql("UPDATE Seasons SET Monitored = 0 WHERE Ignored = 1"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs b/src/NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs deleted file mode 100644 index 193b25094..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(11)] - public class remove_ignored : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Ignored").FromTable("Seasons"); - Delete.Column("Ignored").FromTable("Episodes"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/012_remove_custom_start_date.cs b/src/NzbDrone.Core/Datastore/Migration/012_remove_custom_start_date.cs deleted file mode 100644 index 8b19f1a3f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/012_remove_custom_start_date.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(12)] - public class remove_custom_start_date : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("CustomStartDate").FromTable("Series"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs b/src/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs deleted file mode 100644 index ece91b397..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(13)] - public class add_air_date_utc : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("AirDateUtc").AsDateTime().Nullable(); - - Execute.Sql("UPDATE Episodes SET AirDateUtc = AirDate"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/014_drop_air_date.cs b/src/NzbDrone.Core/Datastore/Migration/014_drop_air_date.cs deleted file mode 100644 index 00af970b9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/014_drop_air_date.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(14)] - public class drop_air_date : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("AirDate").FromTable("Episodes"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/015_add_air_date_as_string.cs b/src/NzbDrone.Core/Datastore/Migration/015_add_air_date_as_string.cs deleted file mode 100644 index 7638e6df5..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/015_add_air_date_as_string.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(15)] - public class add_air_date_as_string : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("AirDate").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs b/src/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs deleted file mode 100644 index 7a2c50e71..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(16)] - public class updated_imported_history_item : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql(@"UPDATE HISTORY SET Data = replace( Data, '""Path""', '""ImportedPath""' ) WHERE EventType=3"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/017_reset_scene_names.cs b/src/NzbDrone.Core/Datastore/Migration/017_reset_scene_names.cs deleted file mode 100644 index e2e3a21d6..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/017_reset_scene_names.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(17)] - public class reset_scene_names : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - //we were storing new file name as scene name. - Execute.Sql(@"UPDATE EpisodeFiles SET SceneName = NULL where SceneName != NULL"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/018_remove_duplicates.cs b/src/NzbDrone.Core/Datastore/Migration/018_remove_duplicates.cs deleted file mode 100644 index d788dd7dc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/018_remove_duplicates.cs +++ /dev/null @@ -1,99 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System.Linq; -using System.Data; -using System.Collections.Generic; -using System; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(18)] - public class remove_duplicates : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(RemoveDuplicates); - } - - private void RemoveDuplicates(IDbConnection conn, IDbTransaction tran) - { - RemoveDuplicateSeries(conn, tran, "TvdbId"); - RemoveDuplicateSeries(conn, tran, "TitleSlug"); - - var duplicatedEpisodes = GetDuplicates(conn, tran, "Episodes", "TvDbEpisodeId"); - - foreach (var duplicate in duplicatedEpisodes) - { - foreach (var episodeId in duplicate.OrderBy(c => c.Key).Skip(1).Select(c => c.Key)) - { - RemoveEpisodeRows(conn, tran, episodeId); - } - } - } - - private IEnumerable>> GetDuplicates(IDbConnection conn, IDbTransaction tran, string tableName, string columnName) - { - var getDuplicates = conn.CreateCommand(); - getDuplicates.Transaction = tran; - getDuplicates.CommandText = string.Format("select id, {0} from {1}", columnName, tableName); - - var result = new List>(); - - using (var reader = getDuplicates.ExecuteReader()) - { - while (reader.Read()) - { - result.Add(new KeyValuePair(reader.GetInt32(0), (T)Convert.ChangeType(reader[1], typeof(T)))); - } - } - - return result.GroupBy(c => c.Value).Where(g => g.Count() > 1); - } - - private void RemoveDuplicateSeries(IDbConnection conn, IDbTransaction tran, string field) - { - var duplicatedSeries = GetDuplicates(conn, tran, "Series", field); - - foreach (var duplicate in duplicatedSeries) - { - foreach (var seriesId in duplicate.OrderBy(c => c.Key).Skip(1).Select(c => c.Key)) - { - RemoveSeriesRows(conn, tran, seriesId); - } - } - } - - private void RemoveSeriesRows(IDbConnection conn, IDbTransaction tran, int seriesId) - { - var deleteCmd = conn.CreateCommand(); - deleteCmd.Transaction = tran; - - deleteCmd.CommandText = string.Format("DELETE FROM Series WHERE Id = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM Episodes WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM Seasons WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM History WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM EpisodeFiles WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - } - - private void RemoveEpisodeRows(IDbConnection conn, IDbTransaction tran, int episodeId) - { - var deleteCmd = conn.CreateCommand(); - deleteCmd.Transaction = tran; - - deleteCmd.CommandText = string.Format("DELETE FROM Episodes WHERE Id = {0}", episodeId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM History WHERE EpisodeId = {0}", episodeId.ToString()); - deleteCmd.ExecuteNonQuery(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/019_restore_unique_constraints.cs b/src/NzbDrone.Core/Datastore/Migration/019_restore_unique_constraints.cs deleted file mode 100644 index bf70a9532..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/019_restore_unique_constraints.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(19)] - public class restore_unique_constraints : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - // During an earlier version of drone, the indexes weren't recreated during alter table. - Execute.Sql("DROP INDEX IF EXISTS \"IX_Series_TvdbId\""); - Execute.Sql("DROP INDEX IF EXISTS \"IX_Series_TitleSlug\""); - Execute.Sql("DROP INDEX IF EXISTS \"IX_Episodes_TvDbEpisodeId\""); - - Create.Index().OnTable("Series").OnColumn("TvdbId").Unique(); - Create.Index().OnTable("Series").OnColumn("TitleSlug").Unique(); - Create.Index().OnTable("Episodes").OnColumn("TvDbEpisodeId").Unique(); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/020_add_year_and_seasons_to_series.cs b/src/NzbDrone.Core/Datastore/Migration/020_add_year_and_seasons_to_series.cs deleted file mode 100644 index 0e2136141..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/020_add_year_and_seasons_to_series.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(20)] - public class add_year_and_seasons_to_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("Year").AsInt32().Nullable(); - Alter.Table("Series").AddColumn("Seasons").AsString().Nullable(); - - Execute.WithConnection(ConvertSeasons); - } - - private void ConvertSeasons(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand allSeriesCmd = conn.CreateCommand()) - { - allSeriesCmd.Transaction = tran; - allSeriesCmd.CommandText = @"SELECT Id FROM Series"; - using (IDataReader allSeriesReader = allSeriesCmd.ExecuteReader()) - { - while (allSeriesReader.Read()) - { - int seriesId = allSeriesReader.GetInt32(0); - var seasons = new List(); - - using (IDbCommand seasonsCmd = conn.CreateCommand()) - { - seasonsCmd.Transaction = tran; - seasonsCmd.CommandText = string.Format(@"SELECT SeasonNumber, Monitored FROM Seasons WHERE SeriesId = {0}", seriesId); - - using (IDataReader seasonReader = seasonsCmd.ExecuteReader()) - { - while (seasonReader.Read()) - { - int seasonNumber = seasonReader.GetInt32(0); - bool monitored = seasonReader.GetBoolean(1); - - if (seasonNumber == 0) - { - monitored = false; - } - - seasons.Add(new { seasonNumber, monitored }); - } - } - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE Series SET Seasons = '{0}' WHERE Id = {1}", seasons.ToJson() , seriesId); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/021_drop_seasons_table.cs b/src/NzbDrone.Core/Datastore/Migration/021_drop_seasons_table.cs deleted file mode 100644 index d2527c755..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/021_drop_seasons_table.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(21)] - public class drop_seasons_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Table("Seasons"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/022_move_indexer_to_generic_provider.cs b/src/NzbDrone.Core/Datastore/Migration/022_move_indexer_to_generic_provider.cs deleted file mode 100644 index ea1908901..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/022_move_indexer_to_generic_provider.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(22)] - public class move_indexer_to_generic_provider : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Indexers").AddColumn("ConfigContract").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/023_add_config_contract_to_indexers.cs b/src/NzbDrone.Core/Datastore/Migration/023_add_config_contract_to_indexers.cs deleted file mode 100644 index 1a40a5a26..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/023_add_config_contract_to_indexers.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(23)] - public class add_config_contract_to_indexers : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Indexers").Set(new { ConfigContract = "NewznabSettings" }).Where(new { Implementation = "Newznab" }); - Update.Table("Indexers").Set(new { ConfigContract = "OmgwtfnzbsSettings" }).Where(new { Implementation = "Omgwtfnzbs" }); - Update.Table("Indexers").Set(new { ConfigContract = "NullConfig" }).Where(new { Implementation = "Wombles" }); - Update.Table("Indexers").Set(new { ConfigContract = "NullConfig" }).Where(new { Implementation = "Eztv" }); - - Delete.FromTable("Indexers").IsNull("ConfigContract"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/024_drop_tvdb_episodeid.cs b/src/NzbDrone.Core/Datastore/Migration/024_drop_tvdb_episodeid.cs deleted file mode 100644 index c723f462c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/024_drop_tvdb_episodeid.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(24)] - public class drop_tvdb_episodeid : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("TvDbEpisodeId").FromTable("Episodes"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/025_move_notification_to_generic_provider.cs b/src/NzbDrone.Core/Datastore/Migration/025_move_notification_to_generic_provider.cs deleted file mode 100644 index 1937f76eb..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/025_move_notification_to_generic_provider.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(25)] - public class move_notification_to_generic_provider : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Notifications").AddColumn("ConfigContract").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/026_add_config_contract_to_notifications.cs b/src/NzbDrone.Core/Datastore/Migration/026_add_config_contract_to_notifications.cs deleted file mode 100644 index 8eb24daae..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/026_add_config_contract_to_notifications.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(26)] - public class add_config_contract_to_notifications : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Notifications").Set(new { ConfigContract = "EmailSettings" }).Where(new { Implementation = "Email" }); - Update.Table("Notifications").Set(new { ConfigContract = "GrowlSettings" }).Where(new { Implementation = "Growl" }); - Update.Table("Notifications").Set(new { ConfigContract = "NotifyMyAndroidSettings" }).Where(new { Implementation = "NotifyMyAndroid" }); - Update.Table("Notifications").Set(new { ConfigContract = "PlexClientSettings" }).Where(new { Implementation = "PlexClient" }); - Update.Table("Notifications").Set(new { ConfigContract = "PlexServerSettings" }).Where(new { Implementation = "PlexServer" }); - Update.Table("Notifications").Set(new { ConfigContract = "ProwlSettings" }).Where(new { Implementation = "Prowl" }); - Update.Table("Notifications").Set(new { ConfigContract = "PushBulletSettings" }).Where(new { Implementation = "PushBullet" }); - Update.Table("Notifications").Set(new { ConfigContract = "PushoverSettings" }).Where(new { Implementation = "Pushover" }); - Update.Table("Notifications").Set(new { ConfigContract = "XbmcSettings" }).Where(new { Implementation = "Xbmc" }); - - Delete.FromTable("Notifications").IsNull("ConfigContract"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/027_fix_omgwtfnzbs.cs b/src/NzbDrone.Core/Datastore/Migration/027_fix_omgwtfnzbs.cs deleted file mode 100644 index d7b8b31fc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/027_fix_omgwtfnzbs.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(27)] - public class fix_omgwtfnzbs : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Indexers") - .Set(new {ConfigContract = "OmgwtfnzbsSettings"}) - .Where(new {Implementation = "Omgwtfnzbs"}); - - Update.Table("Indexers") - .Set(new {Settings = "{}"}) - .Where(new {Implementation = "Omgwtfnzbs", Settings = (string) null}); - - Update.Table("Indexers") - .Set(new { Settings = "{}" }) - .Where(new { Implementation = "Omgwtfnzbs", Settings = "" }); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/028_add_blacklist_table.cs b/src/NzbDrone.Core/Datastore/Migration/028_add_blacklist_table.cs deleted file mode 100644 index 0514c9689..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/028_add_blacklist_table.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(28)] - public class add_blacklist_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Blacklist") - .WithColumn("SeriesId").AsInt32() - .WithColumn("EpisodeIds").AsString() - .WithColumn("SourceTitle").AsString() - .WithColumn("Quality").AsString() - .WithColumn("Date").AsDateTime(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/029_add_formats_to_naming_config.cs b/src/NzbDrone.Core/Datastore/Migration/029_add_formats_to_naming_config.cs deleted file mode 100644 index 6d3dd897b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/029_add_formats_to_naming_config.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(29)] - public class add_formats_to_naming_config : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("StandardEpisodeFormat").AsString().Nullable(); - Alter.Table("NamingConfig").AddColumn("DailyEpisodeFormat").AsString().Nullable(); - - Execute.WithConnection(ConvertConfig); - } - - private void ConvertConfig(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand namingConfigCmd = conn.CreateCommand()) - { - namingConfigCmd.Transaction = tran; - namingConfigCmd.CommandText = @"SELECT * FROM NamingConfig LIMIT 1"; - using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader()) - { - var separatorIndex = namingConfigReader.GetOrdinal("Separator"); - var numberStyleIndex = namingConfigReader.GetOrdinal("NumberStyle"); - var includeSeriesTitleIndex = namingConfigReader.GetOrdinal("IncludeSeriesTitle"); - var includeEpisodeTitleIndex = namingConfigReader.GetOrdinal("IncludeEpisodeTitle"); - var includeQualityIndex = namingConfigReader.GetOrdinal("IncludeQuality"); - var replaceSpacesIndex = namingConfigReader.GetOrdinal("ReplaceSpaces"); - - while (namingConfigReader.Read()) - { - var separator = namingConfigReader.GetString(separatorIndex); - var numberStyle = namingConfigReader.GetInt32(numberStyleIndex); - var includeSeriesTitle = namingConfigReader.GetBoolean(includeSeriesTitleIndex); - var includeEpisodeTitle = namingConfigReader.GetBoolean(includeEpisodeTitleIndex); - var includeQuality = namingConfigReader.GetBoolean(includeQualityIndex); - var replaceSpaces = namingConfigReader.GetBoolean(replaceSpacesIndex); - - //Output settings - var seriesTitlePattern = ""; - var episodeTitlePattern = ""; - var dailyEpisodePattern = "{Air-Date}"; - var qualityFormat = " [{Quality Title}]"; - - if (includeSeriesTitle) - { - if (replaceSpaces) - { - seriesTitlePattern = "{Series.Title}"; - } - - else - { - seriesTitlePattern = "{Series Title}"; - } - - seriesTitlePattern += separator; - } - - if (includeEpisodeTitle) - { - episodeTitlePattern = separator; - - if (replaceSpaces) - { - episodeTitlePattern += "{Episode.Title}"; - } - - else - { - episodeTitlePattern += "{Episode Title}"; - } - } - - var standardEpisodeFormat = string.Format("{0}{1}{2}", seriesTitlePattern, - GetNumberStyle(numberStyle).Pattern, - episodeTitlePattern); - - var dailyEpisodeFormat = string.Format("{0}{1}{2}", seriesTitlePattern, - dailyEpisodePattern, - episodeTitlePattern); - - if (includeQuality) - { - if (replaceSpaces) - { - qualityFormat = ".[{Quality.Title}]"; - } - - standardEpisodeFormat += qualityFormat; - dailyEpisodeFormat += qualityFormat; - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE NamingConfig " + - "SET StandardEpisodeFormat = '{0}', " + - "DailyEpisodeFormat = '{1}'", - standardEpisodeFormat, - dailyEpisodeFormat); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private static readonly List NumberStyles = new List - { - new - { - Id = 0, - Name = "1x05", - Pattern = "{season}x{episode:00}", - EpisodeSeparator = "x" - - }, - new - { - Id = 1, - Name = "01x05", - Pattern = "{season:00}x{episode:00}", - EpisodeSeparator = "x" - }, - new - { - Id = 2, - Name = "S01E05", - Pattern = "S{season:00}E{episode:00}", - EpisodeSeparator = "E" - }, - new - { - Id = 3, - Name = "s01e05", - Pattern = "s{season:00}e{episode:00}", - EpisodeSeparator = "e" - } - }; - - private static dynamic GetNumberStyle(int id) - { - return NumberStyles.Single(s => s.Id == id); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/030_add_season_folder_format_to_naming_config.cs b/src/NzbDrone.Core/Datastore/Migration/030_add_season_folder_format_to_naming_config.cs deleted file mode 100644 index 185a53a19..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/030_add_season_folder_format_to_naming_config.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(30)] - public class add_season_folder_format_to_naming_config : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("SeasonFolderFormat").AsString().Nullable(); - Execute.WithConnection(ConvertConfig); - Execute.Sql("DELETE FROM Config WHERE [Key] = 'seasonfolderformat'"); - Execute.Sql("DELETE FROM Config WHERE [Key] = 'useseasonfolder'"); - } - - private void ConvertConfig(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand namingConfigCmd = conn.CreateCommand()) - { - namingConfigCmd.Transaction = tran; - namingConfigCmd.CommandText = @"SELECT [Value] FROM Config WHERE [Key] = 'seasonfolderformat'"; - var seasonFormat = "Season {season}"; - - using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader()) - { - while (namingConfigReader.Read()) - { - //only getting one column, so its index is 0 - seasonFormat = namingConfigReader.GetString(0); - - seasonFormat = seasonFormat.Replace("%sn", "{Series Title}") - .Replace("%s.n", "{Series.Title}") - .Replace("%s", "{season}") - .Replace("%0s", "{season:00}") - .Replace("%e", "{episode}") - .Replace("%0e", "{episode:00}"); - } - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE NamingConfig " + - "SET SeasonFolderFormat = '{0}'", - seasonFormat); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/031_delete_old_naming_config_columns.cs b/src/NzbDrone.Core/Datastore/Migration/031_delete_old_naming_config_columns.cs deleted file mode 100644 index 90c7571af..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/031_delete_old_naming_config_columns.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(31)] - public class delete_old_naming_config_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Separator") - .Column("NumberStyle") - .Column("IncludeSeriesTitle") - .Column("IncludeEpisodeTitle") - .Column("IncludeQuality") - .Column("ReplaceSpaces") - .FromTable("NamingConfig"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/032_set_default_release_group.cs b/src/NzbDrone.Core/Datastore/Migration/032_set_default_release_group.cs deleted file mode 100644 index 5ecc4e2c0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/032_set_default_release_group.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(32)] - public class set_default_release_group : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE EpisodeFiles SET ReleaseGroup = 'DRONE' WHERE ReleaseGroup IS NULL"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/033_add_api_key_to_pushover.cs b/src/NzbDrone.Core/Datastore/Migration/033_add_api_key_to_pushover.cs deleted file mode 100644 index 670d1f8ab..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/033_add_api_key_to_pushover.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(33)] - public class add_api_key_to_pushover : NzbDroneMigrationBase - { - private const string API_KEY = "yz9b4U215iR4vrKFRfjNXP24NMNPKJ"; - - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdatePushoverSettings); - } - - private void UpdatePushoverSettings(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand selectCommand = conn.CreateCommand()) - { - selectCommand.Transaction = tran; - selectCommand.CommandText = @"SELECT * FROM Notifications WHERE ConfigContract = 'PushoverSettings'"; - - using (IDataReader reader = selectCommand.ExecuteReader()) - { - while (reader.Read()) - { - var idIndex = reader.GetOrdinal("Id"); - var settingsIndex = reader.GetOrdinal("Settings"); - - var id = reader.GetInt32(idIndex); - var settings = Json.Deserialize(reader.GetString(settingsIndex)); - settings.ApiKey = API_KEY; - - //Set priority to high if its currently emergency - if (settings.Priority == 2) - { - settings.Priority = 1; - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE Notifications " + - "SET Settings = '{0}'" + - "WHERE Id = {1}", - settings.ToJson(), id - ); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private class PushoverSettingsForV33 - { - public string ApiKey { get; set; } - public string UserKey { get; set; } - public int Priority { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/034_remove_series_contraints.cs b/src/NzbDrone.Core/Datastore/Migration/034_remove_series_contraints.cs deleted file mode 100644 index 8eb08798a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/034_remove_series_contraints.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(34)] - public class remove_series_contraints : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series") - .AlterColumn("ImdbId").AsString().Nullable() - .AlterColumn("TitleSlug").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/035_add_series_folder_format_to_naming_config.cs b/src/NzbDrone.Core/Datastore/Migration/035_add_series_folder_format_to_naming_config.cs deleted file mode 100644 index 9423a54f0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/035_add_series_folder_format_to_naming_config.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(35)] - public class add_series_folder_format_to_naming_config : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("SeriesFolderFormat").AsString().Nullable(); - - Execute.Sql("UPDATE NamingConfig SET SeriesFolderFormat = '{Series Title}'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs b/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs deleted file mode 100644 index a84e661a8..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs +++ /dev/null @@ -1,129 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System.Data; -using System.Linq; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Profiles.Qualities; -using NzbDrone.Core.Qualities; -using System.Collections.Generic; -using NzbDrone.Core.Datastore.Converters; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(36)] - public class update_with_quality_converters : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - if (!Schema.Table("QualityProfiles").Column("Items").Exists()) - { - Alter.Table("QualityProfiles").AddColumn("Items").AsString().Nullable(); - } - - Execute.WithConnection(ConvertQualityProfiles); - Execute.WithConnection(ConvertQualityModels); - } - - private void ConvertQualityProfiles(IDbConnection conn, IDbTransaction tran) - { - var qualityProfileItemConverter = new EmbeddedDocumentConverter(new QualityIntConverter()); - - // Convert 'Allowed' column in QualityProfiles from Json List to Json List (int = Quality) - using (IDbCommand qualityProfileCmd = conn.CreateCommand()) - { - qualityProfileCmd.Transaction = tran; - qualityProfileCmd.CommandText = @"SELECT Id, Allowed FROM QualityProfiles"; - using (IDataReader qualityProfileReader = qualityProfileCmd.ExecuteReader()) - { - while (qualityProfileReader.Read()) - { - var id = qualityProfileReader.GetInt32(0); - var allowedJson = qualityProfileReader.GetString(1); - - var allowed = Json.Deserialize>(allowedJson); - - var items = Quality.DefaultQualityDefinitions.OrderBy(v => v.Weight).Select(v => new ProfileQualityItem { Quality = v.Quality, Allowed = allowed.Contains(v.Quality) }).ToList(); - - var allowedNewJson = qualityProfileItemConverter.ToDB(items); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE QualityProfiles SET Items = ? WHERE Id = ?"; - updateCmd.AddParameter(allowedNewJson); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private void ConvertQualityModels(IDbConnection conn, IDbTransaction tran) - { - // Converts the QualityModel JSON objects to their new format (only storing the QualityId instead of the entire object) - ConvertQualityModel(conn, tran, "Blacklist"); - ConvertQualityModel(conn, tran, "EpisodeFiles"); - ConvertQualityModel(conn, tran, "History"); - } - - private void ConvertQualityModel(IDbConnection conn, IDbTransaction tran, string tableName) - { - var qualityModelConverter = new EmbeddedDocumentConverter(new QualityIntConverter()); - - using (IDbCommand qualityModelCmd = conn.CreateCommand()) - { - qualityModelCmd.Transaction = tran; - qualityModelCmd.CommandText = @"SELECT Distinct Quality FROM " + tableName; - using (IDataReader qualityModelReader = qualityModelCmd.ExecuteReader()) - { - while (qualityModelReader.Read()) - { - var qualityJson = qualityModelReader.GetString(0); - - SourceQualityModel036 sourceQuality; - - if (!Json.TryDeserialize(qualityJson, out sourceQuality)) - { - continue; - } - - var qualityNewJson = qualityModelConverter.ToDB(new DestinationQualityModel036 - { - Quality = sourceQuality.Quality.Id, - Proper = sourceQuality.Proper - }); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Quality = ?"; - updateCmd.AddParameter(qualityNewJson); - updateCmd.AddParameter(qualityJson); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private class DestinationQualityModel036 - { - public int Quality { get; set; } - public bool Proper { get; set; } - } - - private class SourceQualityModel036 - { - public SourceQuality036 Quality { get; set; } - public bool Proper { get; set; } - } - - private class SourceQuality036 - { - public int Id { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs b/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs deleted file mode 100644 index 06ced4854..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs +++ /dev/null @@ -1,64 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System.Data; -using System.Linq; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(37)] - public class add_configurable_qualities : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Allowed").FromTable("QualityProfiles"); - - Alter.Column("Items").OnTable("QualityProfiles").AsString().NotNullable(); - - Create.TableForModel("QualityDefinitions") - .WithColumn("Quality").AsInt32().Unique() - .WithColumn("Title").AsString().Unique() - .WithColumn("Weight").AsInt32().Unique() - .WithColumn("MinSize").AsInt32() - .WithColumn("MaxSize").AsInt32(); - - Execute.WithConnection(ConvertQualities); - - Delete.Table("QualitySizes"); - } - - private void ConvertQualities(IDbConnection conn, IDbTransaction tran) - { - // Convert QualitySizes to a more generic QualityDefinitions table. - using (IDbCommand qualitySizeCmd = conn.CreateCommand()) - { - qualitySizeCmd.Transaction = tran; - qualitySizeCmd.CommandText = @"SELECT QualityId, MinSize, MaxSize FROM QualitySizes"; - using (IDataReader qualitySizeReader = qualitySizeCmd.ExecuteReader()) - { - while (qualitySizeReader.Read()) - { - var qualityId = qualitySizeReader.GetInt32(0); - var minSize = qualitySizeReader.GetInt32(1); - var maxSize = qualitySizeReader.GetInt32(2); - - var defaultConfig = Quality.DefaultQualityDefinitions.Single(p => (int)p.Quality == qualityId); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "INSERT INTO QualityDefinitions (Quality, Title, Weight, MinSize, MaxSize) VALUES (?, ?, ?, ?, ?)"; - updateCmd.AddParameter(qualityId); - updateCmd.AddParameter(defaultConfig.Title); - updateCmd.AddParameter(defaultConfig.Weight); - updateCmd.AddParameter(minSize); - updateCmd.AddParameter(maxSize); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/038_add_on_upgrade_to_notifications.cs b/src/NzbDrone.Core/Datastore/Migration/038_add_on_upgrade_to_notifications.cs deleted file mode 100644 index f5cae2ba0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/038_add_on_upgrade_to_notifications.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(38)] - public class add_on_upgrade_to_notifications : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Notifications").AddColumn("OnUpgrade").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Notifications SET OnUpgrade = OnDownload"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/039_add_metadata_tables.cs b/src/NzbDrone.Core/Datastore/Migration/039_add_metadata_tables.cs deleted file mode 100644 index fdc7f2545..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/039_add_metadata_tables.cs +++ /dev/null @@ -1,28 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(39)] - public class add_metadata_tables : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Metadata") - .WithColumn("Enable").AsBoolean().NotNullable() - .WithColumn("Name").AsString().NotNullable() - .WithColumn("Implementation").AsString().NotNullable() - .WithColumn("Settings").AsString().NotNullable() - .WithColumn("ConfigContract").AsString().NotNullable(); - - Create.TableForModel("MetadataFiles") - .WithColumn("SeriesId").AsInt32().NotNullable() - .WithColumn("Consumer").AsString().NotNullable() - .WithColumn("Type").AsInt32().NotNullable() - .WithColumn("RelativePath").AsString().NotNullable() - .WithColumn("LastUpdated").AsDateTime().NotNullable() - .WithColumn("SeasonNumber").AsInt32().Nullable() - .WithColumn("EpisodeFileId").AsInt32().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/040_add_metadata_to_episodes_and_series.cs b/src/NzbDrone.Core/Datastore/Migration/040_add_metadata_to_episodes_and_series.cs deleted file mode 100644 index bf8119831..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/040_add_metadata_to_episodes_and_series.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(40)] - public class add_metadata_to_episodes_and_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series") - .AddColumn("Actors").AsString().Nullable() - .AddColumn("Ratings").AsString().Nullable() - .AddColumn("Genres").AsString().Nullable() - .AddColumn("Certification").AsString().Nullable(); - - Alter.Table("Episodes") - .AddColumn("Ratings").AsString().Nullable() - .AddColumn("Images").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/041_fix_xbmc_season_images_metadata.cs b/src/NzbDrone.Core/Datastore/Migration/041_fix_xbmc_season_images_metadata.cs deleted file mode 100644 index 25cbc8ed4..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/041_fix_xbmc_season_images_metadata.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(41)] - public class fix_xbmc_season_images_metadata : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE MetadataFiles SET Type = 4 WHERE Consumer = 'XbmcMetadata' AND SeasonNumber IS NOT NULL"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/042_add_download_clients_table.cs b/src/NzbDrone.Core/Datastore/Migration/042_add_download_clients_table.cs deleted file mode 100644 index 08cf7622b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/042_add_download_clients_table.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(42)] - public class add_download_clients_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("DownloadClients") - .WithColumn("Enable").AsBoolean().NotNullable() - .WithColumn("Name").AsString().NotNullable() - .WithColumn("Implementation").AsString().NotNullable() - .WithColumn("Settings").AsString().NotNullable() - .WithColumn("ConfigContract").AsString().NotNullable() - .WithColumn("Protocol").AsInt32().NotNullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/043_convert_config_to_download_clients.cs b/src/NzbDrone.Core/Datastore/Migration/043_convert_config_to_download_clients.cs deleted file mode 100644 index 505962776..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/043_convert_config_to_download_clients.cs +++ /dev/null @@ -1,197 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(43)] - public class convert_config_to_download_clients : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertToThingyProvder); - } - - private void ConvertToThingyProvder(IDbConnection conn, IDbTransaction tran) - { - var config = new Dictionary(); - - using (IDbCommand configCmd = conn.CreateCommand()) - { - configCmd.Transaction = tran; - configCmd.CommandText = @"SELECT * FROM Config"; - using (IDataReader configReader = configCmd.ExecuteReader()) - { - var keyIndex = configReader.GetOrdinal("Key"); - var valueIndex = configReader.GetOrdinal("Value"); - - while (configReader.Read()) - { - var key = configReader.GetString(keyIndex); - var value = configReader.GetString(valueIndex); - - config.Add(key.ToLowerInvariant(), value); - } - } - } - - var client = GetConfigValue(config, "DownloadClient", ""); - - if (string.IsNullOrWhiteSpace(client)) - { - return; - } - - if (client.Equals("sabnzbd", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new ClientSettingsForMigration - { - Host = GetConfigValue(config, "SabHost", "localhost"), - Port = GetConfigValue(config, "SabPort", 8080), - ApiKey = GetConfigValue(config, "SabApiKey", ""), - Username = GetConfigValue(config, "SabUsername", ""), - Password = GetConfigValue(config, "SabPassword", ""), - TvCategory = GetConfigValue(config, "SabTvCategory", "tv"), - RecentTvPriority = GetSabnzbdPriority(GetConfigValue(config, "NzbgetRecentTvPriority", "Default")), - OlderTvPriority = GetSabnzbdPriority(GetConfigValue(config, "NzbgetOlderTvPriority", "Default")), - UseSsl = GetConfigValue(config, "SabUseSsl", false) - }; - - AddDownloadClient(conn, tran, "Sabnzbd", "Sabnzbd", settings.ToJson(), "SabnzbdSettings", 1); - } - - else if (client.Equals("nzbget", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new ClientSettingsForMigration - { - Host = GetConfigValue(config, "NzbGetHost", "localhost"), - Port = GetConfigValue(config, "NzbgetPort", 6789), - Username = GetConfigValue(config, "NzbgetUsername", "nzbget"), - Password = GetConfigValue(config, "NzbgetPassword", ""), - TvCategory = GetConfigValue(config, "NzbgetTvCategory", "tv"), - RecentTvPriority = GetNzbgetPriority(GetConfigValue(config, "NzbgetRecentTvPriority", "Normal")), - OlderTvPriority = GetNzbgetPriority(GetConfigValue(config, "NzbgetOlderTvPriority", "Normal")), - }; - - AddDownloadClient(conn, tran, "Nzbget", "Nzbget", settings.ToJson(), "NzbgetSettings", 1); - } - - else if (client.Equals("pneumatic", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new FolderSettingsForMigration - { - Folder = GetConfigValue(config, "PneumaticFolder", "") - }; - - AddDownloadClient(conn, tran, "Pneumatic", "Pneumatic", settings.ToJson(), "FolderSettings", 1); - } - - else if (client.Equals("blackhole", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new FolderSettingsForMigration - { - Folder = GetConfigValue(config, "BlackholeFolder", "") - }; - - AddDownloadClient(conn, tran, "Blackhole", "Blackhole", settings.ToJson(), "FolderSettings", 1); - } - - DeleteOldConfigValues(conn, tran); - } - - private T GetConfigValue(Dictionary config, string key, T defaultValue) - { - key = key.ToLowerInvariant(); - - if (config.ContainsKey(key)) - { - return (T) Convert.ChangeType(config[key], typeof (T)); - } - - return defaultValue; - } - - private void AddDownloadClient(IDbConnection conn, IDbTransaction tran, string name, string implementation, string settings, - string configContract, int protocol) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("INSERT INTO DownloadClients (Enable, Name, Implementation, Settings, ConfigContract, Protocol) VALUES (1, ?, ?, ?, ?, ?)"); - updateCmd.AddParameter(name); - updateCmd.AddParameter(implementation); - updateCmd.AddParameter(settings); - updateCmd.AddParameter(configContract); - updateCmd.AddParameter(protocol); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - - private void DeleteOldConfigValues(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = "DELETE FROM Config WHERE [KEY] IN ('nzbgetusername', 'nzbgetpassword', 'nzbgethost', 'nzbgetport', " + - "'nzbgettvcategory', 'nzbgetrecenttvpriority', 'nzbgetoldertvpriority', 'sabhost', 'sabport', " + - "'sabapikey', 'sabusername', 'sabpassword', 'sabtvcategory', 'sabrecenttvpriority', " + - "'saboldertvpriority', 'sabusessl', 'downloadclient', 'blackholefolder', 'pneumaticfolder')"; - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - - private int GetSabnzbdPriority(string priority) - { - return (int)Enum.Parse(typeof(SabnzbdPriorityForMigration), priority, true); - } - - private int GetNzbgetPriority(string priority) - { - return (int)Enum.Parse(typeof(NzbGetPriorityForMigration), priority, true); - } - - private class ClientSettingsForMigration - { - public string Host { get; set; } - public int Port { get; set; } - public string ApiKey { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } - - private class FolderSettingsForMigration - { - public string Folder { get; set; } - } - - private enum SabnzbdPriorityForMigration - { - Default = -100, - Paused = -2, - Low = -1, - Normal = 0, - High = 1, - Force = 2 - } - - private enum NzbGetPriorityForMigration - { - VeryLow = -100, - Low = -50, - Normal = 0, - High = 50, - VeryHigh = 100 - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/044_fix_xbmc_episode_metadata.cs b/src/NzbDrone.Core/Datastore/Migration/044_fix_xbmc_episode_metadata.cs deleted file mode 100644 index 0c645259b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/044_fix_xbmc_episode_metadata.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(44)] - public class fix_xbmc_episode_metadata : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - //Convert Episode Metadata to proper type - Execute.Sql("UPDATE MetadataFiles " + - "SET Type = 2 " + - "WHERE Consumer = 'XbmcMetadata' " + - "AND EpisodeFileId IS NOT NULL " + - "AND Type = 4 " + - "AND RelativePath LIKE '%.nfo'"); - - //Convert Episode Images to proper type - Execute.Sql("UPDATE MetadataFiles " + - "SET Type = 5 " + - "WHERE Consumer = 'XbmcMetadata' " + - "AND EpisodeFileId IS NOT NULL " + - "AND Type = 4"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/045_add_indexes.cs b/src/NzbDrone.Core/Datastore/Migration/045_add_indexes.cs deleted file mode 100644 index 4ac4e0034..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/045_add_indexes.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(45)] - public class add_indexes : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Index().OnTable("Blacklist").OnColumn("SeriesId"); - - Create.Index().OnTable("EpisodeFiles").OnColumn("SeriesId"); - - Create.Index().OnTable("Episodes").OnColumn("EpisodeFileId"); - Create.Index().OnTable("Episodes").OnColumn("SeriesId"); - - Create.Index().OnTable("History").OnColumn("EpisodeId"); - Create.Index().OnTable("History").OnColumn("Date"); - - Create.Index().OnTable("Series").OnColumn("Path"); - Create.Index().OnTable("Series").OnColumn("CleanTitle"); - Create.Index().OnTable("Series").OnColumn("TvRageId"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/046_fix_nzb_su_url.cs b/src/NzbDrone.Core/Datastore/Migration/046_fix_nzb_su_url.cs deleted file mode 100644 index 6d5496c0a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/046_fix_nzb_su_url.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(46)] - public class fix_nzb_su_url : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET Settings = replace(Settings, '//nzb.su', '//api.nzb.su')" + - "WHERE Implementation = 'Newznab'" + - "AND Settings LIKE '%//nzb.su%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/047_add_published_date_blacklist_column.cs b/src/NzbDrone.Core/Datastore/Migration/047_add_published_date_blacklist_column.cs deleted file mode 100644 index a7bbc9b9b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/047_add_published_date_blacklist_column.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(47)] - public class add_temporary_blacklist_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Blacklist").AddColumn("PublishedDate").AsDateTime().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/048_add_title_to_scenemappings.cs b/src/NzbDrone.Core/Datastore/Migration/048_add_title_to_scenemappings.cs deleted file mode 100644 index 4a2e94bbf..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/048_add_title_to_scenemappings.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Core.Datastore.Migration.Framework; -using FluentMigrator; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(48)] - public class add_title_to_scenemappings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("SceneMappings").AddColumn("Title").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/049_fix_dognzb_url.cs b/src/NzbDrone.Core/Datastore/Migration/049_fix_dognzb_url.cs deleted file mode 100644 index ebbe8d8c0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/049_fix_dognzb_url.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(49)] - public class fix_dognzb_url : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET Settings = replace(Settings, '//dognzb.cr', '//api.dognzb.cr')" + - "WHERE Implementation = 'Newznab'" + - "AND Settings LIKE '%//dognzb.cr%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/050_add_hash_to_metadata_files.cs b/src/NzbDrone.Core/Datastore/Migration/050_add_hash_to_metadata_files.cs deleted file mode 100644 index 8986a7fba..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/050_add_hash_to_metadata_files.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Core.Datastore.Migration.Framework; -using FluentMigrator; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(50)] - public class add_hash_to_metadata_files : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("MetadataFiles").AddColumn("Hash").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs b/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs deleted file mode 100644 index 549b92e59..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs +++ /dev/null @@ -1,243 +0,0 @@ -using System; -using System.Data; -using System.Linq; -using System.Collections.Generic; -using FluentMigrator; -using Newtonsoft.Json; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; -using System.IO; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(51)] - public class download_client_import : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(EnableCompletedDownloadHandlingForNewUsers); - - Execute.WithConnection(ConvertFolderSettings); - - Execute.WithConnection(AssociateImportedHistoryItems); - } - - private void EnableCompletedDownloadHandlingForNewUsers(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'downloadedepisodesfolder'"; - - var result = cmd.ExecuteScalar(); - - if (result == null) - { - cmd.CommandText = @"INSERT INTO Config (Key, Value) VALUES ('enablecompleteddownloadhandling', 'True')"; - cmd.ExecuteNonQuery(); - } - } - } - - private void ConvertFolderSettings(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand downloadClientsCmd = conn.CreateCommand()) - { - downloadClientsCmd.Transaction = tran; - downloadClientsCmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'downloadedepisodesfolder'"; - var downloadedEpisodesFolder = downloadClientsCmd.ExecuteScalar() as string; - - downloadClientsCmd.Transaction = tran; - downloadClientsCmd.CommandText = @"SELECT Id, Implementation, Settings, ConfigContract FROM DownloadClients WHERE ConfigContract = 'FolderSettings'"; - using (IDataReader downloadClientReader = downloadClientsCmd.ExecuteReader()) - { - while (downloadClientReader.Read()) - { - var id = downloadClientReader.GetInt32(0); - var implementation = downloadClientReader.GetString(1); - var settings = downloadClientReader.GetString(2); - var configContract = downloadClientReader.GetString(3); - - var settingsJson = JsonConvert.DeserializeObject(settings) as Newtonsoft.Json.Linq.JObject; - - if (implementation == "Blackhole") - { - var newSettings = new - { - NzbFolder = settingsJson.Value("folder"), - WatchFolder = downloadedEpisodesFolder - }.ToJson(); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Implementation = ?, Settings = ?, ConfigContract = ? WHERE Id = ?"; - updateCmd.AddParameter("UsenetBlackhole"); - updateCmd.AddParameter(newSettings); - updateCmd.AddParameter("UsenetBlackholeSettings"); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - else if (implementation == "Pneumatic") - { - var newSettings = new - { - NzbFolder = settingsJson.Value("folder") - }.ToJson(); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Settings = ?, ConfigContract = ? WHERE Id = ?"; - updateCmd.AddParameter(newSettings); - updateCmd.AddParameter("PneumaticSettings"); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - else - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "DELETE FROM DownloadClients WHERE Id = ?"; - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - private sealed class MigrationHistoryItem - { - public int Id { get; set; } - public int EpisodeId { get; set; } - public int SeriesId { get; set; } - public string SourceTitle { get; set; } - public DateTime Date { get; set; } - public Dictionary Data { get; set; } - public MigrationHistoryEventType EventType { get; set; } - } - - private enum MigrationHistoryEventType - { - Unknown = 0, - Grabbed = 1, - SeriesFolderImported = 2, - DownloadFolderImported = 3, - DownloadFailed = 4 - } - - private void AssociateImportedHistoryItems(IDbConnection conn, IDbTransaction tran) - { - var historyItems = new List(); - - using (IDbCommand historyCmd = conn.CreateCommand()) - { - historyCmd.Transaction = tran; - historyCmd.CommandText = @"SELECT Id, EpisodeId, SeriesId, SourceTitle, Date, Data, EventType FROM History WHERE EventType NOT NULL"; - using (IDataReader historyRead = historyCmd.ExecuteReader()) - { - while (historyRead.Read()) - { - historyItems.Add(new MigrationHistoryItem - { - Id = historyRead.GetInt32(0), - EpisodeId = historyRead.GetInt32(1), - SeriesId = historyRead.GetInt32(2), - SourceTitle = historyRead.GetString(3), - Date = historyRead.GetDateTime(4), - Data = Json.Deserialize>(historyRead.GetString(5)), - EventType = (MigrationHistoryEventType)historyRead.GetInt32(6) - }); - } - } - } - - var numHistoryItemsNotAssociated = historyItems.Count(v => v.EventType == MigrationHistoryEventType.DownloadFolderImported && - v.Data.GetValueOrDefault("downloadClientId") == null); - - if (numHistoryItemsNotAssociated == 0) - { - return; - } - - var historyItemsToAssociate = new Dictionary(); - - var historyItemsLookup = historyItems.ToLookup(v => v.EpisodeId); - - foreach (var historyItemGroup in historyItemsLookup) - { - var list = historyItemGroup.ToList(); - - for (int i = 0; i < list.Count - 1; i++) - { - var grabbedEvent = list[i]; - if (grabbedEvent.EventType != MigrationHistoryEventType.Grabbed) continue; - if (grabbedEvent.Data.GetValueOrDefault("downloadClient") == null || grabbedEvent.Data.GetValueOrDefault("downloadClientId") == null) continue; - - // Check if it is already associated with a failed/imported event. - int j; - for (j = i + 1; j < list.Count;j++) - { - if (list[j].EventType != MigrationHistoryEventType.DownloadFolderImported && - list[j].EventType != MigrationHistoryEventType.DownloadFailed) - { - continue; - } - - if (list[j].Data.ContainsKey("downloadClient") && list[j].Data["downloadClient"] == grabbedEvent.Data["downloadClient"] && - list[j].Data.ContainsKey("downloadClientId") && list[j].Data["downloadClientId"] == grabbedEvent.Data["downloadClientId"]) - { - break; - } - } - - if (j != list.Count) - { - list.RemoveAt(j); - list.RemoveAt(i--); - continue; - } - - var importedEvent = list[i + 1]; - if (importedEvent.EventType != MigrationHistoryEventType.DownloadFolderImported) continue; - - var droppedPath = importedEvent.Data.GetValueOrDefault("droppedPath"); - if (droppedPath != null && new FileInfo(droppedPath).Directory.Name == grabbedEvent.SourceTitle) - { - historyItemsToAssociate[importedEvent] = grabbedEvent; - - list.RemoveAt(i + 1); - list.RemoveAt(i--); - } - } - } - - foreach (var pair in historyItemsToAssociate) - { - using (IDbCommand updateHistoryCmd = conn.CreateCommand()) - { - pair.Key.Data["downloadClient"] = pair.Value.Data["downloadClient"]; - pair.Key.Data["downloadClientId"] = pair.Value.Data["downloadClientId"]; - - updateHistoryCmd.Transaction = tran; - updateHistoryCmd.CommandText = "UPDATE History SET Data = ? WHERE Id = ?"; - updateHistoryCmd.AddParameter(pair.Key.Data.ToJson()); - updateHistoryCmd.AddParameter(pair.Key.Id); - - updateHistoryCmd.ExecuteNonQuery(); - } - } - - _logger.Info("Updated old History items. {0}/{1} old ImportedEvents were associated with GrabbedEvents.", historyItemsToAssociate.Count, numHistoryItemsNotAssociated); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/052_add_columns_for_anime.cs b/src/NzbDrone.Core/Datastore/Migration/052_add_columns_for_anime.cs deleted file mode 100644 index e781ca010..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/052_add_columns_for_anime.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NzbDrone.Core.Datastore.Migration.Framework; -using FluentMigrator; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(52)] - public class add_columns_for_anime : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - //Support XEM names - Alter.Table("SceneMappings").AddColumn("Type").AsString().Nullable(); - Execute.Sql("DELETE FROM SceneMappings"); - - //Add AnimeEpisodeFormat (set to Stardard Episode format for now) - Alter.Table("NamingConfig").AddColumn("AnimeEpisodeFormat").AsString().Nullable(); - Execute.Sql("UPDATE NamingConfig SET AnimeEpisodeFormat = StandardEpisodeFormat"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/053_add_series_sorttitle.cs b/src/NzbDrone.Core/Datastore/Migration/053_add_series_sorttitle.cs deleted file mode 100644 index 46e1b8ce3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/053_add_series_sorttitle.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(53)] - public class add_series_sorttitle : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Column("SortTitle").OnTable("Series").AsString().Nullable(); - - Execute.WithConnection(SetSortTitles); - } - - private void SetSortTitles(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getSeriesCmd = conn.CreateCommand()) - { - getSeriesCmd.Transaction = tran; - getSeriesCmd.CommandText = @"SELECT Id, Title FROM Series"; - using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) - { - while (seriesReader.Read()) - { - var id = seriesReader.GetInt32(0); - var title = seriesReader.GetString(1); - - var sortTitle = Parser.Parser.NormalizeTitle(title).ToLower(); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE Series SET SortTitle = ? WHERE Id = ?"; - updateCmd.AddParameter(sortTitle); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/054_rename_profiles.cs b/src/NzbDrone.Core/Datastore/Migration/054_rename_profiles.cs deleted file mode 100644 index e665c14a4..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/054_rename_profiles.cs +++ /dev/null @@ -1,31 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(54)] - public class rename_profiles : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Rename.Table("QualityProfiles").To("Profiles"); - - Alter.Table("Profiles").AddColumn("Language").AsInt32().Nullable(); - Alter.Table("Profiles").AddColumn("GrabDelay").AsInt32().Nullable(); - Alter.Table("Profiles").AddColumn("GrabDelayMode").AsInt32().Nullable(); - Execute.Sql("UPDATE Profiles SET Language = 1, GrabDelay = 0, GrabDelayMode = 0"); - - //Rename QualityProfileId in Series - Alter.Table("Series").AddColumn("ProfileId").AsInt32().Nullable(); - Execute.Sql("UPDATE Series SET ProfileId = QualityProfileId"); - - //Add HeldReleases - Create.TableForModel("PendingReleases") - .WithColumn("SeriesId").AsInt32() - .WithColumn("Title").AsString() - .WithColumn("Added").AsDateTime() - .WithColumn("ParsedEpisodeInfo").AsString() - .WithColumn("Release").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/055_drop_old_profile_columns.cs b/src/NzbDrone.Core/Datastore/Migration/055_drop_old_profile_columns.cs deleted file mode 100644 index 3f13f5e84..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/055_drop_old_profile_columns.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(55)] - public class drop_old_profile_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("QualityProfileId").FromTable("Series"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/056_add_mediainfo_to_episodefile.cs b/src/NzbDrone.Core/Datastore/Migration/056_add_mediainfo_to_episodefile.cs deleted file mode 100644 index 42ad68493..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/056_add_mediainfo_to_episodefile.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(56)] - public class add_mediainfo_to_episodefile : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("EpisodeFiles").AddColumn("MediaInfo").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/057_convert_episode_file_path_to_relative.cs b/src/NzbDrone.Core/Datastore/Migration/057_convert_episode_file_path_to_relative.cs deleted file mode 100644 index a1bf307fd..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/057_convert_episode_file_path_to_relative.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Data; -using System.IO; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(57)] - public class convert_episode_file_path_to_relative : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Column("RelativePath").OnTable("EpisodeFiles").AsString().Nullable(); - - //TODO: Add unique contraint for series ID and Relative Path - //TODO: Warn if multiple series share the same path - - Execute.WithConnection(UpdateRelativePaths); - } - - private void UpdateRelativePaths(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getSeriesCmd = conn.CreateCommand()) - { - getSeriesCmd.Transaction = tran; - getSeriesCmd.CommandText = @"SELECT Id, Path FROM Series"; - using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) - { - while (seriesReader.Read()) - { - var seriesId = seriesReader.GetInt32(0); - var seriesPath = seriesReader.GetString(1) + Path.DirectorySeparatorChar; - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE EpisodeFiles SET RelativePath = REPLACE(Path, ?, '') WHERE SeriesId = ?"; - updateCmd.AddParameter(seriesPath); - updateCmd.AddParameter(seriesId); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/058_drop_epsiode_file_path.cs b/src/NzbDrone.Core/Datastore/Migration/058_drop_epsiode_file_path.cs deleted file mode 100644 index d2bfbcfd9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/058_drop_epsiode_file_path.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(58)] - public class drop_episode_file_path : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Path").FromTable("EpisodeFiles"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/059_add_enable_options_to_indexers.cs b/src/NzbDrone.Core/Datastore/Migration/059_add_enable_options_to_indexers.cs deleted file mode 100644 index 0905578c5..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/059_add_enable_options_to_indexers.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(59)] - public class add_enable_options_to_indexers : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Indexers") - .AddColumn("EnableRss").AsBoolean().Nullable() - .AddColumn("EnableSearch").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Indexers SET EnableRss = Enable, EnableSearch = Enable"); - Execute.Sql("UPDATE Indexers SET EnableSearch = 0 WHERE Implementation = 'Wombles'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/060_remove_enable_from_indexers.cs b/src/NzbDrone.Core/Datastore/Migration/060_remove_enable_from_indexers.cs deleted file mode 100644 index 05376c1d2..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/060_remove_enable_from_indexers.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(60)] - public class remove_enable_from_indexers : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Enable").FromTable("Indexers"); - Delete.Column("Protocol").FromTable("DownloadClients"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/061_clear_bad_scene_names.cs b/src/NzbDrone.Core/Datastore/Migration/061_clear_bad_scene_names.cs deleted file mode 100644 index 4bc2275dc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/061_clear_bad_scene_names.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(61)] - public class clear_bad_scene_names : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE [EpisodeFiles] " + - "SET ReleaseGroup = NULL , SceneName = NULL " + - "WHERE " + - " ReleaseGroup IS NULL " + - " OR SceneName IS NULL " + - " OR ReleaseGroup =='DRONE' " + - " OR LENGTH(SceneName) <10 " + - " OR LENGTH(ReleaseGroup) > 20 " + - " OR SceneName NOT LIKE '%.%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/062_convert_quality_models.cs b/src/NzbDrone.Core/Datastore/Migration/062_convert_quality_models.cs deleted file mode 100644 index cc9cea68a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/062_convert_quality_models.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(62)] - public class convert_quality_models : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertQualityModels); - } - - private void ConvertQualityModels(IDbConnection conn, IDbTransaction tran) - { - ConvertQualityModelsOnTable(conn, tran, "EpisodeFiles"); - ConvertQualityModelsOnTable(conn, tran, "Blacklist"); - ConvertQualityModelsOnTable(conn, tran, "History"); - } - - private void ConvertQualityModelsOnTable(IDbConnection conn, IDbTransaction tran, string tableName) - { - var qualitiesToUpdate = new Dictionary(); - - using (IDbCommand qualityModelCmd = conn.CreateCommand()) - { - qualityModelCmd.Transaction = tran; - qualityModelCmd.CommandText = @"SELECT Distinct Quality FROM " + tableName; - - using (IDataReader qualityModelReader = qualityModelCmd.ExecuteReader()) - { - while (qualityModelReader.Read()) - { - var qualityJson = qualityModelReader.GetString(0); - - LegacyQualityModel062 quality; - - if (!Json.TryDeserialize(qualityJson, out quality)) - { - continue; - } - - var newQualityModel = new QualityModel062 { Quality = quality.Quality, Revision = new Revision() }; - if (quality.Proper) - newQualityModel.Revision.Version = 2; - var newQualityJson = newQualityModel.ToJson(); - - qualitiesToUpdate.Add(qualityJson, newQualityJson); - } - } - } - - foreach (var quality in qualitiesToUpdate) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Quality = ?"; - updateCmd.AddParameter(quality.Value); - updateCmd.AddParameter(quality.Key); - - updateCmd.ExecuteNonQuery(); - } - } - } - - private class LegacyQualityModel062 - { - public int Quality { get; set; } - public bool Proper { get; set; } - } - - private class QualityModel062 - { - public int Quality { get; set; } - public Revision Revision { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/063_add_remotepathmappings.cs b/src/NzbDrone.Core/Datastore/Migration/063_add_remotepathmappings.cs deleted file mode 100644 index 2f8c6b755..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/063_add_remotepathmappings.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(63)] - public class add_remotepathmappings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("RemotePathMappings") - .WithColumn("Host").AsString() - .WithColumn("RemotePath").AsString() - .WithColumn("LocalPath").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/064_add_remove_method_from_logs.cs b/src/NzbDrone.Core/Datastore/Migration/064_add_remove_method_from_logs.cs deleted file mode 100644 index 2fd04ea97..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/064_add_remove_method_from_logs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(64)] - public class remove_method_from_logs : NzbDroneMigrationBase - { - protected override void LogDbUpgrade() - { - Delete.Column("Method").FromTable("Logs"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/065_make_scene_numbering_nullable.cs b/src/NzbDrone.Core/Datastore/Migration/065_make_scene_numbering_nullable.cs deleted file mode 100644 index 7936f04dd..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/065_make_scene_numbering_nullable.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(65)] - public class make_scene_numbering_nullable : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Episodes SET AbsoluteEpisodeNumber = NULL WHERE AbsoluteEpisodeNumber = 0"); - Execute.Sql("UPDATE Episodes SET SceneAbsoluteEpisodeNumber = NULL WHERE SceneAbsoluteEpisodeNumber = 0"); - Execute.Sql("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL WHERE SceneSeasonNumber = 0 AND SceneEpisodeNumber = 0"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/066_add_tags.cs b/src/NzbDrone.Core/Datastore/Migration/066_add_tags.cs deleted file mode 100644 index 7a0c09838..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/066_add_tags.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(66)] - public class add_tags : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Tags") - .WithColumn("Label").AsString().NotNullable(); - - Alter.Table("Series") - .AddColumn("Tags").AsString().Nullable(); - - Alter.Table("Notifications") - .AddColumn("Tags").AsString().Nullable(); - - Execute.Sql("UPDATE Series SET Tags = '[]'"); - Execute.Sql("UPDATE Notifications SET Tags = '[]'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/067_add_added_to_series.cs b/src/NzbDrone.Core/Datastore/Migration/067_add_added_to_series.cs deleted file mode 100644 index cb0923e18..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/067_add_added_to_series.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(67)] - public class add_added_to_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("Added").AsDateTime().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/068_add_release_restrictions.cs b/src/NzbDrone.Core/Datastore/Migration/068_add_release_restrictions.cs deleted file mode 100644 index a7cc93e0c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/068_add_release_restrictions.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(68)] - public class add_release_restrictions : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Restrictions") - .WithColumn("Required").AsString().Nullable() - .WithColumn("Preferred").AsString().Nullable() - .WithColumn("Ignored").AsString().Nullable() - .WithColumn("Tags").AsString().NotNullable(); - - Execute.WithConnection(ConvertRestrictions); - Execute.Sql("DELETE FROM Config WHERE [Key] = 'releaserestrictions'"); - } - - private void ConvertRestrictions(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getRestictionsCmd = conn.CreateCommand()) - { - getRestictionsCmd.Transaction = tran; - getRestictionsCmd.CommandText = @"SELECT [Value] FROM Config WHERE [Key] = 'releaserestrictions'"; - - using (IDataReader configReader = getRestictionsCmd.ExecuteReader()) - { - while (configReader.Read()) - { - var restrictions = configReader.GetString(0); - restrictions = restrictions.Replace("\n", ","); - - using (IDbCommand insertCmd = conn.CreateCommand()) - { - insertCmd.Transaction = tran; - insertCmd.CommandText = "INSERT INTO Restrictions (Ignored, Tags) VALUES (?, '[]')"; - insertCmd.AddParameter(restrictions); - - insertCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/069_quality_proper.cs b/src/NzbDrone.Core/Datastore/Migration/069_quality_proper.cs deleted file mode 100644 index 9db5f2955..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/069_quality_proper.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Data; -using System.Linq; -using System.Text.RegularExpressions; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(69)] - public class quality_proper : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertQualityTitle); - } - - private static readonly Regex QualityTitleRegex = new Regex(@"\{(?[- ._\[(]*)(?(?:quality)(?:(?[- ._]+)(?:title))?)(?[- ._)\]]*)\}", - RegexOptions.Compiled | RegexOptions.IgnoreCase); - - private void ConvertQualityTitle(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand namingConfigCmd = conn.CreateCommand()) - { - namingConfigCmd.Transaction = tran; - namingConfigCmd.CommandText = @"SELECT StandardEpisodeFormat, DailyEpisodeFormat, AnimeEpisodeFormat FROM NamingConfig LIMIT 1"; - - using (IDataReader configReader = namingConfigCmd.ExecuteReader()) - { - while (configReader.Read()) - { - var currentStandard = configReader.GetString(0); - var currentDaily = configReader.GetString(1); - var currentAnime = configReader.GetString(2); - - var newStandard = GetNewFormat(currentStandard); - var newDaily = GetNewFormat(currentDaily); - var newAnime = GetNewFormat(currentAnime); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - - updateCmd.CommandText = "UPDATE NamingConfig SET StandardEpisodeFormat = ?, DailyEpisodeFormat = ?, AnimeEpisodeFormat = ?"; - updateCmd.AddParameter(newStandard); - updateCmd.AddParameter(newDaily); - updateCmd.AddParameter(newAnime); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private string GetNewFormat(string currentFormat) - { - var matches = QualityTitleRegex.Matches(currentFormat); - var result = currentFormat; - - foreach (Match match in matches) - { - var tokenMatch = GetTokenMatch(match); - var qualityFullToken = string.Format("Quality{0}Full", tokenMatch.Separator); ; - - if (tokenMatch.Token.All(t => !char.IsLetter(t) || char.IsLower(t))) - { - qualityFullToken = string.Format("quality{0}full", tokenMatch.Separator); - } - else if (tokenMatch.Token.All(t => !char.IsLetter(t) || char.IsUpper(t))) - { - qualityFullToken = string.Format("QUALITY{0}FULL", tokenMatch.Separator); - } - - result = result.Replace(match.Groups["token"].Value, qualityFullToken); - } - - return result; - } - - private TokenMatch69 GetTokenMatch(Match match) - { - return new TokenMatch69 - { - Prefix = match.Groups["prefix"].Value, - Token = match.Groups["token"].Value, - Separator = match.Groups["separator"].Value, - Suffix = match.Groups["suffix"].Value, - }; - } - - private class TokenMatch69 - { - public string Prefix { get; set; } - public string Token { get; set; } - public string Separator { get; set; } - public string Suffix { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/070_delay_profile.cs b/src/NzbDrone.Core/Datastore/Migration/070_delay_profile.cs deleted file mode 100644 index 1c9c7e58b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/070_delay_profile.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(70)] - public class delay_profile : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("DelayProfiles") - .WithColumn("EnableUsenet").AsBoolean().NotNullable() - .WithColumn("EnableTorrent").AsBoolean().NotNullable() - .WithColumn("PreferredProtocol").AsInt32().NotNullable() - .WithColumn("UsenetDelay").AsInt32().NotNullable() - .WithColumn("TorrentDelay").AsInt32().NotNullable() - .WithColumn("Order").AsInt32().NotNullable() - .WithColumn("Tags").AsString().NotNullable(); - - Insert.IntoTable("DelayProfiles").Row(new - { - EnableUsenet = 1, - EnableTorrent = 1, - PreferredProtocol = 1, - UsenetDelay = 0, - TorrentDelay = 0, - Order = int.MaxValue, - Tags = "[]" - }); - - Execute.WithConnection(ConvertProfile); - - Delete.Column("GrabDelay").FromTable("Profiles"); - Delete.Column("GrabDelayMode").FromTable("Profiles"); - } - - private void ConvertProfile(IDbConnection conn, IDbTransaction tran) - { - var profiles = GetProfiles(conn, tran); - var order = 1; - - foreach (var profileClosure in profiles.DistinctBy(p => p.GrabDelay)) - { - var profile = profileClosure; - if (profile.GrabDelay == 0) continue; - - var tag = string.Format("delay-{0}", profile.GrabDelay); - var tagId = InsertTag(conn, tran, tag); - var tags = string.Format("[{0}]", tagId); - - using (IDbCommand insertDelayProfileCmd = conn.CreateCommand()) - { - insertDelayProfileCmd.Transaction = tran; - insertDelayProfileCmd.CommandText = "INSERT INTO DelayProfiles (EnableUsenet, EnableTorrent, PreferredProtocol, TorrentDelay, UsenetDelay, [Order], Tags) VALUES (1, 1, 1, 0, ?, ?, ?)"; - insertDelayProfileCmd.AddParameter(profile.GrabDelay); - insertDelayProfileCmd.AddParameter(order); - insertDelayProfileCmd.AddParameter(tags); - - insertDelayProfileCmd.ExecuteNonQuery(); - } - - var matchingProfileIds = profiles.Where(p => p.GrabDelay == profile.GrabDelay) - .Select(p => p.Id); - - UpdateSeries(conn, tran, matchingProfileIds, tagId); - - order++; - } - } - - private List GetProfiles(IDbConnection conn, IDbTransaction tran) - { - var profiles = new List(); - - using (IDbCommand getProfilesCmd = conn.CreateCommand()) - { - getProfilesCmd.Transaction = tran; - getProfilesCmd.CommandText = @"SELECT Id, GrabDelay FROM Profiles"; - - using (IDataReader profileReader = getProfilesCmd.ExecuteReader()) - { - while (profileReader.Read()) - { - var id = profileReader.GetInt32(0); - var delay = profileReader.GetInt32(1); - - profiles.Add(new Profile69 - { - Id = id, - GrabDelay = delay * 60 - }); - } - } - } - - return profiles; - } - - private int InsertTag(IDbConnection conn, IDbTransaction tran, string tagLabel) - { - using (IDbCommand insertCmd = conn.CreateCommand()) - { - insertCmd.Transaction = tran; - insertCmd.CommandText = @"INSERT INTO Tags (Label) VALUES (?); SELECT last_insert_rowid()"; - insertCmd.AddParameter(tagLabel); - - var id = insertCmd.ExecuteScalar(); - - return Convert.ToInt32(id); - } - } - - private void UpdateSeries(IDbConnection conn, IDbTransaction tran, IEnumerable profileIds, int tagId) - { - using (IDbCommand getSeriesCmd = conn.CreateCommand()) - { - getSeriesCmd.Transaction = tran; - getSeriesCmd.CommandText = "SELECT Id, Tags FROM Series WHERE ProfileId IN (?)"; - getSeriesCmd.AddParameter(string.Join(",", profileIds)); - - using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) - { - while (seriesReader.Read()) - { - var id = seriesReader.GetInt32(0); - var tagString = seriesReader.GetString(1); - - var tags = Json.Deserialize>(tagString); - tags.Add(tagId); - - using (IDbCommand updateSeriesCmd = conn.CreateCommand()) - { - updateSeriesCmd.Transaction = tran; - updateSeriesCmd.CommandText = "UPDATE Series SET Tags = ? WHERE Id = ?"; - updateSeriesCmd.AddParameter(tags.ToJson()); - updateSeriesCmd.AddParameter(id); - - updateSeriesCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class Profile69 - { - public int Id { get; set; } - public int GrabDelay { get; set; } - } - - public class Series69 - { - public int Id { get; set; } - public List Tags { get; set; } - public DateTime? LastInfoSync { get; set; } - } - - public class Tag69 - { - public int Id { get; set; } - public string Label { get; set; } - } - - public class DelayProfile70 - { - public int Id { get; set; } - public bool EnableUsenet { get; set; } - public bool EnableTorrent { get; set; } - public int PreferredProtocol { get; set; } - public int UsenetDelay { get; set; } - public int TorrentDelay { get; set; } - public int Order { get; set; } - public List Tags { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/071_unknown_quality_in_profile.cs b/src/NzbDrone.Core/Datastore/Migration/071_unknown_quality_in_profile.cs deleted file mode 100644 index a033e8410..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/071_unknown_quality_in_profile.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(71)] - public class unknown_quality_in_profile : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Weight").FromTable("QualityDefinitions"); - - Execute.WithConnection(ConvertProfile); - } - - private void ConvertProfile(IDbConnection conn, IDbTransaction tran) - { - var updater = new ProfileUpdater70(conn, tran); - updater.PrependQuality(0); - updater.Commit(); - } - } - public class Profile70 - { - public int Id { get; set; } - public string Name { get; set; } - public int Cutoff { get; set; } - public List Items { get; set; } - public int Language { get; set; } - } - - public class ProfileItem70 - { - public int Quality { get; set; } - public bool Allowed { get; set; } - } - - public class ProfileUpdater70 - { - private readonly IDbConnection _connection; - private readonly IDbTransaction _transaction; - - private List _profiles; - private HashSet _changedProfiles = new HashSet(); - - public ProfileUpdater70(IDbConnection conn, IDbTransaction tran) - { - _connection = conn; - _transaction = tran; - - _profiles = GetProfiles(); - } - - public void Commit() - { - foreach (var profile in _changedProfiles) - { - using (var updateProfileCmd = _connection.CreateCommand()) - { - updateProfileCmd.Transaction = _transaction; - updateProfileCmd.CommandText = "UPDATE Profiles SET Name = ?, Cutoff = ?, Items = ?, Language = ? WHERE Id = ?"; - updateProfileCmd.AddParameter(profile.Name); - updateProfileCmd.AddParameter(profile.Cutoff); - updateProfileCmd.AddParameter(profile.Items.ToJson()); - updateProfileCmd.AddParameter(profile.Language); - updateProfileCmd.AddParameter(profile.Id); - - updateProfileCmd.ExecuteNonQuery(); - } - } - - _changedProfiles.Clear(); - } - - public void PrependQuality(int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) continue; - - profile.Items.Insert(0, new ProfileItem70 - { - Quality = quality, - Allowed = false - }); - - _changedProfiles.Add(profile); - } - } - - public void AppendQuality(int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) continue; - - profile.Items.Add(new ProfileItem70 - { - Quality = quality, - Allowed = false - }); - - _changedProfiles.Add(profile); - } - } - - public void SplitQualityPrepend(int find, int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) continue; - - var findIndex = profile.Items.FindIndex(v => v.Quality == find); - - profile.Items.Insert(findIndex, new ProfileItem70 - { - Quality = quality, - Allowed = profile.Items[findIndex].Allowed - }); - - if (profile.Cutoff == find) - { - profile.Cutoff = quality; - } - - _changedProfiles.Add(profile); - } - } - - public void SplitQualityAppend(int find, int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) continue; - - var findIndex = profile.Items.FindIndex(v => v.Quality == find); - - profile.Items.Insert(findIndex + 1, new ProfileItem70 - { - Quality = quality, - Allowed = false - }); - - _changedProfiles.Add(profile); - } - } - - private List GetProfiles() - { - var profiles = new List(); - - using (var getProfilesCmd = _connection.CreateCommand()) - { - getProfilesCmd.Transaction = _transaction; - getProfilesCmd.CommandText = @"SELECT Id, Name, Cutoff, Items, Language FROM Profiles"; - - using (var profileReader = getProfilesCmd.ExecuteReader()) - { - while (profileReader.Read()) - { - profiles.Add(new Profile70 - { - Id = profileReader.GetInt32(0), - Name = profileReader.GetString(1), - Cutoff = profileReader.GetInt32(2), - Items = Json.Deserialize>(profileReader.GetString(3)), - Language = profileReader.GetInt32(4) - }); - } - } - } - - return profiles; - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/072_history_grabid.cs b/src/NzbDrone.Core/Datastore/Migration/072_history_grabid.cs deleted file mode 100644 index 23523808f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/072_history_grabid.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(72)] - public class history_downloadId : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("History") - .AddColumn("DownloadId").AsString() - .Nullable() - .Indexed(); - - Execute.WithConnection(MoveToColumn); - } - - private void MoveToColumn(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getHistory = conn.CreateCommand()) - { - getHistory.Transaction = tran; - getHistory.CommandText = @"SELECT Id, Data FROM History WHERE Data LIKE '%downloadClientId%'"; - - using (var historyReader = getHistory.ExecuteReader()) - { - while (historyReader.Read()) - { - var id = historyReader.GetInt32(0); - var data = historyReader.GetString(1); - - UpdateHistory(tran, conn, id, data); - } - } - } - } - - private void UpdateHistory(IDbTransaction tran, IDbConnection conn, int id, string data) - { - var dic = Json.Deserialize>(data); - - var downloadId = dic["downloadClientId"]; - dic.Remove("downloadClientId"); - - using (var updateHistoryCmd = conn.CreateCommand()) - { - updateHistoryCmd.Transaction = tran; - updateHistoryCmd.CommandText = @"UPDATE History SET DownloadId = ?, Data = ? WHERE Id = ?"; - - updateHistoryCmd.AddParameter(downloadId); - updateHistoryCmd.AddParameter(dic.ToJson()); - updateHistoryCmd.AddParameter(id); - - updateHistoryCmd.ExecuteNonQuery(); - - } - } - } - - public class History72 - { - public int EpisodeId { get; set; } - public int SeriesId { get; set; } - public string SourceTitle { get; set; } - public string Quality { get; set; } - public DateTime Date { get; set; } - public int EventType { get; set; } - public Dictionary Data { get; set; } - - public string DownloadId { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/073_clear_ratings.cs b/src/NzbDrone.Core/Datastore/Migration/073_clear_ratings.cs deleted file mode 100644 index ef9c4074f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/073_clear_ratings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(73)] - public class clear_ratings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Series") - .Set(new {Ratings = "{}"}) - .AllRows(); - - Update.Table("Episodes") - .Set(new { Ratings = "{}" }) - .AllRows(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs b/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs deleted file mode 100644 index c090df19b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(74)] - public class disable_eztv : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET EnableRss = 0, EnableSearch = 0 WHERE Implementation = 'Eztv' AND Settings LIKE '%ezrss.it%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/075_force_lib_update.cs b/src/NzbDrone.Core/Datastore/Migration/075_force_lib_update.cs deleted file mode 100644 index 5a9336f64..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/075_force_lib_update.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(75)] - public class force_lib_update : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("ScheduledTasks") - .Set(new { LastExecution = "2014-01-01 00:00:00" }) - .Where(new { TypeName = "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand" }); - - Update.Table("Series") - .Set(new { LastInfoSync = "2014-01-01 00:00:00" }) - .AllRows(); - } - } - - public class ScheduledTasks75 - { - public int Id { get; set; } - public string TypeName { get; set; } - public int Interval { get; set; } - public DateTime LastExecution { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/076_add_users_table.cs b/src/NzbDrone.Core/Datastore/Migration/076_add_users_table.cs deleted file mode 100644 index 7933d90d4..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/076_add_users_table.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(76)] - public class add_users_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Users") - .WithColumn("Identifier").AsString().NotNullable().Unique() - .WithColumn("Username").AsString().NotNullable().Unique() - .WithColumn("Password").AsString().NotNullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/077_add_add_options_to_series.cs b/src/NzbDrone.Core/Datastore/Migration/077_add_add_options_to_series.cs deleted file mode 100644 index 5c4891e5c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/077_add_add_options_to_series.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(77)] - public class add_add_options_to_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("AddOptions").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/078_add_commands_table.cs b/src/NzbDrone.Core/Datastore/Migration/078_add_commands_table.cs deleted file mode 100644 index 5a3d93716..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/078_add_commands_table.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(78)] - public class add_commands_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Commands") - .WithColumn("Name").AsString().NotNullable() - .WithColumn("Body").AsString().NotNullable() - .WithColumn("Priority").AsInt32().NotNullable() - .WithColumn("Status").AsInt32().NotNullable() - .WithColumn("QueuedAt").AsDateTime().NotNullable() - .WithColumn("StartedAt").AsDateTime().Nullable() - .WithColumn("EndedAt").AsDateTime().Nullable() - .WithColumn("Duration").AsString().Nullable() - .WithColumn("Exception").AsString().Nullable() - .WithColumn("Trigger").AsInt32().NotNullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/079_dedupe_tags.cs b/src/NzbDrone.Core/Datastore/Migration/079_dedupe_tags.cs deleted file mode 100644 index b786747a2..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/079_dedupe_tags.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(79)] - public class dedupe_tags : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(CleanupTags); - - Alter.Table("Tags").AlterColumn("Label").AsString().Unique(); - } - - private void CleanupTags(IDbConnection conn, IDbTransaction tran) - { - var tags = GetTags(conn, tran); - var grouped = tags.GroupBy(t => t.Label.ToLowerInvariant()); - var replacements = new List(); - - foreach (var group in grouped.Where(g => g.Count() > 1)) - { - var first = group.First().Id; - - foreach (var other in group.Skip(1).Select(t => t.Id)) - { - replacements.Add(new TagReplacement079 { OldId = other, NewId = first }); - } - } - - UpdateTaggedModel(conn, tran, "Series", replacements); - UpdateTaggedModel(conn, tran, "Notifications", replacements); - UpdateTaggedModel(conn, tran, "DelayProfiles", replacements); - UpdateTaggedModel(conn, tran, "Restrictions", replacements); - - DeleteTags(conn, tran, replacements); - } - - private List GetTags(IDbConnection conn, IDbTransaction tran) - { - var tags = new List(); - - using (IDbCommand tagCmd = conn.CreateCommand()) - { - tagCmd.Transaction = tran; - tagCmd.CommandText = @"SELECT Id, Label FROM Tags"; - - using (IDataReader tagReader = tagCmd.ExecuteReader()) - { - while (tagReader.Read()) - { - var id = tagReader.GetInt32(0); - var label = tagReader.GetString(1); - - tags.Add(new Tag079 { Id = id, Label = label }); - } - } - } - - return tags; - } - - private void UpdateTaggedModel(IDbConnection conn, IDbTransaction tran, string table, List replacements) - { - var tagged = new List(); - - using (IDbCommand tagCmd = conn.CreateCommand()) - { - tagCmd.Transaction = tran; - tagCmd.CommandText = string.Format("SELECT Id, Tags FROM {0}", table); - - using (IDataReader tagReader = tagCmd.ExecuteReader()) - { - while (tagReader.Read()) - { - if (!tagReader.IsDBNull(1)) - { - var id = tagReader.GetInt32(0); - var tags = tagReader.GetString(1); - - tagged.Add(new TaggedModel079 - { - Id = id, - Tags = Json.Deserialize>(tags) - }); - } - } - } - } - - var toUpdate = new List(); - - foreach (var model in tagged) - { - foreach (var replacement in replacements) - { - if (model.Tags.Contains(replacement.OldId)) - { - model.Tags.Remove(replacement.OldId); - model.Tags.Add(replacement.NewId); - - toUpdate.Add(model); - } - } - } - - foreach (var model in toUpdate.DistinctBy(m => m.Id)) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = string.Format(@"UPDATE {0} SET Tags = ? WHERE Id = ?", table); - updateCmd.AddParameter(model.Tags.ToJson()); - updateCmd.AddParameter(model.Id); - - updateCmd.ExecuteNonQuery(); - } - } - } - - private void DeleteTags(IDbConnection conn, IDbTransaction tran, List replacements) - { - var idsToRemove = replacements.Select(r => r.OldId).Distinct(); - - using (IDbCommand removeCmd = conn.CreateCommand()) - { - removeCmd.Transaction = tran; - removeCmd.CommandText = string.Format("DELETE FROM Tags WHERE Id IN ({0})", string.Join(",", idsToRemove)); - removeCmd.ExecuteNonQuery(); - } - } - - private class Tag079 - { - public int Id { get; set; } - public string Label { get; set; } - } - - private class TagReplacement079 - { - public int OldId { get; set; } - public int NewId { get; set; } - } - - private class TaggedModel079 - { - public int Id { get; set; } - public HashSet Tags { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/081_move_dot_prefix_to_transmission_category.cs b/src/NzbDrone.Core/Datastore/Migration/081_move_dot_prefix_to_transmission_category.cs deleted file mode 100644 index c48fd75a8..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/081_move_dot_prefix_to_transmission_category.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(81)] - public class move_dot_prefix_to_transmission_category : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM DownloadClients WHERE Implementation = 'Transmission'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - - var settings = Json.Deserialize>(settingsJson); - - var tvCategory = settings.GetValueOrDefault("tvCategory") as string; - if (tvCategory.IsNotNullOrWhiteSpace()) - { - settings["tvCategory"] = "." + tvCategory; - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - } - - public class DownloadClientDefinition81 - { - public int Id { get; set; } - public bool Enable { get; set; } - public string Name { get; set; } - public string Implementation { get; set; } - public JObject Settings { get; set; } - public string ConfigContract { get; set; } - } - - public class SabnzbdSettings81 - { - public string Host { get; set; } - public int Port { get; set; } - public string ApiKey { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } - - public class TransmissionSettings81 - { - public string Host { get; set; } - public int Port { get; set; } - public string UrlBase { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public string TvDirectory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/082_add_fanzub_settings.cs b/src/NzbDrone.Core/Datastore/Migration/082_add_fanzub_settings.cs deleted file mode 100644 index 43d332224..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/082_add_fanzub_settings.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(82)] - public class add_fanzub_settings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET ConfigContract = 'FanzubSettings' WHERE Implementation = 'Fanzub' AND ConfigContract = 'NullConfig'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/083_additonal_blacklist_columns.cs b/src/NzbDrone.Core/Datastore/Migration/083_additonal_blacklist_columns.cs deleted file mode 100644 index 93fa2fd51..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/083_additonal_blacklist_columns.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(83)] - public class additonal_blacklist_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Blacklist").AddColumn("Size").AsInt64().Nullable(); - Alter.Table("Blacklist").AddColumn("Protocol").AsInt32().Nullable(); - Alter.Table("Blacklist").AddColumn("Indexer").AsString().Nullable(); - Alter.Table("Blacklist").AddColumn("Message").AsString().Nullable(); - Alter.Table("Blacklist").AddColumn("TorrentInfoHash").AsString().Nullable(); - - Update.Table("Blacklist") - .Set(new { Protocol = 1 }) - .AllRows(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/084_update_quality_minmax_size.cs b/src/NzbDrone.Core/Datastore/Migration/084_update_quality_minmax_size.cs deleted file mode 100644 index 03a0a8ea3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/084_update_quality_minmax_size.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(84)] - public class update_quality_minmax_size : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("QualityDefinitions").AlterColumn("MinSize").AsDouble().Nullable(); - Alter.Table("QualityDefinitions").AlterColumn("MaxSize").AsDouble().Nullable(); - - Execute.Sql("UPDATE QualityDefinitions SET MaxSize = NULL WHERE Quality = 10 OR MaxSize = 0"); - } - } - - public class QualityDefinition84 - { - public int Id { get; set; } - public int Quality { get; set; } - public string Title { get; set; } - public int? MinSize { get; set; } - public int? MaxSize { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/085_expand_transmission_urlbase.cs b/src/NzbDrone.Core/Datastore/Migration/085_expand_transmission_urlbase.cs deleted file mode 100644 index 956f87bcd..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/085_expand_transmission_urlbase.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(85)] - public class expand_transmission_urlbase : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM DownloadClients WHERE Implementation = 'Transmission'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - - var settings = Json.Deserialize>(settingsJson); - - var urlBase = settings.GetValueOrDefault("urlBase", "") as string; - - if (urlBase.IsNullOrWhiteSpace()) - { - settings["urlBase"] = "/transmission/"; - } - else - { - settings["urlBase"] = string.Format("/{0}/transmission/", urlBase.Trim('/')); - } - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class DelugeSettings85 - { - public string Host { get; set; } - public int Port { get; set; } - public string UrlBase { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/086_pushbullet_device_ids.cs b/src/NzbDrone.Core/Datastore/Migration/086_pushbullet_device_ids.cs deleted file mode 100644 index 432a13ff3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/086_pushbullet_device_ids.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(86)] - public class pushbullet_device_ids : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM Notifications WHERE Implementation = 'PushBullet'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - var settings = Json.Deserialize>(settingsJson); - - if (settings.ContainsKey("deviceId")) - { - var deviceId = settings.GetValueOrDefault("deviceId", "") as string; - - settings.Add("deviceIds", new[] { deviceId }); - settings.Remove("deviceId"); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE Notifications SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - } - - public class Notification86 - { - public int Id { get; set; } - public string Name { get; set; } - public int OnGrab { get; set; } - public int OnDownload { get; set; } - public JObject Settings { get; set; } - public string Implementation { get; set; } - public string ConfigContract { get; set; } - public int OnUpgrade { get; set; } - public List Tags { get; set; } - } - - public class PushBulletSettings86 - { - public string ApiKey { get; set; } - public string[] DeviceIds { get; set; } - public string ChannelTags { get; set; } - public string SenderId { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/087_remove_eztv.cs b/src/NzbDrone.Core/Datastore/Migration/087_remove_eztv.cs deleted file mode 100644 index d6990053a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/087_remove_eztv.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(87)] - public class remove_eztv : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("DELETE FROM Indexers WHERE Implementation = 'Eztv'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/088_pushbullet_devices_channels_list.cs b/src/NzbDrone.Core/Datastore/Migration/088_pushbullet_devices_channels_list.cs deleted file mode 100644 index b219dfd59..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/088_pushbullet_devices_channels_list.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(88)] - public class pushbullet_devices_channels_list : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM Notifications WHERE Implementation = 'PushBullet'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - var settings = Json.Deserialize>(settingsJson); - - if (settings.ContainsKey("deviceIds")) - { - var deviceIdsString = settings.GetValueOrDefault("deviceIds", "") as string; - - if (deviceIdsString.IsNotNullOrWhiteSpace()) - { - var deviceIds = deviceIdsString.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); - - settings["deviceIds"] = deviceIds; - } - } - - if (settings.ContainsKey("channelTags")) - { - var channelTagsString = settings.GetValueOrDefault("channelTags", "") as string; - - if (channelTagsString.IsNotNullOrWhiteSpace()) - { - var channelTags = channelTagsString.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries); - - settings["channelTags"] = channelTags; - } - } - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE Notifications SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class PushBulletSettings88 - { - public string ApiKey { get; set; } - public string[] DeviceIds { get; set; } - public string[] ChannelTags { get; set; } - public string SenderId { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/089_add_on_rename_to_notifcations.cs b/src/NzbDrone.Core/Datastore/Migration/089_add_on_rename_to_notifcations.cs deleted file mode 100644 index e06db676b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/089_add_on_rename_to_notifcations.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(89)] - public class add_on_rename_to_notifcations : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Notifications").AddColumn("OnRename").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Notifications SET OnRename = OnDownload WHERE Implementation IN ('PlexServer', 'Xbmc', 'MediaBrowser')"); - Execute.Sql("UPDATE Notifications SET OnRename = 0 WHERE Implementation NOT IN ('PlexServer', 'Xbmc', 'MediaBrowser')"); - - Alter.Table("Notifications").AlterColumn("OnRename").AsBoolean().NotNullable(); - - Execute.Sql("UPDATE Notifications SET OnGrab = 0 WHERE Implementation = 'PlexServer'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs b/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs deleted file mode 100644 index ec96f48dc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs +++ /dev/null @@ -1,36 +0,0 @@ -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(90)] - public class update_kickass_url : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql( - "UPDATE Indexers SET Settings = Replace(Settings, 'kickass.so', 'kat.cr') WHERE Implementation = 'KickassTorrents';" + - "UPDATE Indexers SET Settings = Replace(Settings, 'kickass.to', 'kat.cr') WHERE Implementation = 'KickassTorrents';" + - "UPDATE Indexers SET Settings = Replace(Settings, 'http://', 'https://') WHERE Implementation = 'KickassTorrents';" - ); - } - } - - public class IndexerDefinition90 - { - public int Id { get; set; } - public string Name { get; set; } - public JObject Settings { get; set; } - public string Implementation { get; set; } - public string ConfigContract { get; set; } - public bool EnableRss { get; set; } - public bool EnableSearch { get; set; } - } - - public class KickassTorrentsSettings90 - { - public string BaseUrl { get; set; } - public bool VerifiedOnly { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/091_added_indexerstatus.cs b/src/NzbDrone.Core/Datastore/Migration/091_added_indexerstatus.cs deleted file mode 100644 index 9a384c298..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/091_added_indexerstatus.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(91)] - public class added_indexerstatus : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("IndexerStatus") - .WithColumn("IndexerId").AsInt32().NotNullable().Unique() - .WithColumn("InitialFailure").AsDateTime().Nullable() - .WithColumn("MostRecentFailure").AsDateTime().Nullable() - .WithColumn("EscalationLevel").AsInt32().NotNullable() - .WithColumn("DisabledTill").AsDateTime().Nullable() - .WithColumn("LastRssSyncReleaseInfo").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/092_add_unverifiedscenenumbering.cs b/src/NzbDrone.Core/Datastore/Migration/092_add_unverifiedscenenumbering.cs deleted file mode 100644 index 5366b0fad..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/092_add_unverifiedscenenumbering.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(92)] - public class add_unverifiedscenenumbering : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("UnverifiedSceneNumbering").AsBoolean().WithDefaultValue(false); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/093_naming_config_replace_characters.cs b/src/NzbDrone.Core/Datastore/Migration/093_naming_config_replace_characters.cs deleted file mode 100644 index 4ba4be853..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/093_naming_config_replace_characters.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(93)] - public class naming_config_replace_illegal_characters : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("ReplaceIllegalCharacters").AsBoolean().WithDefaultValue(true); - Update.Table("NamingConfig").Set(new { ReplaceIllegalCharacters = true }).AllRows(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs b/src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs deleted file mode 100644 index 007716bfc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(94)] - public class add_tvmazeid : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("TvMazeId").AsInt32().WithDefaultValue(0); - Create.Index().OnTable("Series").OnColumn("TvMazeId"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/095_add_additional_episodes_index.cs b/src/NzbDrone.Core/Datastore/Migration/095_add_additional_episodes_index.cs deleted file mode 100644 index 5d7a08b62..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/095_add_additional_episodes_index.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(95)] - public class add_additional_episodes_index : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Index().OnTable("Episodes").OnColumn("SeriesId").Ascending() - .OnColumn("SeasonNumber").Ascending() - .OnColumn("EpisodeNumber").Ascending(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/096_disable_kickass.cs b/src/NzbDrone.Core/Datastore/Migration/096_disable_kickass.cs deleted file mode 100644 index 69894cbce..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/096_disable_kickass.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(96)] - public class disable_kickass : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET EnableRss = 0, EnableSearch = 0, Settings = Replace(Settings, 'https://kat.cr', '') WHERE Implementation = 'KickassTorrents' AND Settings LIKE '%kat.cr%';"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/098_remove_titans_of_tv.cs b/src/NzbDrone.Core/Datastore/Migration/098_remove_titans_of_tv.cs deleted file mode 100644 index 86b2eba1e..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/098_remove_titans_of_tv.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(98)] - public class remove_titans_of_tv : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.FromTable("Indexers").Row(new { Implementation = "TitansOfTv" }); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/099_extra_and_subtitle_files.cs b/src/NzbDrone.Core/Datastore/Migration/099_extra_and_subtitle_files.cs deleted file mode 100644 index f7a173157..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/099_extra_and_subtitle_files.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(99)] - public class extra_and_subtitle_files : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("ExtraFiles") - .WithColumn("SeriesId").AsInt32().NotNullable() - .WithColumn("SeasonNumber").AsInt32().NotNullable() - .WithColumn("EpisodeFileId").AsInt32().NotNullable() - .WithColumn("RelativePath").AsString().NotNullable() - .WithColumn("Extension").AsString().NotNullable() - .WithColumn("Added").AsDateTime().NotNullable() - .WithColumn("LastUpdated").AsDateTime().NotNullable(); - - Create.TableForModel("SubtitleFiles") - .WithColumn("SeriesId").AsInt32().NotNullable() - .WithColumn("SeasonNumber").AsInt32().NotNullable() - .WithColumn("EpisodeFileId").AsInt32().NotNullable() - .WithColumn("RelativePath").AsString().NotNullable() - .WithColumn("Extension").AsString().NotNullable() - .WithColumn("Added").AsDateTime().NotNullable() - .WithColumn("LastUpdated").AsDateTime().NotNullable() - .WithColumn("Language").AsInt32().NotNullable(); - - Alter.Table("MetadataFiles") - .AddColumn("Added").AsDateTime().Nullable() - .AddColumn("Extension").AsString().Nullable(); - - // Remove Metadata files that don't have an extension - Execute.Sql("DELETE FROM MetadataFiles WHERE RelativePath NOT LIKE '%.%'"); - - // Set Extension using the extension from RelativePath - Execute.WithConnection(SetMetadataFileExtension); - - Alter.Table("MetadataFiles").AlterColumn("Extension").AsString().NotNullable(); - } - - private void SetMetadataFileExtension(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, RelativePath FROM MetadataFiles"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var relativePath = reader.GetString(1); - var extension = relativePath.Substring(relativePath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE MetadataFiles SET Extension = ? WHERE Id = ?"; - updateCmd.AddParameter(extension); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class MetadataFile99 - { - public int Id { get; set; } - public int SeriesId { get; set; } - public int? EpisodeFileId { get; set; } - public int? SeasonNumber { get; set; } - public string RelativePath { get; set; } - public DateTime Added { get; set; } - public DateTime LastUpdated { get; set; } - public string Extension { get; set; } - public string Hash { get; set; } - public string Consumer { get; set; } - public int Type { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/100_add_scene_season_number.cs b/src/NzbDrone.Core/Datastore/Migration/100_add_scene_season_number.cs deleted file mode 100644 index 3cd11f6f0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/100_add_scene_season_number.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(100)] - public class add_scene_season_number : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("SceneMappings").AlterColumn("SeasonNumber").AsInt32().Nullable(); - Alter.Table("SceneMappings").AddColumn("SceneSeasonNumber").AsInt32().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/101_add_ultrahd_quality_in_profiles.cs b/src/NzbDrone.Core/Datastore/Migration/101_add_ultrahd_quality_in_profiles.cs deleted file mode 100644 index 171607fa6..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/101_add_ultrahd_quality_in_profiles.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(101)] - public class add_ultrahd_quality_in_profiles : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertProfile); - } - - private void ConvertProfile(IDbConnection conn, IDbTransaction tran) - { - var updater = new ProfileUpdater70(conn, tran); - updater.AppendQuality(16); // HDTV2160p - updater.AppendQuality(18); // WEBDL2160p - updater.AppendQuality(19); // Bluray2160p - updater.Commit(); - - // WEBRip migrations. - //updater.SplitQualityAppend(1, 11); // HDTV480p after SDTV - //updater.SplitQualityPrepend(8, 12); // WEBRip480p before WEBDL480p - //updater.SplitQualityAppend(2, 13); // Bluray480p after DVD - //updater.SplitQualityPrepend(5, 14); // WEBRip720p before WEBDL720p - //updater.SplitQualityPrepend(3, 15); // WEBRip1080p before WEBDL1080p - //updater.SplitQualityPrepend(18, 17); // WEBRip2160p before WEBDL2160p - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/102_add_language_to_episodeFiles_history_and_blacklist.cs b/src/NzbDrone.Core/Datastore/Migration/102_add_language_to_episodeFiles_history_and_blacklist.cs deleted file mode 100644 index 39f46e333..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/102_add_language_to_episodeFiles_history_and_blacklist.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Datastore.Converters; -using NzbDrone.Core.Languages; -using System; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(102)] - public class add_language_to_episodeFiles_history_and_blacklist : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("EpisodeFiles") - .AddColumn("Language").AsInt32().NotNullable().WithDefaultValue(0); - - Alter.Table("History") - .AddColumn("Language").AsInt32().NotNullable().WithDefaultValue(0); - - Alter.Table("Blacklist") - .AddColumn("Language").AsInt32().NotNullable().WithDefaultValue(0); - - Execute.WithConnection(UpdateLanguage); - } - - private void UpdateLanguage(IDbConnection conn, IDbTransaction tran) - { - var LanguageConverter = new EmbeddedDocumentConverter(new LanguageIntConverter()); - - using (IDbCommand getSeriesCmd = conn.CreateCommand()) - { - getSeriesCmd.Transaction = tran; - getSeriesCmd.CommandText = @"SELECT Id, ProfileId FROM Series"; - using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) - { - while (seriesReader.Read()) - { - var seriesId = seriesReader.GetInt32(0); - var seriesProfileId = seriesReader.GetInt32(1); - - using (IDbCommand getProfileCmd = conn.CreateCommand()) - { - getProfileCmd.Transaction = tran; - getProfileCmd.CommandText = "SELECT Language FROM Profiles WHERE Id = ?"; - getProfileCmd.AddParameter(seriesProfileId); - IDataReader profilesReader = getProfileCmd.ExecuteReader(); - while (profilesReader.Read()) - { - var episodeLanguage = Language.English.Id; - try - { - episodeLanguage = profilesReader.GetInt32(0); - } catch (InvalidCastException e) - { - _logger.Debug("Language field not found in Profiles, using English as default." + e.Message); - } - - var validJson = LanguageConverter.ToDB(Language.FindById(episodeLanguage)); - - using (IDbCommand updateEpisodeFilesCmd = conn.CreateCommand()) - { - updateEpisodeFilesCmd.Transaction = tran; - updateEpisodeFilesCmd.CommandText = "UPDATE EpisodeFiles SET Language = ? WHERE SeriesId = ?"; - updateEpisodeFilesCmd.AddParameter(validJson); - updateEpisodeFilesCmd.AddParameter(seriesId); - - updateEpisodeFilesCmd.ExecuteNonQuery(); - } - - using (IDbCommand updateHistoryCmd = conn.CreateCommand()) - { - updateHistoryCmd.Transaction = tran; - updateHistoryCmd.CommandText = "UPDATE History SET Language = ? WHERE SeriesId = ?"; - updateHistoryCmd.AddParameter(validJson); - updateHistoryCmd.AddParameter(seriesId); - - updateHistoryCmd.ExecuteNonQuery(); - } - - using (IDbCommand updateBlacklistCmd = conn.CreateCommand()) - { - updateBlacklistCmd.Transaction = tran; - updateBlacklistCmd.CommandText = "UPDATE Blacklist SET Language = ? WHERE SeriesId = ?"; - updateBlacklistCmd.AddParameter(validJson); - updateBlacklistCmd.AddParameter(seriesId); - - updateBlacklistCmd.ExecuteNonQuery(); - } - } - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/103_fix_metadata_file_extensions.cs b/src/NzbDrone.Core/Datastore/Migration/103_fix_metadata_file_extensions.cs deleted file mode 100644 index d4ed853a3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/103_fix_metadata_file_extensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(103)] - public class fix_metadata_file_extensions : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(SetMetadataFileExtension); - } - - private void SetMetadataFileExtension(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Extension FROM MetadataFiles"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var extension = reader.GetString(1); - extension = extension.Substring(extension.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE MetadataFiles SET Extension = ? WHERE Id = ?"; - updateCmd.AddParameter(extension); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/104_remove_kickass.cs b/src/NzbDrone.Core/Datastore/Migration/104_remove_kickass.cs deleted file mode 100644 index c7f21fe38..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/104_remove_kickass.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(104)] - public class remove_kickass : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("DELETE FROM Indexers WHERE Implementation = 'KickassTorrents';"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/105_rename_torrent_downloadstation.cs b/src/NzbDrone.Core/Datastore/Migration/105_rename_torrent_downloadstation.cs deleted file mode 100644 index c5a71c885..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/105_rename_torrent_downloadstation.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(105)] - public class rename_torrent_downloadstation : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE DownloadClients SET Implementation = 'TorrentDownloadStation' WHERE Implementation = 'DownloadStation';"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/106_update_btn_url.cs b/src/NzbDrone.Core/Datastore/Migration/106_update_btn_url.cs deleted file mode 100644 index f2989a2c8..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/106_update_btn_url.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(106)] - public class update_btn_url : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET Settings = Replace(Settings, 'api.btnapps.net', 'api.broadcasthe.net') WHERE Implementation = 'BroadcastheNet';"); - } - } - - public class BroadcastheNetSettings106 - { - public string BaseUrl { get; set; } - - public string ApiKey { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/107_remove_wombles.cs b/src/NzbDrone.Core/Datastore/Migration/107_remove_wombles.cs deleted file mode 100644 index 7bbb5ceb7..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/107_remove_wombles.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(107)] - public class remove_wombles : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("DELETE FROM Indexers WHERE Implementation = 'Wombles';"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/108_fix_extra_file_extension.cs b/src/NzbDrone.Core/Datastore/Migration/108_fix_extra_file_extension.cs deleted file mode 100644 index 8ef387b26..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/108_fix_extra_file_extension.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(108)] - public class fix_extra_file_extension : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - // Delete extraneous files without extensions that Lidarr found previously, - // these will be blocked from importing as well. - Execute.Sql("DELETE FROM ExtraFiles WHERE TRIM(Extension) = ''"); - - Execute.WithConnection(FixExtraFileExtension); - } - - private void FixExtraFileExtension(IDbConnection conn, IDbTransaction tran) - { - FixExtraFileExtensionForTable(conn, tran, "ExtraFiles"); - FixExtraFileExtensionForTable(conn, tran, "SubtitleFiles"); - } - - private void FixExtraFileExtensionForTable(IDbConnection conn, IDbTransaction tran, string table) - { - - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = $"SELECT Id, RelativePath FROM {table}"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var relativePath = reader.GetString(1); - var extension = relativePath.Substring(relativePath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = $"UPDATE {table} SET Extension = ? WHERE Id = ?"; - updateCmd.AddParameter(extension); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/109_import_extra_files.cs b/src/NzbDrone.Core/Datastore/Migration/109_import_extra_files.cs deleted file mode 100644 index e92e00a78..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/109_import_extra_files.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(109)] - public class import_extra_files : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ImportExtraFiles); - } - - private void ImportExtraFiles(IDbConnection conn, IDbTransaction tran) - { - - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Value from Config WHERE Key = 'extrafileextensions'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var value = reader.GetString(0); - - if (value.IsNotNullOrWhiteSpace()) - { - using (var insertCmd = conn.CreateCommand()) - { - insertCmd.Transaction = tran; - insertCmd.CommandText = "INSERT INTO Config (Key, Value) VALUES('importextrafiles', 'True')"; - insertCmd.ExecuteNonQuery(); - } - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/110_fix_extra_files_config.cs b/src/NzbDrone.Core/Datastore/Migration/110_fix_extra_files_config.cs deleted file mode 100644 index 5f136deb1..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/110_fix_extra_files_config.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(110)] - public class fix_extra_files_config : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(FixExtraFilesConfig); - } - - private void FixExtraFilesConfig(IDbConnection conn, IDbTransaction tran) - { - string extraFileExtensions; - string importExtraFiles; - - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Value FROM Config WHERE Key = 'extrafileextensions'"; - - extraFileExtensions = (string)cmd.ExecuteScalar(); - } - - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Value FROM Config WHERE Key = 'importextrafiles'"; - - importExtraFiles = (string)cmd.ExecuteScalar(); - } - - if (importExtraFiles == "1" || importExtraFiles == "True") - { - using (var insertCmd = conn.CreateCommand()) - { - insertCmd.Transaction = tran; - insertCmd.CommandText = "UPDATE Config SET Value = 'True' WHERE Key = 'importextrafiles'"; - insertCmd.ExecuteNonQuery(); - } - } - else if (extraFileExtensions.IsNullOrWhiteSpace()) - { - using (var insertCmd = conn.CreateCommand()) - { - insertCmd.Transaction = tran; - insertCmd.CommandText = "UPDATE Config SET Value = 'srt' WHERE Key = 'extrafileextensions'"; - insertCmd.ExecuteNonQuery(); - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/111_create_language_profiles.cs b/src/NzbDrone.Core/Datastore/Migration/111_create_language_profiles.cs deleted file mode 100644 index 57ac6ac59..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/111_create_language_profiles.cs +++ /dev/null @@ -1,175 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Converters; -using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Languages; -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Profiles.Languages; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(111)] - public class create_language_profiles : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("LanguageProfiles").WithColumn("Name").AsString().Unique() - .WithColumn("Languages").AsString() - .WithColumn("Cutoff").AsInt32(); - - Alter.Table("Series").AddColumn("LanguageProfileId").AsInt32().WithDefaultValue(1); - - Execute.WithConnection(InsertDefaultLanguages); - - Delete.Column("Language").FromTable("Profiles"); - } - - private void InsertDefaultLanguages(IDbConnection conn, IDbTransaction tran) - { - var profiles = GetLanguageProfiles(conn, tran); - var languageConverter = new EmbeddedDocumentConverter(new LanguageIntConverter()); - - foreach (var profile in profiles.OrderBy(p => p.Id)) - { - using (IDbCommand insertNewLanguageProfileCmd = conn.CreateCommand()) - { - var itemsJson = languageConverter.ToDB(profile.Languages); - insertNewLanguageProfileCmd.Transaction = tran; - insertNewLanguageProfileCmd.CommandText = "INSERT INTO LanguageProfiles (Id, Name, Cutoff, Languages) VALUES (?, ?, ?, ?)"; - insertNewLanguageProfileCmd.AddParameter(profile.Id); - insertNewLanguageProfileCmd.AddParameter(profile.Name); - insertNewLanguageProfileCmd.AddParameter(profile.Cutoff.Id); - insertNewLanguageProfileCmd.AddParameter(itemsJson); - - insertNewLanguageProfileCmd.ExecuteNonQuery(); - } - - using (IDbCommand updateSeriesCmd = conn.CreateCommand()) - { - foreach (var profileId in profile.ProfileIds) - { - updateSeriesCmd.Transaction = tran; - updateSeriesCmd.CommandText = "UPDATE Series SET LanguageProfileId = ? WHERE ProfileId = ?"; - updateSeriesCmd.AddParameter(profile.Id); - updateSeriesCmd.AddParameter(profileId); - updateSeriesCmd.ExecuteNonQuery(); - } - } - } - } - - private List GetDefaultLanguageProfiles() - { - var profiles = new List(); - - var languages = GetOrderedLanguages().Select(v => new ProfileLanguageItem { Language = v, Allowed = v == Language.English }) - .ToList(); - - profiles.Add(new LanguageProfile111 - { - Id = 1, - Name = "English", - Cutoff = Language.English, - Languages = languages - }); - - return profiles; - - } - - private List GetLanguageProfiles(IDbConnection conn, IDbTransaction tran) - { - var profiles = GetDefaultLanguageProfiles(); - var thereAreProfiles = false; - - using (IDbCommand getProfilesCmd = conn.CreateCommand()) - { - getProfilesCmd.Transaction = tran; - getProfilesCmd.CommandText = @"SELECT Id, Language FROM Profiles"; - - using (IDataReader profileReader = getProfilesCmd.ExecuteReader()) - { - while (profileReader.Read()) - { - thereAreProfiles = true; - var profileId = profileReader.GetInt32(0); - var lang = Language.English.Id; - - try - { - lang = profileReader.GetInt32(1); - } - catch (InvalidCastException e) - { - _logger.Debug("Language field not found in Profiles, using English as default." + e.Message); - } - - if (profiles.None(p => p.Cutoff.Id == lang)) - { - var language = Language.FindById(lang); - var languages = GetOrderedLanguages().Select(l => new ProfileLanguageItem { Language = l, Allowed = l.Id == lang }) - .ToList(); - - profiles.Add(new LanguageProfile111 - { - Id = profiles.Count + 1, - Name = language.Name, - Cutoff = language, - Languages = languages, - ProfileIds = new List { profileId } - }); - } - else - { - profiles = profiles.Select(p => - { - if (p.Cutoff.Id == lang) - { - p.ProfileIds.Add(profileId); - } - - return p; - }).ToList(); - } - } - } - } - - if (!thereAreProfiles) - { - return new List(); - } - - return profiles; - } - - private List GetOrderedLanguages() - { - var orderedLanguages = Language.All - .Where(l => l != Language.Unknown) - .OrderByDescending(l => l.Name) - .ToList(); - - orderedLanguages.Insert(0, Language.Unknown); - - return orderedLanguages; - } - - private class LanguageProfile111 - { - public int Id { get; set; } - public List ProfileIds { get; set; } - public string Name { get; set; } - public Language Cutoff { get; set; } - public List Languages { get; set; } - - public LanguageProfile111 () - { - ProfileIds = new List(); - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/112_setup_music.cs b/src/NzbDrone.Core/Datastore/Migration/112_setup_music.cs deleted file mode 100644 index 2e68c591e..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/112_setup_music.cs +++ /dev/null @@ -1,108 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(112)] - public class setup_music : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Artists") - .WithColumn("ForeignArtistId").AsString().Unique() - .WithColumn("MBId").AsString().Nullable() - .WithColumn("AMId").AsString().Nullable() - .WithColumn("TADBId").AsInt32().Nullable() - .WithColumn("DiscogsId").AsInt32().Nullable() - .WithColumn("Name").AsString() - .WithColumn("NameSlug").AsString().Nullable().Unique() - .WithColumn("CleanName").AsString().Indexed() - .WithColumn("Status").AsInt32() - .WithColumn("Overview").AsString().Nullable() - .WithColumn("Images").AsString() - .WithColumn("Path").AsString().Indexed() - .WithColumn("Monitored").AsBoolean() - .WithColumn("AlbumFolder").AsBoolean() - .WithColumn("LastInfoSync").AsDateTime().Nullable() - .WithColumn("LastDiskSync").AsDateTime().Nullable() - .WithColumn("DateFormed").AsDateTime().Nullable() - .WithColumn("Members").AsString().Nullable() - .WithColumn("Ratings").AsString().Nullable() - .WithColumn("Genres").AsString().Nullable() - .WithColumn("SortName").AsString().Nullable() - .WithColumn("ProfileId").AsInt32().Nullable() - .WithColumn("Tags").AsString().Nullable() - .WithColumn("Added").AsDateTime().Nullable() - .WithColumn("AddOptions").AsString().Nullable() - .WithColumn("LanguageProfileId").AsInt32().WithDefaultValue(1); - - Create.TableForModel("Albums") - .WithColumn("ForeignAlbumId").AsString().Unique() - .WithColumn("ArtistId").AsInt32() - .WithColumn("MBId").AsString().Nullable().Indexed() - .WithColumn("AMId").AsString().Nullable() - .WithColumn("TADBId").AsInt32().Nullable().Indexed() - .WithColumn("DiscogsId").AsInt32().Nullable() - .WithColumn("Title").AsString() - .WithColumn("TitleSlug").AsString().Nullable().Unique() - .WithColumn("CleanTitle").AsString().Indexed() - .WithColumn("Overview").AsString().Nullable() - .WithColumn("Images").AsString() - .WithColumn("Path").AsString().Indexed() - .WithColumn("Monitored").AsBoolean() - .WithColumn("LastInfoSync").AsDateTime().Nullable() - .WithColumn("LastDiskSync").AsDateTime().Nullable() - .WithColumn("ReleaseDate").AsDateTime().Nullable() - .WithColumn("Ratings").AsString().Nullable() - .WithColumn("Genres").AsString().Nullable() - .WithColumn("Label").AsString().Nullable() - .WithColumn("SortTitle").AsString().Nullable() - .WithColumn("ProfileId").AsInt32().Nullable() - .WithColumn("Tags").AsString().Nullable() - .WithColumn("Added").AsDateTime().Nullable() - .WithColumn("AlbumType").AsString() - .WithColumn("AddOptions").AsString().Nullable(); - - Create.TableForModel("Tracks") - .WithColumn("ForeignTrackId").AsString().Unique() - .WithColumn("ArtistId").AsInt32().Indexed() - .WithColumn("AlbumId").AsInt32() - .WithColumn("MBId").AsString().Nullable().Indexed() - .WithColumn("TrackNumber").AsInt32() - .WithColumn("Title").AsString().Nullable() - .WithColumn("Explicit").AsBoolean() - .WithColumn("Compilation").AsBoolean() - .WithColumn("DiscNumber").AsInt32().Nullable() - .WithColumn("TrackFileId").AsInt32().Nullable().Indexed() - .WithColumn("Monitored").AsBoolean() - .WithColumn("Ratings").AsString().Nullable(); - - Create.Index().OnTable("Tracks").OnColumn("ArtistId").Ascending() - .OnColumn("AlbumId").Ascending() - .OnColumn("TrackNumber").Ascending(); - - Create.TableForModel("TrackFiles") - .WithColumn("ArtistId").AsInt32().Indexed() - .WithColumn("AlbumId").AsInt32().Indexed() - .WithColumn("Quality").AsString() - .WithColumn("Size").AsInt64() - .WithColumn("DateAdded").AsDateTime() - .WithColumn("SceneName").AsString().Nullable() - .WithColumn("ReleaseGroup").AsString().Nullable() - .WithColumn("MediaInfo").AsString().Nullable() - .WithColumn("RelativePath").AsString().Nullable() - .WithColumn("Language").AsInt32().WithDefaultValue(0); - - Alter.Table("NamingConfig") - .AddColumn("ArtistFolderFormat").AsString().Nullable() - .AddColumn("RenameTracks").AsBoolean().Nullable() - .AddColumn("StandardTrackFormat").AsString().Nullable() - .AddColumn("AlbumFolderFormat").AsString().Nullable(); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/113_music_history.cs b/src/NzbDrone.Core/Datastore/Migration/113_music_history.cs deleted file mode 100644 index 81417304f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/113_music_history.cs +++ /dev/null @@ -1,36 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(113)] - public class music_history : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("History") - .AddColumn("ArtistId").AsInt32().WithDefaultValue(0) - .AddColumn("AlbumId").AsInt32().WithDefaultValue(0); - - Alter.Table("PendingReleases") - .AddColumn("ArtistId").AsInt32().WithDefaultValue(0) - .AddColumn("ParsedAlbumInfo").AsString().WithDefaultValue(""); - - Alter.Table("Tracks") - .AddColumn("Duration").AsInt32().WithDefaultValue(0); - - Alter.Table("Albums") - .AddColumn("Duration").AsInt32().WithDefaultValue(0); - - Delete.Column("SeriesId").FromTable("History"); - Delete.Column("EpisodeId").FromTable("History"); - Delete.Column("SeriesId").FromTable("PendingReleases"); - Delete.Column("ParsedEpisodeInfo").FromTable("PendingReleases"); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/114_music_blacklist.cs b/src/NzbDrone.Core/Datastore/Migration/114_music_blacklist.cs deleted file mode 100644 index 36a5deecf..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/114_music_blacklist.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(114)] - public class music_blacklist : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Blacklist") - .AddColumn("ArtistId").AsInt32().WithDefaultValue(0) - .AddColumn("AlbumIds").AsString().WithDefaultValue(""); - - Delete.Column("SeriesId").FromTable("Blacklist"); - Delete.Column("EpisodeIds").FromTable("Blacklist"); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/115_remove_tv_naming.cs b/src/NzbDrone.Core/Datastore/Migration/115_remove_tv_naming.cs deleted file mode 100644 index 84272f5b7..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/115_remove_tv_naming.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(115)] - public class remove_tv_naming : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("RenameEpisodes").FromTable("NamingConfig"); - Delete.Column("StandardEpisodeFormat").FromTable("NamingConfig"); - Delete.Column("DailyEpisodeFormat").FromTable("NamingConfig"); - Delete.Column("AnimeEpisodeFormat").FromTable("NamingConfig"); - Delete.Column("SeasonFolderFormat").FromTable("NamingConfig"); - Delete.Column("SeriesFolderFormat").FromTable("NamingConfig"); - Delete.Column("MultiEpisodeStyle").FromTable("NamingConfig"); - - Execute.Sql("DELETE FROM Config WHERE [Key] = 'filedate'"); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/116_change_drone_factory_variable_name.cs b/src/NzbDrone.Core/Datastore/Migration/116_change_drone_factory_variable_name.cs deleted file mode 100644 index a7cc52981..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/116_change_drone_factory_variable_name.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(116)] - public class change_drone_factory_variable_name : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("DELETE FROM Config WHERE [Key] = 'downloadedepisodesfolder'"); - Execute.Sql("DELETE FROM Config WHERE [Key] = 'downloadedepisodesscaninterval'"); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/117_artist_links.cs b/src/NzbDrone.Core/Datastore/Migration/117_artist_links.cs deleted file mode 100644 index af3eeb65f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/117_artist_links.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(117)] - public class artist_links : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Artists") - .AddColumn("Links").AsString().Nullable(); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/118_history_trackid.cs b/src/NzbDrone.Core/Datastore/Migration/118_history_trackid.cs deleted file mode 100644 index d4ae1f7d0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/118_history_trackid.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(118)] - public class history_trackid : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("History") - .AddColumn("TrackId").AsInt32().WithDefaultValue(0); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/119_artist_type.cs b/src/NzbDrone.Core/Datastore/Migration/119_artist_type.cs deleted file mode 100644 index 4cef4cca3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/119_artist_type.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(119)] - public class artist_type : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Artists") - .AddColumn("ArtistType").AsString().Nullable() - .AddColumn("Disambiguation").AsString().Nullable(); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/120_artist_album_types.cs b/src/NzbDrone.Core/Datastore/Migration/120_artist_album_types.cs deleted file mode 100644 index 9517a6758..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/120_artist_album_types.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(120)] - public class artist_album_types : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Artists") - .AddColumn("PrimaryAlbumTypes").AsString().Nullable() - .AddColumn("SecondaryAlbumTypes").AsString().Nullable(); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/121_update_types_existing_artist.cs b/src/NzbDrone.Core/Datastore/Migration/121_update_types_existing_artist.cs deleted file mode 100644 index b4eb7da33..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/121_update_types_existing_artist.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(121)] - public class update_types_existing_artist : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Artists SET PrimaryAlbumTypes = '[]', SecondaryAlbumTypes = '[]'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/122_consolidate_indexer_baseurl.cs b/src/NzbDrone.Core/Datastore/Migration/122_consolidate_indexer_baseurl.cs deleted file mode 100644 index a97efade0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/122_consolidate_indexer_baseurl.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(122)] - public class consolidate_indexer_baseurl : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(RenameUrlToBaseUrl); - } - - private void RenameUrlToBaseUrl(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM Indexers WHERE ConfigContract IN ('NewznabSettings', 'TorznabSettings', 'IPTorrentsSettings', 'OmgwtfnzbsSettings')"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settings = reader.GetString(1); - - if (settings.IsNotNullOrWhiteSpace()) - { - var jsonObject = Json.Deserialize(settings); - - if (jsonObject.Property("url") != null) - { - jsonObject.AddFirst(new JProperty("baseUrl", jsonObject["url"])); - jsonObject.Remove("url"); - settings = jsonObject.ToJson(); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE Indexers SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings); - updateCmd.AddParameter(id); - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/123_music_extras.cs b/src/NzbDrone.Core/Datastore/Migration/123_music_extras.cs deleted file mode 100644 index 39ea2dc6b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/123_music_extras.cs +++ /dev/null @@ -1,44 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(123)] - public class music_extras : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("ExtraFiles") - .AddColumn("ArtistId").AsInt32().NotNullable().WithDefaultValue(0) - .AddColumn("AlbumId").AsInt32().NotNullable().WithDefaultValue(0) - .AddColumn("TrackFileId").AsInt32().NotNullable().WithDefaultValue(0); - - Delete.Column("SeriesId").FromTable("ExtraFiles"); - Delete.Column("SeasonNumber").FromTable("ExtraFiles"); - Delete.Column("EpisodeFileId").FromTable("ExtraFiles"); - - Alter.Table("SubtitleFiles") - .AddColumn("ArtistId").AsInt32().NotNullable().WithDefaultValue(0) - .AddColumn("AlbumId").AsInt32().NotNullable().WithDefaultValue(0) - .AddColumn("TrackFileId").AsInt32().NotNullable().WithDefaultValue(0); - - Delete.Column("SeriesId").FromTable("SubtitleFiles"); - Delete.Column("SeasonNumber").FromTable("SubtitleFiles"); - Delete.Column("EpisodeFileId").FromTable("SubtitleFiles"); - - Alter.Table("MetadataFiles") - .AddColumn("ArtistId").AsInt32().NotNullable().WithDefaultValue(0) - .AddColumn("AlbumId").AsInt32().Nullable() - .AddColumn("TrackFileId").AsInt32().Nullable(); - - Delete.Column("SeriesId").FromTable("MetadataFiles"); - Delete.Column("SeasonNumber").FromTable("MetadataFiles"); - Delete.Column("EpisodeFileId").FromTable("MetadataFiles"); - } - - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs index a94ca0bc9..929a89e9d 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Data; using System.Linq; using FluentMigrator; @@ -8,6 +9,7 @@ using FluentMigrator.Runner; using FluentMigrator.Runner.Announcers; using FluentMigrator.Runner.Generators.SQLite; using FluentMigrator.Runner.Processors.SQLite; +using System.Text.RegularExpressions; namespace NzbDrone.Core.Datastore.Migration.Framework { @@ -63,15 +65,55 @@ namespace NzbDrone.Core.Datastore.Migration.Framework ProcessAlterTable(tableDefinition); } + public override void Process(RenameColumnExpression expression) + { + var tableDefinition = GetTableSchema(expression.TableName); + + var oldColumnDefinitions = tableDefinition.Columns.ToList(); + var columnDefinitions = tableDefinition.Columns.ToList(); + var columnIndex = columnDefinitions.FindIndex(c => c.Name == expression.OldName); + + if (columnIndex == -1) + { + throw new ApplicationException(string.Format("Column {0} does not exist on table {1}.", expression.OldName, expression.TableName)); + } + if (columnDefinitions.Any(c => c.Name == expression.NewName)) + { + throw new ApplicationException(string.Format("Column {0} already exists on table {1}.", expression.NewName, expression.TableName)); + } + + oldColumnDefinitions[columnIndex] = (ColumnDefinition)columnDefinitions[columnIndex].Clone(); + columnDefinitions[columnIndex].Name = expression.NewName; + + foreach (var index in tableDefinition.Indexes) + { + if (index.Name.StartsWith("IX_")) + { + index.Name = Regex.Replace(index.Name, "(?<=_)" + Regex.Escape(expression.OldName) + "(?=_|$)", Regex.Escape(expression.NewName)); + } + + foreach (var column in index.Columns) + { + if (column.Name == expression.OldName) + { + column.Name = expression.NewName; + } + } + } + + ProcessAlterTable(tableDefinition, oldColumnDefinitions); + } + + protected virtual TableDefinition GetTableSchema(string tableName) { - var schemaDumper = new SqliteSchemaDumper(this, Announcer); + var schemaDumper = new SqliteSchemaDumper(this, Announcer); var schema = schemaDumper.ReadDbSchema(); return schema.Single(v => v.Name == tableName); } - protected virtual void ProcessAlterTable(TableDefinition tableDefinition) + protected virtual void ProcessAlterTable(TableDefinition tableDefinition, List oldColumnDefinitions = null) { var tableName = tableDefinition.Name; var tempTableName = tableName + "_temp"; @@ -84,11 +126,13 @@ namespace NzbDrone.Core.Datastore.Migration.Framework // What is the cleanest way to do this? Add function to Generator? var quoter = new SQLiteQuoter(); - var columnsToTransfer = string.Join(", ", tableDefinition.Columns.Select(c => quoter.QuoteColumnName(c.Name))); + var columnsToInsert = string.Join(", ", tableDefinition.Columns.Select(c => quoter.QuoteColumnName(c.Name))); + var columnsToFetch = string.Join(", ", (oldColumnDefinitions ?? tableDefinition.Columns).Select(c => quoter.QuoteColumnName(c.Name))); + Process(new CreateTableExpression() { TableName = tempTableName, Columns = tableDefinition.Columns.ToList() }); - Process(string.Format("INSERT INTO {0} SELECT {1} FROM {2}", quoter.QuoteTableName(tempTableName), columnsToTransfer, quoter.QuoteTableName(tableName))); + Process(string.Format("INSERT INTO {0} ({1}) SELECT {2} FROM {3}", quoter.QuoteTableName(tempTableName), columnsToInsert, columnsToFetch, quoter.QuoteTableName(tableName))); Process(new DeleteTableExpression() { TableName = tableName }); diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 50182316f..0c4a3bb7a 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -5,7 +5,6 @@ using Marr.Data.Mapping; using NzbDrone.Common.Reflection; using NzbDrone.Core.Blacklisting; using NzbDrone.Core.Configuration; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Datastore.Converters; using NzbDrone.Core.Datastore.Extensions; using NzbDrone.Core.Download; @@ -31,7 +30,7 @@ using NzbDrone.Core.Authentication; using NzbDrone.Core.Extras.Metadata; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.Extras.Others; -using NzbDrone.Core.Extras.Subtitles; +using NzbDrone.Core.Extras.Lyrics; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Music; using NzbDrone.Core.Languages; @@ -71,8 +70,6 @@ namespace NzbDrone.Core.Datastore .Ignore(d => d.Protocol) .Ignore(d => d.Tags); - Mapper.Entity().RegisterModel("SceneMappings"); - Mapper.Entity().RegisterModel("History") .AutoMapChildModels(); @@ -110,7 +107,7 @@ namespace NzbDrone.Core.Datastore Mapper.Entity().MapResultSet(); Mapper.Entity().RegisterModel("Blacklist"); Mapper.Entity().RegisterModel("MetadataFiles"); - Mapper.Entity().RegisterModel("SubtitleFiles"); + Mapper.Entity().RegisterModel("LyricFiles"); Mapper.Entity().RegisterModel("ExtraFiles"); Mapper.Entity().RegisterModel("PendingReleases") diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 4e05f5fea..e341e6c0d 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Download.Pending private List FilterBlockedIndexers(List releases) { - var blockedIndexers = new HashSet(_indexerStatusService.GetBlockedIndexers().Select(v => v.IndexerId)); + var blockedIndexers = new HashSet(_indexerStatusService.GetBlockedIndexers().Select(v => v.ProviderId)); return releases.Where(release => !blockedIndexers.Contains(release.IndexerId)).ToList(); } diff --git a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs b/src/NzbDrone.Core/Extras/Lyrics/ExistingLyricImporter.cs similarity index 71% rename from src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs rename to src/NzbDrone.Core/Extras/Lyrics/ExistingLyricImporter.cs index 4d6bf2604..7bf9f2998 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs +++ b/src/NzbDrone.Core/Extras/Lyrics/ExistingLyricImporter.cs @@ -7,20 +7,20 @@ using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Parser; using NzbDrone.Core.Music; -namespace NzbDrone.Core.Extras.Subtitles +namespace NzbDrone.Core.Extras.Lyrics { - public class ExistingSubtitleImporter : ImportExistingExtraFilesBase + public class ExistingLyricImporter : ImportExistingExtraFilesBase { - private readonly IExtraFileService _subtitleFileService; + private readonly IExtraFileService _lyricFileService; private readonly IParsingService _parsingService; private readonly Logger _logger; - public ExistingSubtitleImporter(IExtraFileService subtitleFileService, + public ExistingLyricImporter(IExtraFileService lyricFileService, IParsingService parsingService, Logger logger) - : base (subtitleFileService) + : base (lyricFileService) { - _subtitleFileService = subtitleFileService; + _lyricFileService = lyricFileService; _parsingService = parsingService; _logger = logger; } @@ -29,22 +29,22 @@ namespace NzbDrone.Core.Extras.Subtitles public override IEnumerable ProcessFiles(Artist artist, List filesOnDisk, List importedFiles) { - _logger.Debug("Looking for existing subtitle files in {0}", artist.Path); + _logger.Debug("Looking for existing lyrics files in {0}", artist.Path); - var subtitleFiles = new List(); + var subtitleFiles = new List(); var filterResult = FilterAndClean(artist, filesOnDisk, importedFiles); foreach (var possibleSubtitleFile in filterResult.FilesOnDisk) { var extension = Path.GetExtension(possibleSubtitleFile); - if (SubtitleFileExtensions.Extensions.Contains(extension)) + if (LyricFileExtensions.Extensions.Contains(extension)) { var localTrack = _parsingService.GetLocalTrack(possibleSubtitleFile, artist); if (localTrack == null) { - _logger.Debug("Unable to parse subtitle file: {0}", possibleSubtitleFile); + _logger.Debug("Unable to parse lyric file: {0}", possibleSubtitleFile); continue; } @@ -56,11 +56,11 @@ namespace NzbDrone.Core.Extras.Subtitles if (localTrack.Tracks.DistinctBy(e => e.TrackFileId).Count() > 1) { - _logger.Debug("Subtitle file: {0} does not match existing files.", possibleSubtitleFile); + _logger.Debug("Lyric file: {0} does not match existing files.", possibleSubtitleFile); continue; } - var subtitleFile = new SubtitleFile + var subtitleFile = new LyricFile { ArtistId = artist.Id, AlbumId = localTrack.Album.Id, @@ -74,8 +74,8 @@ namespace NzbDrone.Core.Extras.Subtitles } } - _logger.Info("Found {0} existing subtitle files", subtitleFiles.Count); - _subtitleFileService.Upsert(subtitleFiles); + _logger.Info("Found {0} existing lyric files", subtitleFiles.Count); + _lyricFileService.Upsert(subtitleFiles); // Return files that were just imported along with files that were // previously imported so previously imported files aren't imported twice diff --git a/src/NzbDrone.Core/Extras/Lyrics/ImportedLyricFiles.cs b/src/NzbDrone.Core/Extras/Lyrics/ImportedLyricFiles.cs new file mode 100644 index 000000000..abbaa4c74 --- /dev/null +++ b/src/NzbDrone.Core/Extras/Lyrics/ImportedLyricFiles.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using NzbDrone.Core.Extras.Files; + +namespace NzbDrone.Core.Extras.Lyrics +{ + public class ImportedLyricFiles + { + public List SourceFiles { get; set; } + public List LyricFiles { get; set; } + + public ImportedLyricFiles() + { + SourceFiles = new List(); + LyricFiles = new List(); + } + } +} diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFile.cs b/src/NzbDrone.Core/Extras/Lyrics/LyricFile.cs similarity index 60% rename from src/NzbDrone.Core/Extras/Subtitles/SubtitleFile.cs rename to src/NzbDrone.Core/Extras/Lyrics/LyricFile.cs index 7263b4c64..82bd50c27 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFile.cs +++ b/src/NzbDrone.Core/Extras/Lyrics/LyricFile.cs @@ -1,9 +1,9 @@ using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Languages; -namespace NzbDrone.Core.Extras.Subtitles +namespace NzbDrone.Core.Extras.Lyrics { - public class SubtitleFile : ExtraFile + public class LyricFile : ExtraFile { public Language Language { get; set; } } diff --git a/src/NzbDrone.Core/Extras/Lyrics/LyricFileExtensions.cs b/src/NzbDrone.Core/Extras/Lyrics/LyricFileExtensions.cs new file mode 100644 index 000000000..a9b8772a5 --- /dev/null +++ b/src/NzbDrone.Core/Extras/Lyrics/LyricFileExtensions.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace NzbDrone.Core.Extras.Lyrics +{ + public static class LyricFileExtensions + { + private static HashSet _fileExtensions; + + static LyricFileExtensions() + { + _fileExtensions = new HashSet + { + ".lrc", + ".txt", + ".utf", + ".utf8", + ".utf-8" + }; + } + + public static HashSet Extensions => _fileExtensions; + } +} diff --git a/src/NzbDrone.Core/Extras/Lyrics/LyricFileRepository.cs b/src/NzbDrone.Core/Extras/Lyrics/LyricFileRepository.cs new file mode 100644 index 000000000..60fe50f45 --- /dev/null +++ b/src/NzbDrone.Core/Extras/Lyrics/LyricFileRepository.cs @@ -0,0 +1,18 @@ +using NzbDrone.Core.Datastore; +using NzbDrone.Core.Extras.Files; +using NzbDrone.Core.Messaging.Events; + +namespace NzbDrone.Core.Extras.Lyrics +{ + public interface ILyricFileRepository : IExtraFileRepository + { + } + + public class LyricFileRepository : ExtraFileRepository, ILyricFileRepository + { + public LyricFileRepository(IMainDatabase database, IEventAggregator eventAggregator) + : base(database, eventAggregator) + { + } + } +} diff --git a/src/NzbDrone.Core/Extras/Lyrics/LyricFileService.cs b/src/NzbDrone.Core/Extras/Lyrics/LyricFileService.cs new file mode 100644 index 000000000..4d2935ce5 --- /dev/null +++ b/src/NzbDrone.Core/Extras/Lyrics/LyricFileService.cs @@ -0,0 +1,20 @@ +using NLog; +using NzbDrone.Common.Disk; +using NzbDrone.Core.Extras.Files; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.Music; + +namespace NzbDrone.Core.Extras.Lyrics +{ + public interface ILyricFileService : IExtraFileService + { + } + + public class LyricFileService : ExtraFileService, ILyricFileService + { + public LyricFileService(IExtraFileRepository repository, IArtistService artistService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger) + : base(repository, artistService, diskProvider, recycleBinProvider, logger) + { + } + } +} diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs b/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs similarity index 76% rename from src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs rename to src/NzbDrone.Core/Extras/Lyrics/LyricService.cs index b77dad041..679157989 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs +++ b/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs @@ -12,21 +12,21 @@ using NzbDrone.Core.Parser; using NzbDrone.Core.Music; using NzbDrone.Core.Languages; -namespace NzbDrone.Core.Extras.Subtitles +namespace NzbDrone.Core.Extras.Lyrics { - public class SubtitleService : ExtraFileManager + public class LyricService : ExtraFileManager { - private readonly ISubtitleFileService _subtitleFileService; + private readonly ILyricFileService _lyricFileService; private readonly Logger _logger; - public SubtitleService(IConfigService configService, + public LyricService(IConfigService configService, IDiskProvider diskProvider, IDiskTransferService diskTransferService, - ISubtitleFileService subtitleFileService, + ILyricFileService lyricFileService, Logger logger) : base(configService, diskProvider, diskTransferService, logger) { - _subtitleFileService = subtitleFileService; + _lyricFileService = lyricFileService; _logger = logger; } @@ -34,24 +34,24 @@ namespace NzbDrone.Core.Extras.Subtitles public override IEnumerable CreateAfterArtistScan(Artist artist, List albums, List trackFiles) { - return Enumerable.Empty(); + return Enumerable.Empty(); } public override IEnumerable CreateAfterTrackImport(Artist artist, TrackFile trackFile) { - return Enumerable.Empty(); + return Enumerable.Empty(); } public override IEnumerable CreateAfterTrackImport(Artist artist, string artistFolder, string albumFolder) { - return Enumerable.Empty(); + return Enumerable.Empty(); } public override IEnumerable MoveFilesAfterRename(Artist artist, List trackFiles) { - var subtitleFiles = _subtitleFileService.GetFilesByArtist(artist.Id); + var subtitleFiles = _lyricFileService.GetFilesByArtist(artist.Id); - var movedFiles = new List(); + var movedFiles = new List(); foreach (var trackFile in trackFiles) { @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Extras.Subtitles if (groupCount > 1) { - _logger.Warn("Multiple subtitle files found with the same language and extension for {0}", Path.Combine(artist.Path, trackFile.RelativePath)); + _logger.Warn("Multiple lyric files found with the same language and extension for {0}", Path.Combine(artist.Path, trackFile.RelativePath)); } foreach (var subtitleFile in group) @@ -78,21 +78,21 @@ namespace NzbDrone.Core.Extras.Subtitles } } - _subtitleFileService.Upsert(movedFiles); + _lyricFileService.Upsert(movedFiles); return movedFiles; } public override ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly) { - if (SubtitleFileExtensions.Extensions.Contains(Path.GetExtension(path))) + if (LyricFileExtensions.Extensions.Contains(Path.GetExtension(path))) { var language = LanguageParser.ParseSubtitleLanguage(path); var suffix = GetSuffix(language, 1, false); var subtitleFile = ImportFile(artist, trackFile, path, readOnly, extension, suffix); subtitleFile.Language = language; - _subtitleFileService.Upsert(subtitleFile); + _lyricFileService.Upsert(subtitleFile); return subtitleFile; } diff --git a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs index d52680922..be52758d0 100644 --- a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs +++ b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Extras.Metadata.Files; -using NzbDrone.Core.Extras.Subtitles; +using NzbDrone.Core.Extras.Lyrics; using NzbDrone.Core.Parser; using NzbDrone.Core.Music; @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Extras.Metadata { // Don't process files that have known Subtitle file extensions (saves a bit of unecessary processing) - if (SubtitleFileExtensions.Extensions.Contains(Path.GetExtension(possibleMetadataFile))) + if (LyricFileExtensions.Extensions.Contains(Path.GetExtension(possibleMetadataFile))) { continue; } diff --git a/src/NzbDrone.Core/Extras/Subtitles/ImportedSubtitleFiles.cs b/src/NzbDrone.Core/Extras/Subtitles/ImportedSubtitleFiles.cs deleted file mode 100644 index 287ebdb68..000000000 --- a/src/NzbDrone.Core/Extras/Subtitles/ImportedSubtitleFiles.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Extras.Files; - -namespace NzbDrone.Core.Extras.Subtitles -{ - public class ImportedSubtitleFiles - { - public List SourceFiles { get; set; } - public List SubtitleFiles { get; set; } - - public ImportedSubtitleFiles() - { - SourceFiles = new List(); - SubtitleFiles = new List(); - } - } -} diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileExtensions.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileExtensions.cs deleted file mode 100644 index 423d14656..000000000 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.Extras.Subtitles -{ - public static class SubtitleFileExtensions - { - private static HashSet _fileExtensions; - - static SubtitleFileExtensions() - { - _fileExtensions = new HashSet - { - ".aqt", - ".ass", - ".idx", - ".jss", - ".psb", - ".rt", - ".smi", - ".srt", - ".ssa", - ".sub", - ".txt", - ".utf", - ".utf8", - ".utf-8" - }; - } - - public static HashSet Extensions => _fileExtensions; - } -} diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileRepository.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileRepository.cs deleted file mode 100644 index 9b87fa9e0..000000000 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileRepository.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Extras.Files; -using NzbDrone.Core.Messaging.Events; - -namespace NzbDrone.Core.Extras.Subtitles -{ - public interface ISubtitleFileRepository : IExtraFileRepository - { - } - - public class SubtitleFileRepository : ExtraFileRepository, ISubtitleFileRepository - { - public SubtitleFileRepository(IMainDatabase database, IEventAggregator eventAggregator) - : base(database, eventAggregator) - { - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs deleted file mode 100644 index 5194a3139..000000000 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NLog; -using NzbDrone.Common.Disk; -using NzbDrone.Core.Extras.Files; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; - -namespace NzbDrone.Core.Extras.Subtitles -{ - public interface ISubtitleFileService : IExtraFileService - { - } - - public class SubtitleFileService : ExtraFileService, ISubtitleFileService - { - public SubtitleFileService(IExtraFileRepository repository, IArtistService artistService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger) - : base(repository, artistService, diskProvider, recycleBinProvider, logger) - { - } - } -} diff --git a/src/NzbDrone.Core/HealthCheck/Checks/IndexerStatusCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/IndexerStatusCheck.cs index 29eadb180..275c2cb24 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/IndexerStatusCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/IndexerStatusCheck.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.HealthCheck.Checks var enabledIndexers = _indexerFactory.GetAvailableProviders(); var backOffIndexers = enabledIndexers.Join(_indexerStatusService.GetBlockedIndexers(), i => i.Definition.Id, - s => s.IndexerId, + s => s.ProviderId, (i, s) => new { Indexer = i, Status = s }) .Where(v => (v.Status.MostRecentFailure - v.Status.InitialFailure) > TimeSpan.FromHours(1)) .ToList(); diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 7cd886fcb..e129db351 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -4,7 +4,6 @@ using System.Globalization; using System.Threading.Tasks; using NLog; using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Indexers; diff --git a/src/NzbDrone.Core/Indexers/IndexerFactory.cs b/src/NzbDrone.Core/Indexers/IndexerFactory.cs index c4903c9c7..c4ef7ac79 100644 --- a/src/NzbDrone.Core/Indexers/IndexerFactory.cs +++ b/src/NzbDrone.Core/Indexers/IndexerFactory.cs @@ -70,7 +70,7 @@ namespace NzbDrone.Core.Indexers private IEnumerable FilterBlockedIndexers(IEnumerable indexers) { - var blockedIndexers = _indexerStatusService.GetBlockedIndexers().ToDictionary(v => v.IndexerId, v => v); + var blockedIndexers = _indexerStatusService.GetBlockedIndexers().ToDictionary(v => v.ProviderId, v => v); foreach (var indexer in indexers) { diff --git a/src/NzbDrone.Core/Indexers/IndexerStatus.cs b/src/NzbDrone.Core/Indexers/IndexerStatus.cs index 662c9de64..92830490d 100644 --- a/src/NzbDrone.Core/Indexers/IndexerStatus.cs +++ b/src/NzbDrone.Core/Indexers/IndexerStatus.cs @@ -6,7 +6,7 @@ namespace NzbDrone.Core.Indexers { public class IndexerStatus : ModelBase { - public int IndexerId { get; set; } + public int ProviderId { get; set; } public DateTime? InitialFailure { get; set; } public DateTime? MostRecentFailure { get; set; } diff --git a/src/NzbDrone.Core/Indexers/IndexerStatusRepository.cs b/src/NzbDrone.Core/Indexers/IndexerStatusRepository.cs index 8a70b790a..79173ff6b 100644 --- a/src/NzbDrone.Core/Indexers/IndexerStatusRepository.cs +++ b/src/NzbDrone.Core/Indexers/IndexerStatusRepository.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers public IndexerStatus FindByIndexerId(int indexerId) { - return Query.Where(c => c.IndexerId == indexerId).SingleOrDefault(); + return Query.Where(c => c.ProviderId == indexerId).SingleOrDefault(); } } } diff --git a/src/NzbDrone.Core/Indexers/IndexerStatusService.cs b/src/NzbDrone.Core/Indexers/IndexerStatusService.cs index 8e1bd1fe5..09be1f00b 100644 --- a/src/NzbDrone.Core/Indexers/IndexerStatusService.cs +++ b/src/NzbDrone.Core/Indexers/IndexerStatusService.cs @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Indexers private IndexerStatus GetIndexerStatus(int indexerId) { - return _indexerStatusRepository.FindByIndexerId(indexerId) ?? new IndexerStatus { IndexerId = indexerId }; + return _indexerStatusRepository.FindByIndexerId(indexerId) ?? new IndexerStatus { ProviderId = indexerId }; } private TimeSpan CalculateBackOffPeriod(IndexerStatus status) diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index c728379ef..fbc63abbd 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -5,7 +5,6 @@ using NLog; using NzbDrone.Core.Backup; using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration.Events; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Download; using NzbDrone.Core.HealthCheck; using NzbDrone.Core.Housekeeping; diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 5eb7c1c0b..4eb93c459 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -183,7 +183,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook artist.ForeignArtistId = resource.Id; artist.Genres = resource.Genres; artist.Overview = resource.Overview; - artist.NameSlug = Parser.Parser.CleanArtistName(artist.Name); + artist.NameSlug = Parser.Parser.CleanArtistName(artist.Name) + "-" + resource.Id.Substring(resource.Id.Length - 6); artist.CleanName = Parser.Parser.CleanArtistName(artist.Name); artist.SortName = Parser.Parser.NormalizeTitle(artist.Name); artist.Disambiguation = resource.Disambiguation; diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 0bbdd6486..27e832e38 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -143,14 +143,6 @@ - - - - - - - - @@ -178,128 +170,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - @@ -556,13 +426,13 @@ - - - - - - - + + + + + + + diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index a89a7c3a1..3f270deea 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; @@ -167,7 +166,7 @@ namespace NzbDrone.Core.Parser if (artist == null) { - _logger.Debug("No matching series {0}", parsedAlbumInfo.ArtistName); + _logger.Debug("No matching artist {0}", parsedAlbumInfo.ArtistName); return null; }