using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Jellyfin.Database.Providers.Postgres.Migrations
{
    /// <inheritdoc />
    public partial class AddUserDataRowVersion : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AccessSchedules_Users_UserId",
                schema: "users",
                table: "AccessSchedules");

            migrationBuilder.DropForeignKey(
                name: "FK_AncestorIds_BaseItems_ItemId",
                schema: "library",
                table: "AncestorIds");

            migrationBuilder.DropForeignKey(
                name: "FK_AncestorIds_BaseItems_ParentItemId",
                schema: "library",
                table: "AncestorIds");

            migrationBuilder.DropForeignKey(
                name: "FK_AttachmentStreamInfos_BaseItems_ItemId",
                schema: "library",
                table: "AttachmentStreamInfos");

            migrationBuilder.DropForeignKey(
                name: "FK_AudioStreamDetails_MediaStreamInfos_ItemId_StreamIndex",
                schema: "library",
                table: "AudioStreamDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItemAudioExtras_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemAudioExtras");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItemImageInfos_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemImageInfos");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItemLiveTvExtras_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemLiveTvExtras");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItemMetadataFields_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemMetadataFields");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItemProviders_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemProviders");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItems_BaseItems_ParentId",
                schema: "library",
                table: "BaseItems");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItemTrailerTypes_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemTrailerTypes");

            migrationBuilder.DropForeignKey(
                name: "FK_BaseItemTvExtras_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemTvExtras");

            migrationBuilder.DropForeignKey(
                name: "FK_Chapters_BaseItems_ItemId",
                schema: "library",
                table: "Chapters");

            migrationBuilder.DropForeignKey(
                name: "FK_Devices_Users_UserId",
                schema: "authentication",
                table: "Devices");

            migrationBuilder.DropForeignKey(
                name: "FK_DisplayPreferences_Users_UserId",
                schema: "displaypreferences",
                table: "DisplayPreferences");

            migrationBuilder.DropForeignKey(
                name: "FK_HomeSection_DisplayPreferences_DisplayPreferencesId",
                schema: "displaypreferences",
                table: "HomeSection");

            migrationBuilder.DropForeignKey(
                name: "FK_ImageInfos_Users_UserId",
                schema: "library",
                table: "ImageInfos");

            migrationBuilder.DropForeignKey(
                name: "FK_ItemDisplayPreferences_Users_UserId",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences");

            migrationBuilder.DropForeignKey(
                name: "FK_ItemValuesMap_BaseItems_ItemId",
                schema: "library",
                table: "ItemValuesMap");

            migrationBuilder.DropForeignKey(
                name: "FK_ItemValuesMap_ItemValues_ItemValueId",
                schema: "library",
                table: "ItemValuesMap");

            migrationBuilder.DropForeignKey(
                name: "FK_KeyframeData_BaseItems_ItemId",
                schema: "library",
                table: "KeyframeData");

            migrationBuilder.DropForeignKey(
                name: "FK_MediaStreamInfos_BaseItems_ItemId",
                schema: "library",
                table: "MediaStreamInfos");

            migrationBuilder.DropForeignKey(
                name: "FK_PeopleBaseItemMap_BaseItems_ItemId",
                schema: "library",
                table: "PeopleBaseItemMap");

            migrationBuilder.DropForeignKey(
                name: "FK_PeopleBaseItemMap_Peoples_PeopleId",
                schema: "library",
                table: "PeopleBaseItemMap");

            migrationBuilder.DropForeignKey(
                name: "FK_Permissions_Users_UserId",
                schema: "users",
                table: "Permissions");

            migrationBuilder.DropForeignKey(
                name: "FK_Preferences_Users_UserId",
                schema: "users",
                table: "Preferences");

            migrationBuilder.DropForeignKey(
                name: "FK_UserData_BaseItems_ItemId",
                schema: "library",
                table: "UserData");

            migrationBuilder.DropForeignKey(
                name: "FK_UserData_Users_UserId",
                schema: "library",
                table: "UserData");

            migrationBuilder.DropForeignKey(
                name: "FK_VideoStreamDetails_MediaStreamInfos_ItemId_StreamIndex",
                schema: "library",
                table: "VideoStreamDetails");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Users",
                schema: "users",
                table: "Users");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Preferences",
                schema: "users",
                table: "Preferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Permissions",
                schema: "users",
                table: "Permissions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Peoples",
                schema: "library",
                table: "Peoples");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Devices",
                schema: "authentication",
                table: "Devices");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Chapters",
                schema: "library",
                table: "Chapters");

            migrationBuilder.DropPrimaryKey(
                name: "PK_VideoStreamDetails",
                schema: "library",
                table: "VideoStreamDetails");

            migrationBuilder.DropPrimaryKey(
                name: "PK_UserData",
                schema: "library",
                table: "UserData");

            migrationBuilder.DropPrimaryKey(
                name: "PK_TrickplayInfos",
                schema: "library",
                table: "TrickplayInfos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PeopleBaseItemMap",
                schema: "library",
                table: "PeopleBaseItemMap");

            migrationBuilder.DropPrimaryKey(
                name: "PK_MediaStreamInfos",
                schema: "library",
                table: "MediaStreamInfos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_MediaSegments",
                schema: "library",
                table: "MediaSegments");

            migrationBuilder.DropPrimaryKey(
                name: "PK_KeyframeData",
                schema: "library",
                table: "KeyframeData");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ItemValuesMap",
                schema: "library",
                table: "ItemValuesMap");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ItemValues",
                schema: "library",
                table: "ItemValues");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ItemDisplayPreferences",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ImageInfos",
                schema: "library",
                table: "ImageInfos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_HomeSection",
                schema: "displaypreferences",
                table: "HomeSection");

            migrationBuilder.DropPrimaryKey(
                name: "PK_DisplayPreferences",
                schema: "displaypreferences",
                table: "DisplayPreferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_DeviceOptions",
                schema: "authentication",
                table: "DeviceOptions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_CustomItemDisplayPreferences",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItemTvExtras",
                schema: "library",
                table: "BaseItemTvExtras");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItemTrailerTypes",
                schema: "library",
                table: "BaseItemTrailerTypes");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItems",
                schema: "library",
                table: "BaseItems");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItemProviders",
                schema: "library",
                table: "BaseItemProviders");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItemMetadataFields",
                schema: "library",
                table: "BaseItemMetadataFields");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItemLiveTvExtras",
                schema: "library",
                table: "BaseItemLiveTvExtras");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItemImageInfos",
                schema: "library",
                table: "BaseItemImageInfos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseItemAudioExtras",
                schema: "library",
                table: "BaseItemAudioExtras");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AudioStreamDetails",
                schema: "library",
                table: "AudioStreamDetails");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AttachmentStreamInfos",
                schema: "library",
                table: "AttachmentStreamInfos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ApiKeys",
                schema: "authentication",
                table: "ApiKeys");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AncestorIds",
                schema: "library",
                table: "AncestorIds");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ActivityLogs",
                schema: "activitylog",
                table: "ActivityLogs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AccessSchedules",
                schema: "users",
                table: "AccessSchedules");

            migrationBuilder.RenameTable(
                name: "Users",
                schema: "users",
                newName: "users",
                newSchema: "users");

            migrationBuilder.RenameTable(
                name: "Preferences",
                schema: "users",
                newName: "preferences",
                newSchema: "users");

            migrationBuilder.RenameTable(
                name: "Permissions",
                schema: "users",
                newName: "permissions",
                newSchema: "users");

            migrationBuilder.RenameTable(
                name: "Peoples",
                schema: "library",
                newName: "peoples",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "Devices",
                schema: "authentication",
                newName: "devices",
                newSchema: "authentication");

            migrationBuilder.RenameTable(
                name: "Chapters",
                schema: "library",
                newName: "chapters",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "VideoStreamDetails",
                schema: "library",
                newName: "video_stream_details",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "UserData",
                schema: "library",
                newName: "user_data",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "TrickplayInfos",
                schema: "library",
                newName: "trickplay_infos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "PeopleBaseItemMap",
                schema: "library",
                newName: "people_base_item_map",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "MediaStreamInfos",
                schema: "library",
                newName: "media_stream_infos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "MediaSegments",
                schema: "library",
                newName: "media_segments",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "KeyframeData",
                schema: "library",
                newName: "keyframe_data",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "ItemValuesMap",
                schema: "library",
                newName: "item_values_map",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "ItemValues",
                schema: "library",
                newName: "item_values",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "ItemDisplayPreferences",
                schema: "displaypreferences",
                newName: "item_display_preferences",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "ImageInfos",
                schema: "library",
                newName: "image_infos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "HomeSection",
                schema: "displaypreferences",
                newName: "home_sections",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "DisplayPreferences",
                schema: "displaypreferences",
                newName: "display_preferences",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "DeviceOptions",
                schema: "authentication",
                newName: "device_options",
                newSchema: "authentication");

            migrationBuilder.RenameTable(
                name: "CustomItemDisplayPreferences",
                schema: "displaypreferences",
                newName: "custom_item_display_preferences",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "BaseItemTvExtras",
                schema: "library",
                newName: "base_item_tv_extras",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "BaseItemTrailerTypes",
                schema: "library",
                newName: "base_item_trailer_types",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "BaseItems",
                schema: "library",
                newName: "base_items",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "BaseItemProviders",
                schema: "library",
                newName: "base_item_providers",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "BaseItemMetadataFields",
                schema: "library",
                newName: "base_item_metadata_fields",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "BaseItemLiveTvExtras",
                schema: "library",
                newName: "base_item_live_tv_extras",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "BaseItemImageInfos",
                schema: "library",
                newName: "base_item_image_infos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "BaseItemAudioExtras",
                schema: "library",
                newName: "base_item_audio_extras",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "AudioStreamDetails",
                schema: "library",
                newName: "audio_stream_details",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "AttachmentStreamInfos",
                schema: "library",
                newName: "attachment_stream_infos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "ApiKeys",
                schema: "authentication",
                newName: "api_keys",
                newSchema: "authentication");

            migrationBuilder.RenameTable(
                name: "AncestorIds",
                schema: "library",
                newName: "ancestor_ids",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "ActivityLogs",
                schema: "activitylog",
                newName: "activity_logs",
                newSchema: "activitylog");

            migrationBuilder.RenameTable(
                name: "AccessSchedules",
                schema: "users",
                newName: "access_schedules",
                newSchema: "users");

            migrationBuilder.RenameColumn(
                name: "Username",
                schema: "users",
                table: "users",
                newName: "username");

            migrationBuilder.RenameColumn(
                name: "Password",
                schema: "users",
                table: "users",
                newName: "password");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "users",
                table: "users",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "SyncPlayAccess",
                schema: "users",
                table: "users",
                newName: "sync_play_access");

            migrationBuilder.RenameColumn(
                name: "SubtitleMode",
                schema: "users",
                table: "users",
                newName: "subtitle_mode");

            migrationBuilder.RenameColumn(
                name: "SubtitleLanguagePreference",
                schema: "users",
                table: "users",
                newName: "subtitle_language_preference");

            migrationBuilder.RenameColumn(
                name: "RowVersion",
                schema: "users",
                table: "users",
                newName: "row_version");

            migrationBuilder.RenameColumn(
                name: "RemoteClientBitrateLimit",
                schema: "users",
                table: "users",
                newName: "remote_client_bitrate_limit");

            migrationBuilder.RenameColumn(
                name: "RememberSubtitleSelections",
                schema: "users",
                table: "users",
                newName: "remember_subtitle_selections");

            migrationBuilder.RenameColumn(
                name: "RememberAudioSelections",
                schema: "users",
                table: "users",
                newName: "remember_audio_selections");

            migrationBuilder.RenameColumn(
                name: "PlayDefaultAudioTrack",
                schema: "users",
                table: "users",
                newName: "play_default_audio_track");

            migrationBuilder.RenameColumn(
                name: "PasswordResetProviderId",
                schema: "users",
                table: "users",
                newName: "password_reset_provider_id");

            migrationBuilder.RenameColumn(
                name: "MustUpdatePassword",
                schema: "users",
                table: "users",
                newName: "must_update_password");

            migrationBuilder.RenameColumn(
                name: "MaxParentalRatingSubScore",
                schema: "users",
                table: "users",
                newName: "max_parental_rating_sub_score");

            migrationBuilder.RenameColumn(
                name: "MaxParentalRatingScore",
                schema: "users",
                table: "users",
                newName: "max_parental_rating_score");

            migrationBuilder.RenameColumn(
                name: "MaxActiveSessions",
                schema: "users",
                table: "users",
                newName: "max_active_sessions");

            migrationBuilder.RenameColumn(
                name: "LoginAttemptsBeforeLockout",
                schema: "users",
                table: "users",
                newName: "login_attempts_before_lockout");

            migrationBuilder.RenameColumn(
                name: "LastLoginDate",
                schema: "users",
                table: "users",
                newName: "last_login_date");

            migrationBuilder.RenameColumn(
                name: "LastActivityDate",
                schema: "users",
                table: "users",
                newName: "last_activity_date");

            migrationBuilder.RenameColumn(
                name: "InvalidLoginAttemptCount",
                schema: "users",
                table: "users",
                newName: "invalid_login_attempt_count");

            migrationBuilder.RenameColumn(
                name: "InternalId",
                schema: "users",
                table: "users",
                newName: "internal_id");

            migrationBuilder.RenameColumn(
                name: "HidePlayedInLatest",
                schema: "users",
                table: "users",
                newName: "hide_played_in_latest");

            migrationBuilder.RenameColumn(
                name: "EnableUserPreferenceAccess",
                schema: "users",
                table: "users",
                newName: "enable_user_preference_access");

            migrationBuilder.RenameColumn(
                name: "EnableNextEpisodeAutoPlay",
                schema: "users",
                table: "users",
                newName: "enable_next_episode_auto_play");

            migrationBuilder.RenameColumn(
                name: "EnableLocalPassword",
                schema: "users",
                table: "users",
                newName: "enable_local_password");

            migrationBuilder.RenameColumn(
                name: "EnableAutoLogin",
                schema: "users",
                table: "users",
                newName: "enable_auto_login");

            migrationBuilder.RenameColumn(
                name: "DisplayMissingEpisodes",
                schema: "users",
                table: "users",
                newName: "display_missing_episodes");

            migrationBuilder.RenameColumn(
                name: "DisplayCollectionsView",
                schema: "users",
                table: "users",
                newName: "display_collections_view");

            migrationBuilder.RenameColumn(
                name: "CastReceiverId",
                schema: "users",
                table: "users",
                newName: "cast_receiver_id");

            migrationBuilder.RenameColumn(
                name: "AuthenticationProviderId",
                schema: "users",
                table: "users",
                newName: "authentication_provider_id");

            migrationBuilder.RenameColumn(
                name: "AudioLanguagePreference",
                schema: "users",
                table: "users",
                newName: "audio_language_preference");

            migrationBuilder.RenameIndex(
                name: "IX_Users_Username",
                schema: "users",
                table: "users",
                newName: "IX_users_username");

            migrationBuilder.RenameColumn(
                name: "Value",
                schema: "users",
                table: "preferences",
                newName: "value");

            migrationBuilder.RenameColumn(
                name: "Preference_Preferences_Guid",
                schema: "users",
                table: "preferences",
                newName: "preference_preferences_guid");

            migrationBuilder.RenameColumn(
                name: "Kind",
                schema: "users",
                table: "preferences",
                newName: "kind");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "users",
                table: "preferences",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "users",
                table: "preferences",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "RowVersion",
                schema: "users",
                table: "preferences",
                newName: "row_version");

            migrationBuilder.RenameIndex(
                name: "IX_Preferences_UserId_Kind",
                schema: "users",
                table: "preferences",
                newName: "IX_preferences_user_id_kind");

            migrationBuilder.RenameColumn(
                name: "Value",
                schema: "users",
                table: "permissions",
                newName: "value");

            migrationBuilder.RenameColumn(
                name: "Permission_Permissions_Guid",
                schema: "users",
                table: "permissions",
                newName: "permission_permissions_guid");

            migrationBuilder.RenameColumn(
                name: "Kind",
                schema: "users",
                table: "permissions",
                newName: "kind");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "users",
                table: "permissions",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "users",
                table: "permissions",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "RowVersion",
                schema: "users",
                table: "permissions",
                newName: "row_version");

            migrationBuilder.RenameIndex(
                name: "IX_Permissions_UserId_Kind",
                schema: "users",
                table: "permissions",
                newName: "IX_permissions_user_id_kind");

            migrationBuilder.RenameColumn(
                name: "Name",
                schema: "library",
                table: "peoples",
                newName: "name");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "library",
                table: "peoples",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "PersonType",
                schema: "library",
                table: "peoples",
                newName: "person_type");

            migrationBuilder.RenameIndex(
                name: "IX_Peoples_Name",
                schema: "library",
                table: "peoples",
                newName: "IX_peoples_name");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "authentication",
                table: "devices",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "authentication",
                table: "devices",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "IsActive",
                schema: "authentication",
                table: "devices",
                newName: "is_active");

            migrationBuilder.RenameColumn(
                name: "DeviceName",
                schema: "authentication",
                table: "devices",
                newName: "device_name");

            migrationBuilder.RenameColumn(
                name: "DeviceId",
                schema: "authentication",
                table: "devices",
                newName: "device_id");

            migrationBuilder.RenameColumn(
                name: "DateModified",
                schema: "authentication",
                table: "devices",
                newName: "date_modified");

            migrationBuilder.RenameColumn(
                name: "DateLastActivity",
                schema: "authentication",
                table: "devices",
                newName: "date_last_activity");

            migrationBuilder.RenameColumn(
                name: "DateCreated",
                schema: "authentication",
                table: "devices",
                newName: "date_created");

            migrationBuilder.RenameColumn(
                name: "AppVersion",
                schema: "authentication",
                table: "devices",
                newName: "app_version");

            migrationBuilder.RenameColumn(
                name: "AppName",
                schema: "authentication",
                table: "devices",
                newName: "app_name");

            migrationBuilder.RenameColumn(
                name: "AccessToken",
                schema: "authentication",
                table: "devices",
                newName: "access_token");

            migrationBuilder.RenameIndex(
                name: "IX_Devices_UserId_DeviceId",
                schema: "authentication",
                table: "devices",
                newName: "IX_devices_user_id_device_id");

            migrationBuilder.RenameIndex(
                name: "IX_Devices_DeviceId_DateLastActivity",
                schema: "authentication",
                table: "devices",
                newName: "IX_devices_device_id_date_last_activity");

            migrationBuilder.RenameIndex(
                name: "IX_Devices_DeviceId",
                schema: "authentication",
                table: "devices",
                newName: "IX_devices_device_id");

            migrationBuilder.RenameIndex(
                name: "IX_Devices_AccessToken_DateLastActivity",
                schema: "authentication",
                table: "devices",
                newName: "IX_devices_access_token_date_last_activity");

            migrationBuilder.RenameColumn(
                name: "Name",
                schema: "library",
                table: "chapters",
                newName: "name");

            migrationBuilder.RenameColumn(
                name: "StartPositionTicks",
                schema: "library",
                table: "chapters",
                newName: "start_position_ticks");

            migrationBuilder.RenameColumn(
                name: "ImagePath",
                schema: "library",
                table: "chapters",
                newName: "image_path");

            migrationBuilder.RenameColumn(
                name: "ImageDateModified",
                schema: "library",
                table: "chapters",
                newName: "image_date_modified");

            migrationBuilder.RenameColumn(
                name: "ChapterIndex",
                schema: "library",
                table: "chapters",
                newName: "chapter_index");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "chapters",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "Width",
                schema: "library",
                table: "video_stream_details",
                newName: "width");

            migrationBuilder.RenameColumn(
                name: "Rotation",
                schema: "library",
                table: "video_stream_details",
                newName: "rotation");

            migrationBuilder.RenameColumn(
                name: "Height",
                schema: "library",
                table: "video_stream_details",
                newName: "height");

            migrationBuilder.RenameColumn(
                name: "RpuPresentFlag",
                schema: "library",
                table: "video_stream_details",
                newName: "rpu_present_flag");

            migrationBuilder.RenameColumn(
                name: "RefFrames",
                schema: "library",
                table: "video_stream_details",
                newName: "ref_frames");

            migrationBuilder.RenameColumn(
                name: "RealFrameRate",
                schema: "library",
                table: "video_stream_details",
                newName: "real_frame_rate");

            migrationBuilder.RenameColumn(
                name: "PixelFormat",
                schema: "library",
                table: "video_stream_details",
                newName: "pixel_format");

            migrationBuilder.RenameColumn(
                name: "NalLengthSize",
                schema: "library",
                table: "video_stream_details",
                newName: "nal_length_size");

            migrationBuilder.RenameColumn(
                name: "KeyFrames",
                schema: "library",
                table: "video_stream_details",
                newName: "key_frames");

            migrationBuilder.RenameColumn(
                name: "IsInterlaced",
                schema: "library",
                table: "video_stream_details",
                newName: "is_interlaced");

            migrationBuilder.RenameColumn(
                name: "IsAnamorphic",
                schema: "library",
                table: "video_stream_details",
                newName: "is_anamorphic");

            migrationBuilder.RenameColumn(
                name: "Hdr10PlusPresentFlag",
                schema: "library",
                table: "video_stream_details",
                newName: "hdr10_plus_present_flag");

            migrationBuilder.RenameColumn(
                name: "ElPresentFlag",
                schema: "library",
                table: "video_stream_details",
                newName: "el_present_flag");

            migrationBuilder.RenameColumn(
                name: "DvVersionMinor",
                schema: "library",
                table: "video_stream_details",
                newName: "dv_version_minor");

            migrationBuilder.RenameColumn(
                name: "DvVersionMajor",
                schema: "library",
                table: "video_stream_details",
                newName: "dv_version_major");

            migrationBuilder.RenameColumn(
                name: "DvProfile",
                schema: "library",
                table: "video_stream_details",
                newName: "dv_profile");

            migrationBuilder.RenameColumn(
                name: "DvLevel",
                schema: "library",
                table: "video_stream_details",
                newName: "dv_level");

            migrationBuilder.RenameColumn(
                name: "DvBlSignalCompatibilityId",
                schema: "library",
                table: "video_stream_details",
                newName: "dv_bl_signal_compatibility_id");

            migrationBuilder.RenameColumn(
                name: "ColorTransfer",
                schema: "library",
                table: "video_stream_details",
                newName: "color_transfer");

            migrationBuilder.RenameColumn(
                name: "ColorSpace",
                schema: "library",
                table: "video_stream_details",
                newName: "color_space");

            migrationBuilder.RenameColumn(
                name: "ColorPrimaries",
                schema: "library",
                table: "video_stream_details",
                newName: "color_primaries");

            migrationBuilder.RenameColumn(
                name: "BlPresentFlag",
                schema: "library",
                table: "video_stream_details",
                newName: "bl_present_flag");

            migrationBuilder.RenameColumn(
                name: "BitDepth",
                schema: "library",
                table: "video_stream_details",
                newName: "bit_depth");

            migrationBuilder.RenameColumn(
                name: "AverageFrameRate",
                schema: "library",
                table: "video_stream_details",
                newName: "average_frame_rate");

            migrationBuilder.RenameColumn(
                name: "AspectRatio",
                schema: "library",
                table: "video_stream_details",
                newName: "aspect_ratio");

            migrationBuilder.RenameColumn(
                name: "StreamIndex",
                schema: "library",
                table: "video_stream_details",
                newName: "stream_index");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "video_stream_details",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "Rating",
                schema: "library",
                table: "user_data",
                newName: "rating");

            migrationBuilder.RenameColumn(
                name: "Played",
                schema: "library",
                table: "user_data",
                newName: "played");

            migrationBuilder.RenameColumn(
                name: "Likes",
                schema: "library",
                table: "user_data",
                newName: "likes");

            migrationBuilder.RenameColumn(
                name: "SubtitleStreamIndex",
                schema: "library",
                table: "user_data",
                newName: "subtitle_stream_index");

            migrationBuilder.RenameColumn(
                name: "RetentionDate",
                schema: "library",
                table: "user_data",
                newName: "retention_date");

            migrationBuilder.RenameColumn(
                name: "PlaybackPositionTicks",
                schema: "library",
                table: "user_data",
                newName: "playback_position_ticks");

            migrationBuilder.RenameColumn(
                name: "PlayCount",
                schema: "library",
                table: "user_data",
                newName: "play_count");

            migrationBuilder.RenameColumn(
                name: "LastPlayedDate",
                schema: "library",
                table: "user_data",
                newName: "last_played_date");

            migrationBuilder.RenameColumn(
                name: "IsFavorite",
                schema: "library",
                table: "user_data",
                newName: "is_favorite");

            migrationBuilder.RenameColumn(
                name: "AudioStreamIndex",
                schema: "library",
                table: "user_data",
                newName: "audio_stream_index");

            migrationBuilder.RenameColumn(
                name: "CustomDataKey",
                schema: "library",
                table: "user_data",
                newName: "custom_data_key");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "library",
                table: "user_data",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "user_data",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_UserData_UserId",
                schema: "library",
                table: "user_data",
                newName: "IX_user_data_user_id");

            migrationBuilder.RenameIndex(
                name: "IX_UserData_ItemId_UserId_Played",
                schema: "library",
                table: "user_data",
                newName: "IX_user_data_item_id_user_id_played");

            migrationBuilder.RenameIndex(
                name: "IX_UserData_ItemId_UserId_PlaybackPositionTicks",
                schema: "library",
                table: "user_data",
                newName: "IX_user_data_item_id_user_id_playback_position_ticks");

            migrationBuilder.RenameIndex(
                name: "IX_UserData_ItemId_UserId_LastPlayedDate",
                schema: "library",
                table: "user_data",
                newName: "IX_user_data_item_id_user_id_last_played_date");

            migrationBuilder.RenameIndex(
                name: "IX_UserData_ItemId_UserId_IsFavorite",
                schema: "library",
                table: "user_data",
                newName: "IX_user_data_item_id_user_id_is_favorite");

            migrationBuilder.RenameColumn(
                name: "Interval",
                schema: "library",
                table: "trickplay_infos",
                newName: "interval");

            migrationBuilder.RenameColumn(
                name: "Height",
                schema: "library",
                table: "trickplay_infos",
                newName: "height");

            migrationBuilder.RenameColumn(
                name: "Bandwidth",
                schema: "library",
                table: "trickplay_infos",
                newName: "bandwidth");

            migrationBuilder.RenameColumn(
                name: "Width",
                schema: "library",
                table: "trickplay_infos",
                newName: "width");

            migrationBuilder.RenameColumn(
                name: "TileWidth",
                schema: "library",
                table: "trickplay_infos",
                newName: "tile_width");

            migrationBuilder.RenameColumn(
                name: "TileHeight",
                schema: "library",
                table: "trickplay_infos",
                newName: "tile_height");

            migrationBuilder.RenameColumn(
                name: "ThumbnailCount",
                schema: "library",
                table: "trickplay_infos",
                newName: "thumbnail_count");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "trickplay_infos",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "Role",
                schema: "library",
                table: "people_base_item_map",
                newName: "role");

            migrationBuilder.RenameColumn(
                name: "SortOrder",
                schema: "library",
                table: "people_base_item_map",
                newName: "sort_order");

            migrationBuilder.RenameColumn(
                name: "ListOrder",
                schema: "library",
                table: "people_base_item_map",
                newName: "list_order");

            migrationBuilder.RenameColumn(
                name: "PeopleId",
                schema: "library",
                table: "people_base_item_map",
                newName: "people_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "people_base_item_map",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_PeopleBaseItemMap_PeopleId",
                schema: "library",
                table: "people_base_item_map",
                newName: "IX_people_base_item_map_people_id");

            migrationBuilder.RenameIndex(
                name: "IX_PeopleBaseItemMap_ItemId_SortOrder",
                schema: "library",
                table: "people_base_item_map",
                newName: "IX_people_base_item_map_item_id_sort_order");

            migrationBuilder.RenameIndex(
                name: "IX_PeopleBaseItemMap_ItemId_ListOrder",
                schema: "library",
                table: "people_base_item_map",
                newName: "IX_people_base_item_map_item_id_list_order");

            migrationBuilder.RenameColumn(
                name: "Title",
                schema: "library",
                table: "media_stream_infos",
                newName: "title");

            migrationBuilder.RenameColumn(
                name: "Profile",
                schema: "library",
                table: "media_stream_infos",
                newName: "profile");

            migrationBuilder.RenameColumn(
                name: "Path",
                schema: "library",
                table: "media_stream_infos",
                newName: "path");

            migrationBuilder.RenameColumn(
                name: "Level",
                schema: "library",
                table: "media_stream_infos",
                newName: "level");

            migrationBuilder.RenameColumn(
                name: "Language",
                schema: "library",
                table: "media_stream_infos",
                newName: "language");

            migrationBuilder.RenameColumn(
                name: "Comment",
                schema: "library",
                table: "media_stream_infos",
                newName: "comment");

            migrationBuilder.RenameColumn(
                name: "Codec",
                schema: "library",
                table: "media_stream_infos",
                newName: "codec");

            migrationBuilder.RenameColumn(
                name: "TimeBase",
                schema: "library",
                table: "media_stream_infos",
                newName: "time_base");

            migrationBuilder.RenameColumn(
                name: "StreamType",
                schema: "library",
                table: "media_stream_infos",
                newName: "stream_type");

            migrationBuilder.RenameColumn(
                name: "IsForced",
                schema: "library",
                table: "media_stream_infos",
                newName: "is_forced");

            migrationBuilder.RenameColumn(
                name: "IsExternal",
                schema: "library",
                table: "media_stream_infos",
                newName: "is_external");

            migrationBuilder.RenameColumn(
                name: "IsDefault",
                schema: "library",
                table: "media_stream_infos",
                newName: "is_default");

            migrationBuilder.RenameColumn(
                name: "IsAvc",
                schema: "library",
                table: "media_stream_infos",
                newName: "is_avc");

            migrationBuilder.RenameColumn(
                name: "CodecTimeBase",
                schema: "library",
                table: "media_stream_infos",
                newName: "codec_time_base");

            migrationBuilder.RenameColumn(
                name: "CodecTag",
                schema: "library",
                table: "media_stream_infos",
                newName: "codec_tag");

            migrationBuilder.RenameColumn(
                name: "BitRate",
                schema: "library",
                table: "media_stream_infos",
                newName: "bit_rate");

            migrationBuilder.RenameColumn(
                name: "StreamIndex",
                schema: "library",
                table: "media_stream_infos",
                newName: "stream_index");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "media_stream_infos",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_MediaStreamInfos_StreamType",
                schema: "library",
                table: "media_stream_infos",
                newName: "IX_media_stream_infos_stream_type");

            migrationBuilder.RenameIndex(
                name: "IX_MediaStreamInfos_StreamIndex_StreamType_Language",
                schema: "library",
                table: "media_stream_infos",
                newName: "IX_media_stream_infos_stream_index_stream_type_language");

            migrationBuilder.RenameIndex(
                name: "IX_MediaStreamInfos_StreamIndex_StreamType",
                schema: "library",
                table: "media_stream_infos",
                newName: "IX_media_stream_infos_stream_index_stream_type");

            migrationBuilder.RenameIndex(
                name: "IX_MediaStreamInfos_StreamIndex",
                schema: "library",
                table: "media_stream_infos",
                newName: "IX_media_stream_infos_stream_index");

            migrationBuilder.RenameColumn(
                name: "Type",
                schema: "library",
                table: "media_segments",
                newName: "type");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "library",
                table: "media_segments",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "StartTicks",
                schema: "library",
                table: "media_segments",
                newName: "start_ticks");

            migrationBuilder.RenameColumn(
                name: "SegmentProviderId",
                schema: "library",
                table: "media_segments",
                newName: "segment_provider_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "media_segments",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "EndTicks",
                schema: "library",
                table: "media_segments",
                newName: "end_ticks");

            migrationBuilder.RenameColumn(
                name: "TotalDuration",
                schema: "library",
                table: "keyframe_data",
                newName: "total_duration");

            migrationBuilder.RenameColumn(
                name: "KeyframeTicks",
                schema: "library",
                table: "keyframe_data",
                newName: "keyframe_ticks");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "keyframe_data",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "item_values_map",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "ItemValueId",
                schema: "library",
                table: "item_values_map",
                newName: "item_value_id");

            migrationBuilder.RenameIndex(
                name: "IX_ItemValuesMap_ItemId",
                schema: "library",
                table: "item_values_map",
                newName: "IX_item_values_map_item_id");

            migrationBuilder.RenameColumn(
                name: "Value",
                schema: "library",
                table: "item_values",
                newName: "value");

            migrationBuilder.RenameColumn(
                name: "Type",
                schema: "library",
                table: "item_values",
                newName: "type");

            migrationBuilder.RenameColumn(
                name: "CleanValue",
                schema: "library",
                table: "item_values",
                newName: "clean_value");

            migrationBuilder.RenameColumn(
                name: "ItemValueId",
                schema: "library",
                table: "item_values",
                newName: "item_value_id");

            migrationBuilder.RenameIndex(
                name: "IX_ItemValues_Type_Value",
                schema: "library",
                table: "item_values",
                newName: "IX_item_values_type_value");

            migrationBuilder.RenameIndex(
                name: "IX_ItemValues_Type_CleanValue",
                schema: "library",
                table: "item_values",
                newName: "IX_item_values_type_clean_value");

            migrationBuilder.RenameColumn(
                name: "Client",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "client");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "ViewType",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "view_type");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "SortOrder",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "sort_order");

            migrationBuilder.RenameColumn(
                name: "SortBy",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "sort_by");

            migrationBuilder.RenameColumn(
                name: "RememberSorting",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "remember_sorting");

            migrationBuilder.RenameColumn(
                name: "RememberIndexing",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "remember_indexing");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "IndexBy",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "index_by");

            migrationBuilder.RenameIndex(
                name: "IX_ItemDisplayPreferences_UserId",
                schema: "displaypreferences",
                table: "item_display_preferences",
                newName: "IX_item_display_preferences_user_id");

            migrationBuilder.RenameColumn(
                name: "Path",
                schema: "library",
                table: "image_infos",
                newName: "path");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "library",
                table: "image_infos",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "library",
                table: "image_infos",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "LastModified",
                schema: "library",
                table: "image_infos",
                newName: "last_modified");

            migrationBuilder.RenameIndex(
                name: "IX_ImageInfos_UserId",
                schema: "library",
                table: "image_infos",
                newName: "IX_image_infos_user_id");

            migrationBuilder.RenameColumn(
                name: "Type",
                schema: "displaypreferences",
                table: "home_sections",
                newName: "type");

            migrationBuilder.RenameColumn(
                name: "Order",
                schema: "displaypreferences",
                table: "home_sections",
                newName: "order");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "displaypreferences",
                table: "home_sections",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "DisplayPreferencesId",
                schema: "displaypreferences",
                table: "home_sections",
                newName: "display_preferences_id");

            migrationBuilder.RenameIndex(
                name: "IX_HomeSection_DisplayPreferencesId",
                schema: "displaypreferences",
                table: "home_sections",
                newName: "IX_home_sections_display_preferences_id");

            migrationBuilder.RenameColumn(
                name: "Client",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "client");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "TvHome",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "tv_home");

            migrationBuilder.RenameColumn(
                name: "SkipForwardLength",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "skip_forward_length");

            migrationBuilder.RenameColumn(
                name: "SkipBackwardLength",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "skip_backward_length");

            migrationBuilder.RenameColumn(
                name: "ShowSidebar",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "show_sidebar");

            migrationBuilder.RenameColumn(
                name: "ShowBackdrop",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "show_backdrop");

            migrationBuilder.RenameColumn(
                name: "ScrollDirection",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "scroll_direction");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "IndexBy",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "index_by");

            migrationBuilder.RenameColumn(
                name: "EnableNextVideoInfoOverlay",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "enable_next_video_info_overlay");

            migrationBuilder.RenameColumn(
                name: "DashboardTheme",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "dashboard_theme");

            migrationBuilder.RenameColumn(
                name: "ChromecastVersion",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "chromecast_version");

            migrationBuilder.RenameIndex(
                name: "IX_DisplayPreferences_UserId_ItemId_Client",
                schema: "displaypreferences",
                table: "display_preferences",
                newName: "IX_display_preferences_user_id_item_id_client");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "authentication",
                table: "device_options",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "DeviceId",
                schema: "authentication",
                table: "device_options",
                newName: "device_id");

            migrationBuilder.RenameColumn(
                name: "CustomName",
                schema: "authentication",
                table: "device_options",
                newName: "custom_name");

            migrationBuilder.RenameIndex(
                name: "IX_DeviceOptions_DeviceId",
                schema: "authentication",
                table: "device_options",
                newName: "IX_device_options_device_id");

            migrationBuilder.RenameColumn(
                name: "Value",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                newName: "value");

            migrationBuilder.RenameColumn(
                name: "Key",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                newName: "key");

            migrationBuilder.RenameColumn(
                name: "Client",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                newName: "client");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_CustomItemDisplayPreferences_UserId_ItemId_Client_Key",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                newName: "IX_custom_item_display_preferences_user_id_item_id_client_key");

            migrationBuilder.RenameColumn(
                name: "SeriesPresentationUniqueKey",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "series_presentation_unique_key");

            migrationBuilder.RenameColumn(
                name: "SeriesName",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "series_name");

            migrationBuilder.RenameColumn(
                name: "SeriesId",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "series_id");

            migrationBuilder.RenameColumn(
                name: "SeasonName",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "season_name");

            migrationBuilder.RenameColumn(
                name: "SeasonId",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "season_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemTvExtras_SeriesPresentationUniqueKey",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "IX_base_item_tv_extras_series_presentation_unique_key");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemTvExtras_SeriesId",
                schema: "library",
                table: "base_item_tv_extras",
                newName: "IX_base_item_tv_extras_series_id");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "library",
                table: "base_item_trailer_types",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "base_item_trailer_types",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemTrailerTypes_ItemId",
                schema: "library",
                table: "base_item_trailer_types",
                newName: "IX_base_item_trailer_types_item_id");

            migrationBuilder.RenameColumn(
                name: "Width",
                schema: "library",
                table: "base_items",
                newName: "width");

            migrationBuilder.RenameColumn(
                name: "Type",
                schema: "library",
                table: "base_items",
                newName: "type");

            migrationBuilder.RenameColumn(
                name: "Tags",
                schema: "library",
                table: "base_items",
                newName: "tags");

            migrationBuilder.RenameColumn(
                name: "Tagline",
                schema: "library",
                table: "base_items",
                newName: "tagline");

            migrationBuilder.RenameColumn(
                name: "Studios",
                schema: "library",
                table: "base_items",
                newName: "studios");

            migrationBuilder.RenameColumn(
                name: "Size",
                schema: "library",
                table: "base_items",
                newName: "size");

            migrationBuilder.RenameColumn(
                name: "Path",
                schema: "library",
                table: "base_items",
                newName: "path");

            migrationBuilder.RenameColumn(
                name: "Overview",
                schema: "library",
                table: "base_items",
                newName: "overview");

            migrationBuilder.RenameColumn(
                name: "Name",
                schema: "library",
                table: "base_items",
                newName: "name");

            migrationBuilder.RenameColumn(
                name: "Height",
                schema: "library",
                table: "base_items",
                newName: "height");

            migrationBuilder.RenameColumn(
                name: "Genres",
                schema: "library",
                table: "base_items",
                newName: "genres");

            migrationBuilder.RenameColumn(
                name: "Data",
                schema: "library",
                table: "base_items",
                newName: "data");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "library",
                table: "base_items",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UnratedType",
                schema: "library",
                table: "base_items",
                newName: "unrated_type");

            migrationBuilder.RenameColumn(
                name: "TotalBitrate",
                schema: "library",
                table: "base_items",
                newName: "total_bitrate");

            migrationBuilder.RenameColumn(
                name: "TopParentId",
                schema: "library",
                table: "base_items",
                newName: "top_parent_id");

            migrationBuilder.RenameColumn(
                name: "SortName",
                schema: "library",
                table: "base_items",
                newName: "sort_name");

            migrationBuilder.RenameColumn(
                name: "RunTimeTicks",
                schema: "library",
                table: "base_items",
                newName: "run_time_ticks");

            migrationBuilder.RenameColumn(
                name: "ProductionYear",
                schema: "library",
                table: "base_items",
                newName: "production_year");

            migrationBuilder.RenameColumn(
                name: "ProductionLocations",
                schema: "library",
                table: "base_items",
                newName: "production_locations");

            migrationBuilder.RenameColumn(
                name: "PrimaryVersionId",
                schema: "library",
                table: "base_items",
                newName: "primary_version_id");

            migrationBuilder.RenameColumn(
                name: "PresentationUniqueKey",
                schema: "library",
                table: "base_items",
                newName: "presentation_unique_key");

            migrationBuilder.RenameColumn(
                name: "PremiereDate",
                schema: "library",
                table: "base_items",
                newName: "premiere_date");

            migrationBuilder.RenameColumn(
                name: "PreferredMetadataLanguage",
                schema: "library",
                table: "base_items",
                newName: "preferred_metadata_language");

            migrationBuilder.RenameColumn(
                name: "PreferredMetadataCountryCode",
                schema: "library",
                table: "base_items",
                newName: "preferred_metadata_country_code");

            migrationBuilder.RenameColumn(
                name: "ParentIndexNumber",
                schema: "library",
                table: "base_items",
                newName: "parent_index_number");

            migrationBuilder.RenameColumn(
                name: "ParentId",
                schema: "library",
                table: "base_items",
                newName: "parent_id");

            migrationBuilder.RenameColumn(
                name: "OwnerId",
                schema: "library",
                table: "base_items",
                newName: "owner_id");

            migrationBuilder.RenameColumn(
                name: "OriginalTitle",
                schema: "library",
                table: "base_items",
                newName: "original_title");

            migrationBuilder.RenameColumn(
                name: "OfficialRating",
                schema: "library",
                table: "base_items",
                newName: "official_rating");

            migrationBuilder.RenameColumn(
                name: "MediaType",
                schema: "library",
                table: "base_items",
                newName: "media_type");

            migrationBuilder.RenameColumn(
                name: "IsVirtualItem",
                schema: "library",
                table: "base_items",
                newName: "is_virtual_item");

            migrationBuilder.RenameColumn(
                name: "IsSeries",
                schema: "library",
                table: "base_items",
                newName: "is_series");

            migrationBuilder.RenameColumn(
                name: "IsRepeat",
                schema: "library",
                table: "base_items",
                newName: "is_repeat");

            migrationBuilder.RenameColumn(
                name: "IsMovie",
                schema: "library",
                table: "base_items",
                newName: "is_movie");

            migrationBuilder.RenameColumn(
                name: "IsLocked",
                schema: "library",
                table: "base_items",
                newName: "is_locked");

            migrationBuilder.RenameColumn(
                name: "IsInMixedFolder",
                schema: "library",
                table: "base_items",
                newName: "is_in_mixed_folder");

            migrationBuilder.RenameColumn(
                name: "IsFolder",
                schema: "library",
                table: "base_items",
                newName: "is_folder");

            migrationBuilder.RenameColumn(
                name: "InheritedParentalRatingValue",
                schema: "library",
                table: "base_items",
                newName: "inherited_parental_rating_value");

            migrationBuilder.RenameColumn(
                name: "InheritedParentalRatingSubValue",
                schema: "library",
                table: "base_items",
                newName: "inherited_parental_rating_sub_value");

            migrationBuilder.RenameColumn(
                name: "IndexNumber",
                schema: "library",
                table: "base_items",
                newName: "index_number");

            migrationBuilder.RenameColumn(
                name: "ForcedSortName",
                schema: "library",
                table: "base_items",
                newName: "forced_sort_name");

            migrationBuilder.RenameColumn(
                name: "ExtraType",
                schema: "library",
                table: "base_items",
                newName: "extra_type");

            migrationBuilder.RenameColumn(
                name: "ExtraIds",
                schema: "library",
                table: "base_items",
                newName: "extra_ids");

            migrationBuilder.RenameColumn(
                name: "ExternalId",
                schema: "library",
                table: "base_items",
                newName: "external_id");

            migrationBuilder.RenameColumn(
                name: "DateModified",
                schema: "library",
                table: "base_items",
                newName: "date_modified");

            migrationBuilder.RenameColumn(
                name: "DateLastSaved",
                schema: "library",
                table: "base_items",
                newName: "date_last_saved");

            migrationBuilder.RenameColumn(
                name: "DateLastRefreshed",
                schema: "library",
                table: "base_items",
                newName: "date_last_refreshed");

            migrationBuilder.RenameColumn(
                name: "DateLastMediaAdded",
                schema: "library",
                table: "base_items",
                newName: "date_last_media_added");

            migrationBuilder.RenameColumn(
                name: "DateCreated",
                schema: "library",
                table: "base_items",
                newName: "date_created");

            migrationBuilder.RenameColumn(
                name: "CustomRating",
                schema: "library",
                table: "base_items",
                newName: "custom_rating");

            migrationBuilder.RenameColumn(
                name: "CriticRating",
                schema: "library",
                table: "base_items",
                newName: "critic_rating");

            migrationBuilder.RenameColumn(
                name: "CommunityRating",
                schema: "library",
                table: "base_items",
                newName: "community_rating");

            migrationBuilder.RenameColumn(
                name: "CleanName",
                schema: "library",
                table: "base_items",
                newName: "clean_name");

            migrationBuilder.RenameColumn(
                name: "ChannelId",
                schema: "library",
                table: "base_items",
                newName: "channel_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_Type_TopParentId_PresentationUniqueKey",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_type_top_parent_id_presentation_unique_key");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_Type_TopParentId_IsVirtualItem_PresentationUnique~",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_type_top_parent_id_is_virtual_item_presentation_~");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_Type_TopParentId_Id",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_type_top_parent_id_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_TopParentId_Id",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_top_parent_id_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_PresentationUniqueKey",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_presentation_unique_key");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_Path",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_path");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_ParentId",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_parent_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_MediaType_TopParentId_IsVirtualItem_PresentationU~",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_media_type_top_parent_id_is_virtual_item_present~");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_IsFolder_TopParentId_IsVirtualItem_PresentationUn~",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_is_folder_top_parent_id_is_virtual_item_presenta~");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItems_Id_Type_IsFolder_IsVirtualItem",
                schema: "library",
                table: "base_items",
                newName: "IX_base_items_id_type_is_folder_is_virtual_item");

            migrationBuilder.RenameColumn(
                name: "ProviderValue",
                schema: "library",
                table: "base_item_providers",
                newName: "provider_value");

            migrationBuilder.RenameColumn(
                name: "ProviderId",
                schema: "library",
                table: "base_item_providers",
                newName: "provider_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "base_item_providers",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemProviders_ProviderId_ProviderValue_ItemId",
                schema: "library",
                table: "base_item_providers",
                newName: "IX_base_item_providers_provider_id_provider_value_item_id");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "library",
                table: "base_item_metadata_fields",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "base_item_metadata_fields",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemMetadataFields_ItemId",
                schema: "library",
                table: "base_item_metadata_fields",
                newName: "IX_base_item_metadata_fields_item_id");

            migrationBuilder.RenameColumn(
                name: "Audio",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "audio");

            migrationBuilder.RenameColumn(
                name: "StartDate",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "start_date");

            migrationBuilder.RenameColumn(
                name: "ShowId",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "show_id");

            migrationBuilder.RenameColumn(
                name: "ExternalServiceId",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "external_service_id");

            migrationBuilder.RenameColumn(
                name: "ExternalSeriesId",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "external_series_id");

            migrationBuilder.RenameColumn(
                name: "EpisodeTitle",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "episode_title");

            migrationBuilder.RenameColumn(
                name: "EndDate",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "end_date");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemLiveTvExtras_StartDate",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "IX_base_item_live_tv_extras_start_date");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemLiveTvExtras_EndDate",
                schema: "library",
                table: "base_item_live_tv_extras",
                newName: "IX_base_item_live_tv_extras_end_date");

            migrationBuilder.RenameColumn(
                name: "Width",
                schema: "library",
                table: "base_item_image_infos",
                newName: "width");

            migrationBuilder.RenameColumn(
                name: "Path",
                schema: "library",
                table: "base_item_image_infos",
                newName: "path");

            migrationBuilder.RenameColumn(
                name: "Height",
                schema: "library",
                table: "base_item_image_infos",
                newName: "height");

            migrationBuilder.RenameColumn(
                name: "Blurhash",
                schema: "library",
                table: "base_item_image_infos",
                newName: "blurhash");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "library",
                table: "base_item_image_infos",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "base_item_image_infos",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "ImageType",
                schema: "library",
                table: "base_item_image_infos",
                newName: "image_type");

            migrationBuilder.RenameColumn(
                name: "DateModified",
                schema: "library",
                table: "base_item_image_infos",
                newName: "date_modified");

            migrationBuilder.RenameIndex(
                name: "IX_BaseItemImageInfos_ItemId",
                schema: "library",
                table: "base_item_image_infos",
                newName: "IX_base_item_image_infos_item_id");

            migrationBuilder.RenameColumn(
                name: "LUFS",
                schema: "library",
                table: "base_item_audio_extras",
                newName: "lufs");

            migrationBuilder.RenameColumn(
                name: "Artists",
                schema: "library",
                table: "base_item_audio_extras",
                newName: "artists");

            migrationBuilder.RenameColumn(
                name: "Album",
                schema: "library",
                table: "base_item_audio_extras",
                newName: "album");

            migrationBuilder.RenameColumn(
                name: "NormalizationGain",
                schema: "library",
                table: "base_item_audio_extras",
                newName: "normalization_gain");

            migrationBuilder.RenameColumn(
                name: "AlbumArtists",
                schema: "library",
                table: "base_item_audio_extras",
                newName: "album_artists");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "base_item_audio_extras",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "Channels",
                schema: "library",
                table: "audio_stream_details",
                newName: "channels");

            migrationBuilder.RenameColumn(
                name: "SampleRate",
                schema: "library",
                table: "audio_stream_details",
                newName: "sample_rate");

            migrationBuilder.RenameColumn(
                name: "IsHearingImpaired",
                schema: "library",
                table: "audio_stream_details",
                newName: "is_hearing_impaired");

            migrationBuilder.RenameColumn(
                name: "ChannelLayout",
                schema: "library",
                table: "audio_stream_details",
                newName: "channel_layout");

            migrationBuilder.RenameColumn(
                name: "StreamIndex",
                schema: "library",
                table: "audio_stream_details",
                newName: "stream_index");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "audio_stream_details",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "Filename",
                schema: "library",
                table: "attachment_stream_infos",
                newName: "filename");

            migrationBuilder.RenameColumn(
                name: "Comment",
                schema: "library",
                table: "attachment_stream_infos",
                newName: "comment");

            migrationBuilder.RenameColumn(
                name: "Codec",
                schema: "library",
                table: "attachment_stream_infos",
                newName: "codec");

            migrationBuilder.RenameColumn(
                name: "Index",
                schema: "library",
                table: "attachment_stream_infos",
                newName: "index");

            migrationBuilder.RenameColumn(
                name: "MimeType",
                schema: "library",
                table: "attachment_stream_infos",
                newName: "mime_type");

            migrationBuilder.RenameColumn(
                name: "CodecTag",
                schema: "library",
                table: "attachment_stream_infos",
                newName: "codec_tag");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "attachment_stream_infos",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "Name",
                schema: "authentication",
                table: "api_keys",
                newName: "name");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "authentication",
                table: "api_keys",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "DateLastActivity",
                schema: "authentication",
                table: "api_keys",
                newName: "date_last_activity");

            migrationBuilder.RenameColumn(
                name: "DateCreated",
                schema: "authentication",
                table: "api_keys",
                newName: "date_created");

            migrationBuilder.RenameColumn(
                name: "AccessToken",
                schema: "authentication",
                table: "api_keys",
                newName: "access_token");

            migrationBuilder.RenameIndex(
                name: "IX_ApiKeys_AccessToken",
                schema: "authentication",
                table: "api_keys",
                newName: "IX_api_keys_access_token");

            migrationBuilder.RenameColumn(
                name: "ParentItemId",
                schema: "library",
                table: "ancestor_ids",
                newName: "parent_item_id");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "library",
                table: "ancestor_ids",
                newName: "item_id");

            migrationBuilder.RenameIndex(
                name: "IX_AncestorIds_ParentItemId",
                schema: "library",
                table: "ancestor_ids",
                newName: "IX_ancestor_ids_parent_item_id");

            migrationBuilder.RenameColumn(
                name: "Type",
                schema: "activitylog",
                table: "activity_logs",
                newName: "type");

            migrationBuilder.RenameColumn(
                name: "Overview",
                schema: "activitylog",
                table: "activity_logs",
                newName: "overview");

            migrationBuilder.RenameColumn(
                name: "Name",
                schema: "activitylog",
                table: "activity_logs",
                newName: "name");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "activitylog",
                table: "activity_logs",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "activitylog",
                table: "activity_logs",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "ShortOverview",
                schema: "activitylog",
                table: "activity_logs",
                newName: "short_overview");

            migrationBuilder.RenameColumn(
                name: "RowVersion",
                schema: "activitylog",
                table: "activity_logs",
                newName: "row_version");

            migrationBuilder.RenameColumn(
                name: "LogSeverity",
                schema: "activitylog",
                table: "activity_logs",
                newName: "log_severity");

            migrationBuilder.RenameColumn(
                name: "ItemId",
                schema: "activitylog",
                table: "activity_logs",
                newName: "item_id");

            migrationBuilder.RenameColumn(
                name: "DateCreated",
                schema: "activitylog",
                table: "activity_logs",
                newName: "date_created");

            migrationBuilder.RenameIndex(
                name: "IX_ActivityLogs_DateCreated",
                schema: "activitylog",
                table: "activity_logs",
                newName: "IX_activity_logs_date_created");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "users",
                table: "access_schedules",
                newName: "id");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "users",
                table: "access_schedules",
                newName: "user_id");

            migrationBuilder.RenameColumn(
                name: "StartHour",
                schema: "users",
                table: "access_schedules",
                newName: "start_hour");

            migrationBuilder.RenameColumn(
                name: "EndHour",
                schema: "users",
                table: "access_schedules",
                newName: "end_hour");

            migrationBuilder.RenameColumn(
                name: "DayOfWeek",
                schema: "users",
                table: "access_schedules",
                newName: "day_of_week");

            migrationBuilder.RenameIndex(
                name: "IX_AccessSchedules_UserId",
                schema: "users",
                table: "access_schedules",
                newName: "IX_access_schedules_user_id");

            migrationBuilder.AddColumn<long>(
                name: "row_version",
                schema: "library",
                table: "user_data",
                type: "bigint",
                nullable: false,
                defaultValue: 0L);

            migrationBuilder.AddPrimaryKey(
                name: "PK_users",
                schema: "users",
                table: "users",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_preferences",
                schema: "users",
                table: "preferences",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_permissions",
                schema: "users",
                table: "permissions",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_peoples",
                schema: "library",
                table: "peoples",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_devices",
                schema: "authentication",
                table: "devices",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_chapters",
                schema: "library",
                table: "chapters",
                columns: new[] { "item_id", "chapter_index" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_video_stream_details",
                schema: "library",
                table: "video_stream_details",
                columns: new[] { "item_id", "stream_index" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_user_data",
                schema: "library",
                table: "user_data",
                columns: new[] { "item_id", "user_id", "custom_data_key" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_trickplay_infos",
                schema: "library",
                table: "trickplay_infos",
                columns: new[] { "item_id", "width" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_people_base_item_map",
                schema: "library",
                table: "people_base_item_map",
                columns: new[] { "item_id", "people_id", "role" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_media_stream_infos",
                schema: "library",
                table: "media_stream_infos",
                columns: new[] { "item_id", "stream_index" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_media_segments",
                schema: "library",
                table: "media_segments",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_keyframe_data",
                schema: "library",
                table: "keyframe_data",
                column: "item_id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_item_values_map",
                schema: "library",
                table: "item_values_map",
                columns: new[] { "item_value_id", "item_id" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_item_values",
                schema: "library",
                table: "item_values",
                column: "item_value_id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_item_display_preferences",
                schema: "displaypreferences",
                table: "item_display_preferences",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_image_infos",
                schema: "library",
                table: "image_infos",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_home_sections",
                schema: "displaypreferences",
                table: "home_sections",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_display_preferences",
                schema: "displaypreferences",
                table: "display_preferences",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_device_options",
                schema: "authentication",
                table: "device_options",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_custom_item_display_preferences",
                schema: "displaypreferences",
                table: "custom_item_display_preferences",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_item_tv_extras",
                schema: "library",
                table: "base_item_tv_extras",
                column: "item_id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_item_trailer_types",
                schema: "library",
                table: "base_item_trailer_types",
                columns: new[] { "id", "item_id" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_items",
                schema: "library",
                table: "base_items",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_item_providers",
                schema: "library",
                table: "base_item_providers",
                columns: new[] { "item_id", "provider_id" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_item_metadata_fields",
                schema: "library",
                table: "base_item_metadata_fields",
                columns: new[] { "id", "item_id" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_item_live_tv_extras",
                schema: "library",
                table: "base_item_live_tv_extras",
                column: "item_id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_item_image_infos",
                schema: "library",
                table: "base_item_image_infos",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_base_item_audio_extras",
                schema: "library",
                table: "base_item_audio_extras",
                column: "item_id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_audio_stream_details",
                schema: "library",
                table: "audio_stream_details",
                columns: new[] { "item_id", "stream_index" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_attachment_stream_infos",
                schema: "library",
                table: "attachment_stream_infos",
                columns: new[] { "item_id", "index" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_api_keys",
                schema: "authentication",
                table: "api_keys",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ancestor_ids",
                schema: "library",
                table: "ancestor_ids",
                columns: new[] { "item_id", "parent_item_id" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_activity_logs",
                schema: "activitylog",
                table: "activity_logs",
                column: "id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_access_schedules",
                schema: "users",
                table: "access_schedules",
                column: "id");

            migrationBuilder.CreateTable(
                name: "library_options",
                schema: "library",
                columns: table => new
                {
                    library_path = table.Column<string>(type: "text", nullable: false),
                    options_json = table.Column<string>(type: "jsonb", nullable: false),
                    version = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
                    date_created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    date_modified = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_library_options", x => x.library_path);
                });

            migrationBuilder.CreateIndex(
                name: "IX_library_options_date_modified",
                schema: "library",
                table: "library_options",
                column: "date_modified",
                descending: new bool[0]);

            migrationBuilder.AddForeignKey(
                name: "FK_access_schedules_users_user_id",
                schema: "users",
                table: "access_schedules",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ancestor_ids_base_items_item_id",
                schema: "library",
                table: "ancestor_ids",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ancestor_ids_base_items_parent_item_id",
                schema: "library",
                table: "ancestor_ids",
                column: "parent_item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_attachment_stream_infos_base_items_item_id",
                schema: "library",
                table: "attachment_stream_infos",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_audio_stream_details_media_stream_infos_item_id_stream_index",
                schema: "library",
                table: "audio_stream_details",
                columns: new[] { "item_id", "stream_index" },
                principalSchema: "library",
                principalTable: "media_stream_infos",
                principalColumns: new[] { "item_id", "stream_index" },
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_item_audio_extras_base_items_item_id",
                schema: "library",
                table: "base_item_audio_extras",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_item_image_infos_base_items_item_id",
                schema: "library",
                table: "base_item_image_infos",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_item_live_tv_extras_base_items_item_id",
                schema: "library",
                table: "base_item_live_tv_extras",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_item_metadata_fields_base_items_item_id",
                schema: "library",
                table: "base_item_metadata_fields",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_item_providers_base_items_item_id",
                schema: "library",
                table: "base_item_providers",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_item_trailer_types_base_items_item_id",
                schema: "library",
                table: "base_item_trailer_types",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_item_tv_extras_base_items_item_id",
                schema: "library",
                table: "base_item_tv_extras",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_base_items_base_items_parent_id",
                schema: "library",
                table: "base_items",
                column: "parent_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_chapters_base_items_item_id",
                schema: "library",
                table: "chapters",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_devices_users_user_id",
                schema: "authentication",
                table: "devices",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_display_preferences_users_user_id",
                schema: "displaypreferences",
                table: "display_preferences",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_home_sections_display_preferences_display_preferences_id",
                schema: "displaypreferences",
                table: "home_sections",
                column: "display_preferences_id",
                principalSchema: "displaypreferences",
                principalTable: "display_preferences",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_image_infos_users_user_id",
                schema: "library",
                table: "image_infos",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_item_display_preferences_users_user_id",
                schema: "displaypreferences",
                table: "item_display_preferences",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_item_values_map_base_items_item_id",
                schema: "library",
                table: "item_values_map",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_item_values_map_item_values_item_value_id",
                schema: "library",
                table: "item_values_map",
                column: "item_value_id",
                principalSchema: "library",
                principalTable: "item_values",
                principalColumn: "item_value_id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_keyframe_data_base_items_item_id",
                schema: "library",
                table: "keyframe_data",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_media_stream_infos_base_items_item_id",
                schema: "library",
                table: "media_stream_infos",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_people_base_item_map_base_items_item_id",
                schema: "library",
                table: "people_base_item_map",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_people_base_item_map_peoples_people_id",
                schema: "library",
                table: "people_base_item_map",
                column: "people_id",
                principalSchema: "library",
                principalTable: "peoples",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_permissions_users_user_id",
                schema: "users",
                table: "permissions",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_preferences_users_user_id",
                schema: "users",
                table: "preferences",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_user_data_base_items_item_id",
                schema: "library",
                table: "user_data",
                column: "item_id",
                principalSchema: "library",
                principalTable: "base_items",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_user_data_users_user_id",
                schema: "library",
                table: "user_data",
                column: "user_id",
                principalSchema: "users",
                principalTable: "users",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_video_stream_details_media_stream_infos_item_id_stream_index",
                schema: "library",
                table: "video_stream_details",
                columns: new[] { "item_id", "stream_index" },
                principalSchema: "library",
                principalTable: "media_stream_infos",
                principalColumns: new[] { "item_id", "stream_index" },
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_access_schedules_users_user_id",
                schema: "users",
                table: "access_schedules");

            migrationBuilder.DropForeignKey(
                name: "FK_ancestor_ids_base_items_item_id",
                schema: "library",
                table: "ancestor_ids");

            migrationBuilder.DropForeignKey(
                name: "FK_ancestor_ids_base_items_parent_item_id",
                schema: "library",
                table: "ancestor_ids");

            migrationBuilder.DropForeignKey(
                name: "FK_attachment_stream_infos_base_items_item_id",
                schema: "library",
                table: "attachment_stream_infos");

            migrationBuilder.DropForeignKey(
                name: "FK_audio_stream_details_media_stream_infos_item_id_stream_index",
                schema: "library",
                table: "audio_stream_details");

            migrationBuilder.DropForeignKey(
                name: "FK_base_item_audio_extras_base_items_item_id",
                schema: "library",
                table: "base_item_audio_extras");

            migrationBuilder.DropForeignKey(
                name: "FK_base_item_image_infos_base_items_item_id",
                schema: "library",
                table: "base_item_image_infos");

            migrationBuilder.DropForeignKey(
                name: "FK_base_item_live_tv_extras_base_items_item_id",
                schema: "library",
                table: "base_item_live_tv_extras");

            migrationBuilder.DropForeignKey(
                name: "FK_base_item_metadata_fields_base_items_item_id",
                schema: "library",
                table: "base_item_metadata_fields");

            migrationBuilder.DropForeignKey(
                name: "FK_base_item_providers_base_items_item_id",
                schema: "library",
                table: "base_item_providers");

            migrationBuilder.DropForeignKey(
                name: "FK_base_item_trailer_types_base_items_item_id",
                schema: "library",
                table: "base_item_trailer_types");

            migrationBuilder.DropForeignKey(
                name: "FK_base_item_tv_extras_base_items_item_id",
                schema: "library",
                table: "base_item_tv_extras");

            migrationBuilder.DropForeignKey(
                name: "FK_base_items_base_items_parent_id",
                schema: "library",
                table: "base_items");

            migrationBuilder.DropForeignKey(
                name: "FK_chapters_base_items_item_id",
                schema: "library",
                table: "chapters");

            migrationBuilder.DropForeignKey(
                name: "FK_devices_users_user_id",
                schema: "authentication",
                table: "devices");

            migrationBuilder.DropForeignKey(
                name: "FK_display_preferences_users_user_id",
                schema: "displaypreferences",
                table: "display_preferences");

            migrationBuilder.DropForeignKey(
                name: "FK_home_sections_display_preferences_display_preferences_id",
                schema: "displaypreferences",
                table: "home_sections");

            migrationBuilder.DropForeignKey(
                name: "FK_image_infos_users_user_id",
                schema: "library",
                table: "image_infos");

            migrationBuilder.DropForeignKey(
                name: "FK_item_display_preferences_users_user_id",
                schema: "displaypreferences",
                table: "item_display_preferences");

            migrationBuilder.DropForeignKey(
                name: "FK_item_values_map_base_items_item_id",
                schema: "library",
                table: "item_values_map");

            migrationBuilder.DropForeignKey(
                name: "FK_item_values_map_item_values_item_value_id",
                schema: "library",
                table: "item_values_map");

            migrationBuilder.DropForeignKey(
                name: "FK_keyframe_data_base_items_item_id",
                schema: "library",
                table: "keyframe_data");

            migrationBuilder.DropForeignKey(
                name: "FK_media_stream_infos_base_items_item_id",
                schema: "library",
                table: "media_stream_infos");

            migrationBuilder.DropForeignKey(
                name: "FK_people_base_item_map_base_items_item_id",
                schema: "library",
                table: "people_base_item_map");

            migrationBuilder.DropForeignKey(
                name: "FK_people_base_item_map_peoples_people_id",
                schema: "library",
                table: "people_base_item_map");

            migrationBuilder.DropForeignKey(
                name: "FK_permissions_users_user_id",
                schema: "users",
                table: "permissions");

            migrationBuilder.DropForeignKey(
                name: "FK_preferences_users_user_id",
                schema: "users",
                table: "preferences");

            migrationBuilder.DropForeignKey(
                name: "FK_user_data_base_items_item_id",
                schema: "library",
                table: "user_data");

            migrationBuilder.DropForeignKey(
                name: "FK_user_data_users_user_id",
                schema: "library",
                table: "user_data");

            migrationBuilder.DropForeignKey(
                name: "FK_video_stream_details_media_stream_infos_item_id_stream_index",
                schema: "library",
                table: "video_stream_details");

            migrationBuilder.DropTable(
                name: "library_options",
                schema: "library");

            migrationBuilder.DropPrimaryKey(
                name: "PK_users",
                schema: "users",
                table: "users");

            migrationBuilder.DropPrimaryKey(
                name: "PK_preferences",
                schema: "users",
                table: "preferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_permissions",
                schema: "users",
                table: "permissions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_peoples",
                schema: "library",
                table: "peoples");

            migrationBuilder.DropPrimaryKey(
                name: "PK_devices",
                schema: "authentication",
                table: "devices");

            migrationBuilder.DropPrimaryKey(
                name: "PK_chapters",
                schema: "library",
                table: "chapters");

            migrationBuilder.DropPrimaryKey(
                name: "PK_video_stream_details",
                schema: "library",
                table: "video_stream_details");

            migrationBuilder.DropPrimaryKey(
                name: "PK_user_data",
                schema: "library",
                table: "user_data");

            migrationBuilder.DropPrimaryKey(
                name: "PK_trickplay_infos",
                schema: "library",
                table: "trickplay_infos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_people_base_item_map",
                schema: "library",
                table: "people_base_item_map");

            migrationBuilder.DropPrimaryKey(
                name: "PK_media_stream_infos",
                schema: "library",
                table: "media_stream_infos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_media_segments",
                schema: "library",
                table: "media_segments");

            migrationBuilder.DropPrimaryKey(
                name: "PK_keyframe_data",
                schema: "library",
                table: "keyframe_data");

            migrationBuilder.DropPrimaryKey(
                name: "PK_item_values_map",
                schema: "library",
                table: "item_values_map");

            migrationBuilder.DropPrimaryKey(
                name: "PK_item_values",
                schema: "library",
                table: "item_values");

            migrationBuilder.DropPrimaryKey(
                name: "PK_item_display_preferences",
                schema: "displaypreferences",
                table: "item_display_preferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_image_infos",
                schema: "library",
                table: "image_infos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_home_sections",
                schema: "displaypreferences",
                table: "home_sections");

            migrationBuilder.DropPrimaryKey(
                name: "PK_display_preferences",
                schema: "displaypreferences",
                table: "display_preferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_device_options",
                schema: "authentication",
                table: "device_options");

            migrationBuilder.DropPrimaryKey(
                name: "PK_custom_item_display_preferences",
                schema: "displaypreferences",
                table: "custom_item_display_preferences");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_items",
                schema: "library",
                table: "base_items");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_item_tv_extras",
                schema: "library",
                table: "base_item_tv_extras");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_item_trailer_types",
                schema: "library",
                table: "base_item_trailer_types");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_item_providers",
                schema: "library",
                table: "base_item_providers");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_item_metadata_fields",
                schema: "library",
                table: "base_item_metadata_fields");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_item_live_tv_extras",
                schema: "library",
                table: "base_item_live_tv_extras");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_item_image_infos",
                schema: "library",
                table: "base_item_image_infos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_base_item_audio_extras",
                schema: "library",
                table: "base_item_audio_extras");

            migrationBuilder.DropPrimaryKey(
                name: "PK_audio_stream_details",
                schema: "library",
                table: "audio_stream_details");

            migrationBuilder.DropPrimaryKey(
                name: "PK_attachment_stream_infos",
                schema: "library",
                table: "attachment_stream_infos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_api_keys",
                schema: "authentication",
                table: "api_keys");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ancestor_ids",
                schema: "library",
                table: "ancestor_ids");

            migrationBuilder.DropPrimaryKey(
                name: "PK_activity_logs",
                schema: "activitylog",
                table: "activity_logs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_access_schedules",
                schema: "users",
                table: "access_schedules");

            migrationBuilder.DropColumn(
                name: "row_version",
                schema: "library",
                table: "user_data");

            migrationBuilder.RenameTable(
                name: "users",
                schema: "users",
                newName: "Users",
                newSchema: "users");

            migrationBuilder.RenameTable(
                name: "preferences",
                schema: "users",
                newName: "Preferences",
                newSchema: "users");

            migrationBuilder.RenameTable(
                name: "permissions",
                schema: "users",
                newName: "Permissions",
                newSchema: "users");

            migrationBuilder.RenameTable(
                name: "peoples",
                schema: "library",
                newName: "Peoples",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "devices",
                schema: "authentication",
                newName: "Devices",
                newSchema: "authentication");

            migrationBuilder.RenameTable(
                name: "chapters",
                schema: "library",
                newName: "Chapters",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "video_stream_details",
                schema: "library",
                newName: "VideoStreamDetails",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "user_data",
                schema: "library",
                newName: "UserData",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "trickplay_infos",
                schema: "library",
                newName: "TrickplayInfos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "people_base_item_map",
                schema: "library",
                newName: "PeopleBaseItemMap",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "media_stream_infos",
                schema: "library",
                newName: "MediaStreamInfos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "media_segments",
                schema: "library",
                newName: "MediaSegments",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "keyframe_data",
                schema: "library",
                newName: "KeyframeData",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "item_values_map",
                schema: "library",
                newName: "ItemValuesMap",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "item_values",
                schema: "library",
                newName: "ItemValues",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "item_display_preferences",
                schema: "displaypreferences",
                newName: "ItemDisplayPreferences",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "image_infos",
                schema: "library",
                newName: "ImageInfos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "home_sections",
                schema: "displaypreferences",
                newName: "HomeSection",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "display_preferences",
                schema: "displaypreferences",
                newName: "DisplayPreferences",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "device_options",
                schema: "authentication",
                newName: "DeviceOptions",
                newSchema: "authentication");

            migrationBuilder.RenameTable(
                name: "custom_item_display_preferences",
                schema: "displaypreferences",
                newName: "CustomItemDisplayPreferences",
                newSchema: "displaypreferences");

            migrationBuilder.RenameTable(
                name: "base_items",
                schema: "library",
                newName: "BaseItems",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "base_item_tv_extras",
                schema: "library",
                newName: "BaseItemTvExtras",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "base_item_trailer_types",
                schema: "library",
                newName: "BaseItemTrailerTypes",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "base_item_providers",
                schema: "library",
                newName: "BaseItemProviders",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "base_item_metadata_fields",
                schema: "library",
                newName: "BaseItemMetadataFields",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "base_item_live_tv_extras",
                schema: "library",
                newName: "BaseItemLiveTvExtras",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "base_item_image_infos",
                schema: "library",
                newName: "BaseItemImageInfos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "base_item_audio_extras",
                schema: "library",
                newName: "BaseItemAudioExtras",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "audio_stream_details",
                schema: "library",
                newName: "AudioStreamDetails",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "attachment_stream_infos",
                schema: "library",
                newName: "AttachmentStreamInfos",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "api_keys",
                schema: "authentication",
                newName: "ApiKeys",
                newSchema: "authentication");

            migrationBuilder.RenameTable(
                name: "ancestor_ids",
                schema: "library",
                newName: "AncestorIds",
                newSchema: "library");

            migrationBuilder.RenameTable(
                name: "activity_logs",
                schema: "activitylog",
                newName: "ActivityLogs",
                newSchema: "activitylog");

            migrationBuilder.RenameTable(
                name: "access_schedules",
                schema: "users",
                newName: "AccessSchedules",
                newSchema: "users");

            migrationBuilder.RenameColumn(
                name: "username",
                schema: "users",
                table: "Users",
                newName: "Username");

            migrationBuilder.RenameColumn(
                name: "password",
                schema: "users",
                table: "Users",
                newName: "Password");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "users",
                table: "Users",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "sync_play_access",
                schema: "users",
                table: "Users",
                newName: "SyncPlayAccess");

            migrationBuilder.RenameColumn(
                name: "subtitle_mode",
                schema: "users",
                table: "Users",
                newName: "SubtitleMode");

            migrationBuilder.RenameColumn(
                name: "subtitle_language_preference",
                schema: "users",
                table: "Users",
                newName: "SubtitleLanguagePreference");

            migrationBuilder.RenameColumn(
                name: "row_version",
                schema: "users",
                table: "Users",
                newName: "RowVersion");

            migrationBuilder.RenameColumn(
                name: "remote_client_bitrate_limit",
                schema: "users",
                table: "Users",
                newName: "RemoteClientBitrateLimit");

            migrationBuilder.RenameColumn(
                name: "remember_subtitle_selections",
                schema: "users",
                table: "Users",
                newName: "RememberSubtitleSelections");

            migrationBuilder.RenameColumn(
                name: "remember_audio_selections",
                schema: "users",
                table: "Users",
                newName: "RememberAudioSelections");

            migrationBuilder.RenameColumn(
                name: "play_default_audio_track",
                schema: "users",
                table: "Users",
                newName: "PlayDefaultAudioTrack");

            migrationBuilder.RenameColumn(
                name: "password_reset_provider_id",
                schema: "users",
                table: "Users",
                newName: "PasswordResetProviderId");

            migrationBuilder.RenameColumn(
                name: "must_update_password",
                schema: "users",
                table: "Users",
                newName: "MustUpdatePassword");

            migrationBuilder.RenameColumn(
                name: "max_parental_rating_sub_score",
                schema: "users",
                table: "Users",
                newName: "MaxParentalRatingSubScore");

            migrationBuilder.RenameColumn(
                name: "max_parental_rating_score",
                schema: "users",
                table: "Users",
                newName: "MaxParentalRatingScore");

            migrationBuilder.RenameColumn(
                name: "max_active_sessions",
                schema: "users",
                table: "Users",
                newName: "MaxActiveSessions");

            migrationBuilder.RenameColumn(
                name: "login_attempts_before_lockout",
                schema: "users",
                table: "Users",
                newName: "LoginAttemptsBeforeLockout");

            migrationBuilder.RenameColumn(
                name: "last_login_date",
                schema: "users",
                table: "Users",
                newName: "LastLoginDate");

            migrationBuilder.RenameColumn(
                name: "last_activity_date",
                schema: "users",
                table: "Users",
                newName: "LastActivityDate");

            migrationBuilder.RenameColumn(
                name: "invalid_login_attempt_count",
                schema: "users",
                table: "Users",
                newName: "InvalidLoginAttemptCount");

            migrationBuilder.RenameColumn(
                name: "internal_id",
                schema: "users",
                table: "Users",
                newName: "InternalId");

            migrationBuilder.RenameColumn(
                name: "hide_played_in_latest",
                schema: "users",
                table: "Users",
                newName: "HidePlayedInLatest");

            migrationBuilder.RenameColumn(
                name: "enable_user_preference_access",
                schema: "users",
                table: "Users",
                newName: "EnableUserPreferenceAccess");

            migrationBuilder.RenameColumn(
                name: "enable_next_episode_auto_play",
                schema: "users",
                table: "Users",
                newName: "EnableNextEpisodeAutoPlay");

            migrationBuilder.RenameColumn(
                name: "enable_local_password",
                schema: "users",
                table: "Users",
                newName: "EnableLocalPassword");

            migrationBuilder.RenameColumn(
                name: "enable_auto_login",
                schema: "users",
                table: "Users",
                newName: "EnableAutoLogin");

            migrationBuilder.RenameColumn(
                name: "display_missing_episodes",
                schema: "users",
                table: "Users",
                newName: "DisplayMissingEpisodes");

            migrationBuilder.RenameColumn(
                name: "display_collections_view",
                schema: "users",
                table: "Users",
                newName: "DisplayCollectionsView");

            migrationBuilder.RenameColumn(
                name: "cast_receiver_id",
                schema: "users",
                table: "Users",
                newName: "CastReceiverId");

            migrationBuilder.RenameColumn(
                name: "authentication_provider_id",
                schema: "users",
                table: "Users",
                newName: "AuthenticationProviderId");

            migrationBuilder.RenameColumn(
                name: "audio_language_preference",
                schema: "users",
                table: "Users",
                newName: "AudioLanguagePreference");

            migrationBuilder.RenameIndex(
                name: "IX_users_username",
                schema: "users",
                table: "Users",
                newName: "IX_Users_Username");

            migrationBuilder.RenameColumn(
                name: "value",
                schema: "users",
                table: "Preferences",
                newName: "Value");

            migrationBuilder.RenameColumn(
                name: "preference_preferences_guid",
                schema: "users",
                table: "Preferences",
                newName: "Preference_Preferences_Guid");

            migrationBuilder.RenameColumn(
                name: "kind",
                schema: "users",
                table: "Preferences",
                newName: "Kind");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "users",
                table: "Preferences",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "users",
                table: "Preferences",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "row_version",
                schema: "users",
                table: "Preferences",
                newName: "RowVersion");

            migrationBuilder.RenameIndex(
                name: "IX_preferences_user_id_kind",
                schema: "users",
                table: "Preferences",
                newName: "IX_Preferences_UserId_Kind");

            migrationBuilder.RenameColumn(
                name: "value",
                schema: "users",
                table: "Permissions",
                newName: "Value");

            migrationBuilder.RenameColumn(
                name: "permission_permissions_guid",
                schema: "users",
                table: "Permissions",
                newName: "Permission_Permissions_Guid");

            migrationBuilder.RenameColumn(
                name: "kind",
                schema: "users",
                table: "Permissions",
                newName: "Kind");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "users",
                table: "Permissions",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "users",
                table: "Permissions",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "row_version",
                schema: "users",
                table: "Permissions",
                newName: "RowVersion");

            migrationBuilder.RenameIndex(
                name: "IX_permissions_user_id_kind",
                schema: "users",
                table: "Permissions",
                newName: "IX_Permissions_UserId_Kind");

            migrationBuilder.RenameColumn(
                name: "name",
                schema: "library",
                table: "Peoples",
                newName: "Name");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "library",
                table: "Peoples",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "person_type",
                schema: "library",
                table: "Peoples",
                newName: "PersonType");

            migrationBuilder.RenameIndex(
                name: "IX_peoples_name",
                schema: "library",
                table: "Peoples",
                newName: "IX_Peoples_Name");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "authentication",
                table: "Devices",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "authentication",
                table: "Devices",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "is_active",
                schema: "authentication",
                table: "Devices",
                newName: "IsActive");

            migrationBuilder.RenameColumn(
                name: "device_name",
                schema: "authentication",
                table: "Devices",
                newName: "DeviceName");

            migrationBuilder.RenameColumn(
                name: "device_id",
                schema: "authentication",
                table: "Devices",
                newName: "DeviceId");

            migrationBuilder.RenameColumn(
                name: "date_modified",
                schema: "authentication",
                table: "Devices",
                newName: "DateModified");

            migrationBuilder.RenameColumn(
                name: "date_last_activity",
                schema: "authentication",
                table: "Devices",
                newName: "DateLastActivity");

            migrationBuilder.RenameColumn(
                name: "date_created",
                schema: "authentication",
                table: "Devices",
                newName: "DateCreated");

            migrationBuilder.RenameColumn(
                name: "app_version",
                schema: "authentication",
                table: "Devices",
                newName: "AppVersion");

            migrationBuilder.RenameColumn(
                name: "app_name",
                schema: "authentication",
                table: "Devices",
                newName: "AppName");

            migrationBuilder.RenameColumn(
                name: "access_token",
                schema: "authentication",
                table: "Devices",
                newName: "AccessToken");

            migrationBuilder.RenameIndex(
                name: "IX_devices_user_id_device_id",
                schema: "authentication",
                table: "Devices",
                newName: "IX_Devices_UserId_DeviceId");

            migrationBuilder.RenameIndex(
                name: "IX_devices_device_id_date_last_activity",
                schema: "authentication",
                table: "Devices",
                newName: "IX_Devices_DeviceId_DateLastActivity");

            migrationBuilder.RenameIndex(
                name: "IX_devices_device_id",
                schema: "authentication",
                table: "Devices",
                newName: "IX_Devices_DeviceId");

            migrationBuilder.RenameIndex(
                name: "IX_devices_access_token_date_last_activity",
                schema: "authentication",
                table: "Devices",
                newName: "IX_Devices_AccessToken_DateLastActivity");

            migrationBuilder.RenameColumn(
                name: "name",
                schema: "library",
                table: "Chapters",
                newName: "Name");

            migrationBuilder.RenameColumn(
                name: "start_position_ticks",
                schema: "library",
                table: "Chapters",
                newName: "StartPositionTicks");

            migrationBuilder.RenameColumn(
                name: "image_path",
                schema: "library",
                table: "Chapters",
                newName: "ImagePath");

            migrationBuilder.RenameColumn(
                name: "image_date_modified",
                schema: "library",
                table: "Chapters",
                newName: "ImageDateModified");

            migrationBuilder.RenameColumn(
                name: "chapter_index",
                schema: "library",
                table: "Chapters",
                newName: "ChapterIndex");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "Chapters",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "width",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "Width");

            migrationBuilder.RenameColumn(
                name: "rotation",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "Rotation");

            migrationBuilder.RenameColumn(
                name: "height",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "Height");

            migrationBuilder.RenameColumn(
                name: "rpu_present_flag",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "RpuPresentFlag");

            migrationBuilder.RenameColumn(
                name: "ref_frames",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "RefFrames");

            migrationBuilder.RenameColumn(
                name: "real_frame_rate",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "RealFrameRate");

            migrationBuilder.RenameColumn(
                name: "pixel_format",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "PixelFormat");

            migrationBuilder.RenameColumn(
                name: "nal_length_size",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "NalLengthSize");

            migrationBuilder.RenameColumn(
                name: "key_frames",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "KeyFrames");

            migrationBuilder.RenameColumn(
                name: "is_interlaced",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "IsInterlaced");

            migrationBuilder.RenameColumn(
                name: "is_anamorphic",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "IsAnamorphic");

            migrationBuilder.RenameColumn(
                name: "hdr10_plus_present_flag",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "Hdr10PlusPresentFlag");

            migrationBuilder.RenameColumn(
                name: "el_present_flag",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "ElPresentFlag");

            migrationBuilder.RenameColumn(
                name: "dv_version_minor",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "DvVersionMinor");

            migrationBuilder.RenameColumn(
                name: "dv_version_major",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "DvVersionMajor");

            migrationBuilder.RenameColumn(
                name: "dv_profile",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "DvProfile");

            migrationBuilder.RenameColumn(
                name: "dv_level",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "DvLevel");

            migrationBuilder.RenameColumn(
                name: "dv_bl_signal_compatibility_id",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "DvBlSignalCompatibilityId");

            migrationBuilder.RenameColumn(
                name: "color_transfer",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "ColorTransfer");

            migrationBuilder.RenameColumn(
                name: "color_space",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "ColorSpace");

            migrationBuilder.RenameColumn(
                name: "color_primaries",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "ColorPrimaries");

            migrationBuilder.RenameColumn(
                name: "bl_present_flag",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "BlPresentFlag");

            migrationBuilder.RenameColumn(
                name: "bit_depth",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "BitDepth");

            migrationBuilder.RenameColumn(
                name: "average_frame_rate",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "AverageFrameRate");

            migrationBuilder.RenameColumn(
                name: "aspect_ratio",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "AspectRatio");

            migrationBuilder.RenameColumn(
                name: "stream_index",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "StreamIndex");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "VideoStreamDetails",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "rating",
                schema: "library",
                table: "UserData",
                newName: "Rating");

            migrationBuilder.RenameColumn(
                name: "played",
                schema: "library",
                table: "UserData",
                newName: "Played");

            migrationBuilder.RenameColumn(
                name: "likes",
                schema: "library",
                table: "UserData",
                newName: "Likes");

            migrationBuilder.RenameColumn(
                name: "subtitle_stream_index",
                schema: "library",
                table: "UserData",
                newName: "SubtitleStreamIndex");

            migrationBuilder.RenameColumn(
                name: "retention_date",
                schema: "library",
                table: "UserData",
                newName: "RetentionDate");

            migrationBuilder.RenameColumn(
                name: "playback_position_ticks",
                schema: "library",
                table: "UserData",
                newName: "PlaybackPositionTicks");

            migrationBuilder.RenameColumn(
                name: "play_count",
                schema: "library",
                table: "UserData",
                newName: "PlayCount");

            migrationBuilder.RenameColumn(
                name: "last_played_date",
                schema: "library",
                table: "UserData",
                newName: "LastPlayedDate");

            migrationBuilder.RenameColumn(
                name: "is_favorite",
                schema: "library",
                table: "UserData",
                newName: "IsFavorite");

            migrationBuilder.RenameColumn(
                name: "audio_stream_index",
                schema: "library",
                table: "UserData",
                newName: "AudioStreamIndex");

            migrationBuilder.RenameColumn(
                name: "custom_data_key",
                schema: "library",
                table: "UserData",
                newName: "CustomDataKey");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "library",
                table: "UserData",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "UserData",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_user_data_user_id",
                schema: "library",
                table: "UserData",
                newName: "IX_UserData_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_user_data_item_id_user_id_played",
                schema: "library",
                table: "UserData",
                newName: "IX_UserData_ItemId_UserId_Played");

            migrationBuilder.RenameIndex(
                name: "IX_user_data_item_id_user_id_playback_position_ticks",
                schema: "library",
                table: "UserData",
                newName: "IX_UserData_ItemId_UserId_PlaybackPositionTicks");

            migrationBuilder.RenameIndex(
                name: "IX_user_data_item_id_user_id_last_played_date",
                schema: "library",
                table: "UserData",
                newName: "IX_UserData_ItemId_UserId_LastPlayedDate");

            migrationBuilder.RenameIndex(
                name: "IX_user_data_item_id_user_id_is_favorite",
                schema: "library",
                table: "UserData",
                newName: "IX_UserData_ItemId_UserId_IsFavorite");

            migrationBuilder.RenameColumn(
                name: "interval",
                schema: "library",
                table: "TrickplayInfos",
                newName: "Interval");

            migrationBuilder.RenameColumn(
                name: "height",
                schema: "library",
                table: "TrickplayInfos",
                newName: "Height");

            migrationBuilder.RenameColumn(
                name: "bandwidth",
                schema: "library",
                table: "TrickplayInfos",
                newName: "Bandwidth");

            migrationBuilder.RenameColumn(
                name: "width",
                schema: "library",
                table: "TrickplayInfos",
                newName: "Width");

            migrationBuilder.RenameColumn(
                name: "tile_width",
                schema: "library",
                table: "TrickplayInfos",
                newName: "TileWidth");

            migrationBuilder.RenameColumn(
                name: "tile_height",
                schema: "library",
                table: "TrickplayInfos",
                newName: "TileHeight");

            migrationBuilder.RenameColumn(
                name: "thumbnail_count",
                schema: "library",
                table: "TrickplayInfos",
                newName: "ThumbnailCount");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "TrickplayInfos",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "role",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "Role");

            migrationBuilder.RenameColumn(
                name: "sort_order",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "SortOrder");

            migrationBuilder.RenameColumn(
                name: "list_order",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "ListOrder");

            migrationBuilder.RenameColumn(
                name: "people_id",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "PeopleId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_people_base_item_map_people_id",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "IX_PeopleBaseItemMap_PeopleId");

            migrationBuilder.RenameIndex(
                name: "IX_people_base_item_map_item_id_sort_order",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "IX_PeopleBaseItemMap_ItemId_SortOrder");

            migrationBuilder.RenameIndex(
                name: "IX_people_base_item_map_item_id_list_order",
                schema: "library",
                table: "PeopleBaseItemMap",
                newName: "IX_PeopleBaseItemMap_ItemId_ListOrder");

            migrationBuilder.RenameColumn(
                name: "title",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "Title");

            migrationBuilder.RenameColumn(
                name: "profile",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "Profile");

            migrationBuilder.RenameColumn(
                name: "path",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "Path");

            migrationBuilder.RenameColumn(
                name: "level",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "Level");

            migrationBuilder.RenameColumn(
                name: "language",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "Language");

            migrationBuilder.RenameColumn(
                name: "comment",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "Comment");

            migrationBuilder.RenameColumn(
                name: "codec",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "Codec");

            migrationBuilder.RenameColumn(
                name: "time_base",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "TimeBase");

            migrationBuilder.RenameColumn(
                name: "stream_type",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "StreamType");

            migrationBuilder.RenameColumn(
                name: "is_forced",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IsForced");

            migrationBuilder.RenameColumn(
                name: "is_external",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IsExternal");

            migrationBuilder.RenameColumn(
                name: "is_default",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IsDefault");

            migrationBuilder.RenameColumn(
                name: "is_avc",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IsAvc");

            migrationBuilder.RenameColumn(
                name: "codec_time_base",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "CodecTimeBase");

            migrationBuilder.RenameColumn(
                name: "codec_tag",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "CodecTag");

            migrationBuilder.RenameColumn(
                name: "bit_rate",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "BitRate");

            migrationBuilder.RenameColumn(
                name: "stream_index",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "StreamIndex");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_media_stream_infos_stream_type",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IX_MediaStreamInfos_StreamType");

            migrationBuilder.RenameIndex(
                name: "IX_media_stream_infos_stream_index_stream_type_language",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IX_MediaStreamInfos_StreamIndex_StreamType_Language");

            migrationBuilder.RenameIndex(
                name: "IX_media_stream_infos_stream_index_stream_type",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IX_MediaStreamInfos_StreamIndex_StreamType");

            migrationBuilder.RenameIndex(
                name: "IX_media_stream_infos_stream_index",
                schema: "library",
                table: "MediaStreamInfos",
                newName: "IX_MediaStreamInfos_StreamIndex");

            migrationBuilder.RenameColumn(
                name: "type",
                schema: "library",
                table: "MediaSegments",
                newName: "Type");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "library",
                table: "MediaSegments",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "start_ticks",
                schema: "library",
                table: "MediaSegments",
                newName: "StartTicks");

            migrationBuilder.RenameColumn(
                name: "segment_provider_id",
                schema: "library",
                table: "MediaSegments",
                newName: "SegmentProviderId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "MediaSegments",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "end_ticks",
                schema: "library",
                table: "MediaSegments",
                newName: "EndTicks");

            migrationBuilder.RenameColumn(
                name: "total_duration",
                schema: "library",
                table: "KeyframeData",
                newName: "TotalDuration");

            migrationBuilder.RenameColumn(
                name: "keyframe_ticks",
                schema: "library",
                table: "KeyframeData",
                newName: "KeyframeTicks");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "KeyframeData",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "ItemValuesMap",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "item_value_id",
                schema: "library",
                table: "ItemValuesMap",
                newName: "ItemValueId");

            migrationBuilder.RenameIndex(
                name: "IX_item_values_map_item_id",
                schema: "library",
                table: "ItemValuesMap",
                newName: "IX_ItemValuesMap_ItemId");

            migrationBuilder.RenameColumn(
                name: "value",
                schema: "library",
                table: "ItemValues",
                newName: "Value");

            migrationBuilder.RenameColumn(
                name: "type",
                schema: "library",
                table: "ItemValues",
                newName: "Type");

            migrationBuilder.RenameColumn(
                name: "clean_value",
                schema: "library",
                table: "ItemValues",
                newName: "CleanValue");

            migrationBuilder.RenameColumn(
                name: "item_value_id",
                schema: "library",
                table: "ItemValues",
                newName: "ItemValueId");

            migrationBuilder.RenameIndex(
                name: "IX_item_values_type_value",
                schema: "library",
                table: "ItemValues",
                newName: "IX_ItemValues_Type_Value");

            migrationBuilder.RenameIndex(
                name: "IX_item_values_type_clean_value",
                schema: "library",
                table: "ItemValues",
                newName: "IX_ItemValues_Type_CleanValue");

            migrationBuilder.RenameColumn(
                name: "client",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "Client");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "view_type",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "ViewType");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "sort_order",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "SortOrder");

            migrationBuilder.RenameColumn(
                name: "sort_by",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "SortBy");

            migrationBuilder.RenameColumn(
                name: "remember_sorting",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "RememberSorting");

            migrationBuilder.RenameColumn(
                name: "remember_indexing",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "RememberIndexing");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "index_by",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "IndexBy");

            migrationBuilder.RenameIndex(
                name: "IX_item_display_preferences_user_id",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                newName: "IX_ItemDisplayPreferences_UserId");

            migrationBuilder.RenameColumn(
                name: "path",
                schema: "library",
                table: "ImageInfos",
                newName: "Path");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "library",
                table: "ImageInfos",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "library",
                table: "ImageInfos",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "last_modified",
                schema: "library",
                table: "ImageInfos",
                newName: "LastModified");

            migrationBuilder.RenameIndex(
                name: "IX_image_infos_user_id",
                schema: "library",
                table: "ImageInfos",
                newName: "IX_ImageInfos_UserId");

            migrationBuilder.RenameColumn(
                name: "type",
                schema: "displaypreferences",
                table: "HomeSection",
                newName: "Type");

            migrationBuilder.RenameColumn(
                name: "order",
                schema: "displaypreferences",
                table: "HomeSection",
                newName: "Order");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "displaypreferences",
                table: "HomeSection",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "display_preferences_id",
                schema: "displaypreferences",
                table: "HomeSection",
                newName: "DisplayPreferencesId");

            migrationBuilder.RenameIndex(
                name: "IX_home_sections_display_preferences_id",
                schema: "displaypreferences",
                table: "HomeSection",
                newName: "IX_HomeSection_DisplayPreferencesId");

            migrationBuilder.RenameColumn(
                name: "client",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "Client");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "tv_home",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "TvHome");

            migrationBuilder.RenameColumn(
                name: "skip_forward_length",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "SkipForwardLength");

            migrationBuilder.RenameColumn(
                name: "skip_backward_length",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "SkipBackwardLength");

            migrationBuilder.RenameColumn(
                name: "show_sidebar",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "ShowSidebar");

            migrationBuilder.RenameColumn(
                name: "show_backdrop",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "ShowBackdrop");

            migrationBuilder.RenameColumn(
                name: "scroll_direction",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "ScrollDirection");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "index_by",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "IndexBy");

            migrationBuilder.RenameColumn(
                name: "enable_next_video_info_overlay",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "EnableNextVideoInfoOverlay");

            migrationBuilder.RenameColumn(
                name: "dashboard_theme",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "DashboardTheme");

            migrationBuilder.RenameColumn(
                name: "chromecast_version",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "ChromecastVersion");

            migrationBuilder.RenameIndex(
                name: "IX_display_preferences_user_id_item_id_client",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                newName: "IX_DisplayPreferences_UserId_ItemId_Client");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "authentication",
                table: "DeviceOptions",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "device_id",
                schema: "authentication",
                table: "DeviceOptions",
                newName: "DeviceId");

            migrationBuilder.RenameColumn(
                name: "custom_name",
                schema: "authentication",
                table: "DeviceOptions",
                newName: "CustomName");

            migrationBuilder.RenameIndex(
                name: "IX_device_options_device_id",
                schema: "authentication",
                table: "DeviceOptions",
                newName: "IX_DeviceOptions_DeviceId");

            migrationBuilder.RenameColumn(
                name: "value",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                newName: "Value");

            migrationBuilder.RenameColumn(
                name: "key",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                newName: "Key");

            migrationBuilder.RenameColumn(
                name: "client",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                newName: "Client");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_custom_item_display_preferences_user_id_item_id_client_key",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                newName: "IX_CustomItemDisplayPreferences_UserId_ItemId_Client_Key");

            migrationBuilder.RenameColumn(
                name: "width",
                schema: "library",
                table: "BaseItems",
                newName: "Width");

            migrationBuilder.RenameColumn(
                name: "type",
                schema: "library",
                table: "BaseItems",
                newName: "Type");

            migrationBuilder.RenameColumn(
                name: "tags",
                schema: "library",
                table: "BaseItems",
                newName: "Tags");

            migrationBuilder.RenameColumn(
                name: "tagline",
                schema: "library",
                table: "BaseItems",
                newName: "Tagline");

            migrationBuilder.RenameColumn(
                name: "studios",
                schema: "library",
                table: "BaseItems",
                newName: "Studios");

            migrationBuilder.RenameColumn(
                name: "size",
                schema: "library",
                table: "BaseItems",
                newName: "Size");

            migrationBuilder.RenameColumn(
                name: "path",
                schema: "library",
                table: "BaseItems",
                newName: "Path");

            migrationBuilder.RenameColumn(
                name: "overview",
                schema: "library",
                table: "BaseItems",
                newName: "Overview");

            migrationBuilder.RenameColumn(
                name: "name",
                schema: "library",
                table: "BaseItems",
                newName: "Name");

            migrationBuilder.RenameColumn(
                name: "height",
                schema: "library",
                table: "BaseItems",
                newName: "Height");

            migrationBuilder.RenameColumn(
                name: "genres",
                schema: "library",
                table: "BaseItems",
                newName: "Genres");

            migrationBuilder.RenameColumn(
                name: "data",
                schema: "library",
                table: "BaseItems",
                newName: "Data");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "library",
                table: "BaseItems",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "unrated_type",
                schema: "library",
                table: "BaseItems",
                newName: "UnratedType");

            migrationBuilder.RenameColumn(
                name: "total_bitrate",
                schema: "library",
                table: "BaseItems",
                newName: "TotalBitrate");

            migrationBuilder.RenameColumn(
                name: "top_parent_id",
                schema: "library",
                table: "BaseItems",
                newName: "TopParentId");

            migrationBuilder.RenameColumn(
                name: "sort_name",
                schema: "library",
                table: "BaseItems",
                newName: "SortName");

            migrationBuilder.RenameColumn(
                name: "run_time_ticks",
                schema: "library",
                table: "BaseItems",
                newName: "RunTimeTicks");

            migrationBuilder.RenameColumn(
                name: "production_year",
                schema: "library",
                table: "BaseItems",
                newName: "ProductionYear");

            migrationBuilder.RenameColumn(
                name: "production_locations",
                schema: "library",
                table: "BaseItems",
                newName: "ProductionLocations");

            migrationBuilder.RenameColumn(
                name: "primary_version_id",
                schema: "library",
                table: "BaseItems",
                newName: "PrimaryVersionId");

            migrationBuilder.RenameColumn(
                name: "presentation_unique_key",
                schema: "library",
                table: "BaseItems",
                newName: "PresentationUniqueKey");

            migrationBuilder.RenameColumn(
                name: "premiere_date",
                schema: "library",
                table: "BaseItems",
                newName: "PremiereDate");

            migrationBuilder.RenameColumn(
                name: "preferred_metadata_language",
                schema: "library",
                table: "BaseItems",
                newName: "PreferredMetadataLanguage");

            migrationBuilder.RenameColumn(
                name: "preferred_metadata_country_code",
                schema: "library",
                table: "BaseItems",
                newName: "PreferredMetadataCountryCode");

            migrationBuilder.RenameColumn(
                name: "parent_index_number",
                schema: "library",
                table: "BaseItems",
                newName: "ParentIndexNumber");

            migrationBuilder.RenameColumn(
                name: "parent_id",
                schema: "library",
                table: "BaseItems",
                newName: "ParentId");

            migrationBuilder.RenameColumn(
                name: "owner_id",
                schema: "library",
                table: "BaseItems",
                newName: "OwnerId");

            migrationBuilder.RenameColumn(
                name: "original_title",
                schema: "library",
                table: "BaseItems",
                newName: "OriginalTitle");

            migrationBuilder.RenameColumn(
                name: "official_rating",
                schema: "library",
                table: "BaseItems",
                newName: "OfficialRating");

            migrationBuilder.RenameColumn(
                name: "media_type",
                schema: "library",
                table: "BaseItems",
                newName: "MediaType");

            migrationBuilder.RenameColumn(
                name: "is_virtual_item",
                schema: "library",
                table: "BaseItems",
                newName: "IsVirtualItem");

            migrationBuilder.RenameColumn(
                name: "is_series",
                schema: "library",
                table: "BaseItems",
                newName: "IsSeries");

            migrationBuilder.RenameColumn(
                name: "is_repeat",
                schema: "library",
                table: "BaseItems",
                newName: "IsRepeat");

            migrationBuilder.RenameColumn(
                name: "is_movie",
                schema: "library",
                table: "BaseItems",
                newName: "IsMovie");

            migrationBuilder.RenameColumn(
                name: "is_locked",
                schema: "library",
                table: "BaseItems",
                newName: "IsLocked");

            migrationBuilder.RenameColumn(
                name: "is_in_mixed_folder",
                schema: "library",
                table: "BaseItems",
                newName: "IsInMixedFolder");

            migrationBuilder.RenameColumn(
                name: "is_folder",
                schema: "library",
                table: "BaseItems",
                newName: "IsFolder");

            migrationBuilder.RenameColumn(
                name: "inherited_parental_rating_value",
                schema: "library",
                table: "BaseItems",
                newName: "InheritedParentalRatingValue");

            migrationBuilder.RenameColumn(
                name: "inherited_parental_rating_sub_value",
                schema: "library",
                table: "BaseItems",
                newName: "InheritedParentalRatingSubValue");

            migrationBuilder.RenameColumn(
                name: "index_number",
                schema: "library",
                table: "BaseItems",
                newName: "IndexNumber");

            migrationBuilder.RenameColumn(
                name: "forced_sort_name",
                schema: "library",
                table: "BaseItems",
                newName: "ForcedSortName");

            migrationBuilder.RenameColumn(
                name: "extra_type",
                schema: "library",
                table: "BaseItems",
                newName: "ExtraType");

            migrationBuilder.RenameColumn(
                name: "extra_ids",
                schema: "library",
                table: "BaseItems",
                newName: "ExtraIds");

            migrationBuilder.RenameColumn(
                name: "external_id",
                schema: "library",
                table: "BaseItems",
                newName: "ExternalId");

            migrationBuilder.RenameColumn(
                name: "date_modified",
                schema: "library",
                table: "BaseItems",
                newName: "DateModified");

            migrationBuilder.RenameColumn(
                name: "date_last_saved",
                schema: "library",
                table: "BaseItems",
                newName: "DateLastSaved");

            migrationBuilder.RenameColumn(
                name: "date_last_refreshed",
                schema: "library",
                table: "BaseItems",
                newName: "DateLastRefreshed");

            migrationBuilder.RenameColumn(
                name: "date_last_media_added",
                schema: "library",
                table: "BaseItems",
                newName: "DateLastMediaAdded");

            migrationBuilder.RenameColumn(
                name: "date_created",
                schema: "library",
                table: "BaseItems",
                newName: "DateCreated");

            migrationBuilder.RenameColumn(
                name: "custom_rating",
                schema: "library",
                table: "BaseItems",
                newName: "CustomRating");

            migrationBuilder.RenameColumn(
                name: "critic_rating",
                schema: "library",
                table: "BaseItems",
                newName: "CriticRating");

            migrationBuilder.RenameColumn(
                name: "community_rating",
                schema: "library",
                table: "BaseItems",
                newName: "CommunityRating");

            migrationBuilder.RenameColumn(
                name: "clean_name",
                schema: "library",
                table: "BaseItems",
                newName: "CleanName");

            migrationBuilder.RenameColumn(
                name: "channel_id",
                schema: "library",
                table: "BaseItems",
                newName: "ChannelId");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_type_top_parent_id_presentation_unique_key",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_Type_TopParentId_PresentationUniqueKey");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_type_top_parent_id_is_virtual_item_presentation_~",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_Type_TopParentId_IsVirtualItem_PresentationUnique~");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_type_top_parent_id_id",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_Type_TopParentId_Id");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_top_parent_id_id",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_TopParentId_Id");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_presentation_unique_key",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_PresentationUniqueKey");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_path",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_Path");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_parent_id",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_ParentId");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_media_type_top_parent_id_is_virtual_item_present~",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_MediaType_TopParentId_IsVirtualItem_PresentationU~");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_is_folder_top_parent_id_is_virtual_item_presenta~",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_IsFolder_TopParentId_IsVirtualItem_PresentationUn~");

            migrationBuilder.RenameIndex(
                name: "IX_base_items_id_type_is_folder_is_virtual_item",
                schema: "library",
                table: "BaseItems",
                newName: "IX_BaseItems_Id_Type_IsFolder_IsVirtualItem");

            migrationBuilder.RenameColumn(
                name: "series_presentation_unique_key",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "SeriesPresentationUniqueKey");

            migrationBuilder.RenameColumn(
                name: "series_name",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "SeriesName");

            migrationBuilder.RenameColumn(
                name: "series_id",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "SeriesId");

            migrationBuilder.RenameColumn(
                name: "season_name",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "SeasonName");

            migrationBuilder.RenameColumn(
                name: "season_id",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "SeasonId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_tv_extras_series_presentation_unique_key",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "IX_BaseItemTvExtras_SeriesPresentationUniqueKey");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_tv_extras_series_id",
                schema: "library",
                table: "BaseItemTvExtras",
                newName: "IX_BaseItemTvExtras_SeriesId");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "library",
                table: "BaseItemTrailerTypes",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "BaseItemTrailerTypes",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_trailer_types_item_id",
                schema: "library",
                table: "BaseItemTrailerTypes",
                newName: "IX_BaseItemTrailerTypes_ItemId");

            migrationBuilder.RenameColumn(
                name: "provider_value",
                schema: "library",
                table: "BaseItemProviders",
                newName: "ProviderValue");

            migrationBuilder.RenameColumn(
                name: "provider_id",
                schema: "library",
                table: "BaseItemProviders",
                newName: "ProviderId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "BaseItemProviders",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_providers_provider_id_provider_value_item_id",
                schema: "library",
                table: "BaseItemProviders",
                newName: "IX_BaseItemProviders_ProviderId_ProviderValue_ItemId");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "library",
                table: "BaseItemMetadataFields",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "BaseItemMetadataFields",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_metadata_fields_item_id",
                schema: "library",
                table: "BaseItemMetadataFields",
                newName: "IX_BaseItemMetadataFields_ItemId");

            migrationBuilder.RenameColumn(
                name: "audio",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "Audio");

            migrationBuilder.RenameColumn(
                name: "start_date",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "StartDate");

            migrationBuilder.RenameColumn(
                name: "show_id",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "ShowId");

            migrationBuilder.RenameColumn(
                name: "external_service_id",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "ExternalServiceId");

            migrationBuilder.RenameColumn(
                name: "external_series_id",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "ExternalSeriesId");

            migrationBuilder.RenameColumn(
                name: "episode_title",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "EpisodeTitle");

            migrationBuilder.RenameColumn(
                name: "end_date",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "EndDate");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_live_tv_extras_start_date",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "IX_BaseItemLiveTvExtras_StartDate");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_live_tv_extras_end_date",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                newName: "IX_BaseItemLiveTvExtras_EndDate");

            migrationBuilder.RenameColumn(
                name: "width",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "Width");

            migrationBuilder.RenameColumn(
                name: "path",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "Path");

            migrationBuilder.RenameColumn(
                name: "height",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "Height");

            migrationBuilder.RenameColumn(
                name: "blurhash",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "Blurhash");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "image_type",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "ImageType");

            migrationBuilder.RenameColumn(
                name: "date_modified",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "DateModified");

            migrationBuilder.RenameIndex(
                name: "IX_base_item_image_infos_item_id",
                schema: "library",
                table: "BaseItemImageInfos",
                newName: "IX_BaseItemImageInfos_ItemId");

            migrationBuilder.RenameColumn(
                name: "lufs",
                schema: "library",
                table: "BaseItemAudioExtras",
                newName: "LUFS");

            migrationBuilder.RenameColumn(
                name: "artists",
                schema: "library",
                table: "BaseItemAudioExtras",
                newName: "Artists");

            migrationBuilder.RenameColumn(
                name: "album",
                schema: "library",
                table: "BaseItemAudioExtras",
                newName: "Album");

            migrationBuilder.RenameColumn(
                name: "normalization_gain",
                schema: "library",
                table: "BaseItemAudioExtras",
                newName: "NormalizationGain");

            migrationBuilder.RenameColumn(
                name: "album_artists",
                schema: "library",
                table: "BaseItemAudioExtras",
                newName: "AlbumArtists");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "BaseItemAudioExtras",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "channels",
                schema: "library",
                table: "AudioStreamDetails",
                newName: "Channels");

            migrationBuilder.RenameColumn(
                name: "sample_rate",
                schema: "library",
                table: "AudioStreamDetails",
                newName: "SampleRate");

            migrationBuilder.RenameColumn(
                name: "is_hearing_impaired",
                schema: "library",
                table: "AudioStreamDetails",
                newName: "IsHearingImpaired");

            migrationBuilder.RenameColumn(
                name: "channel_layout",
                schema: "library",
                table: "AudioStreamDetails",
                newName: "ChannelLayout");

            migrationBuilder.RenameColumn(
                name: "stream_index",
                schema: "library",
                table: "AudioStreamDetails",
                newName: "StreamIndex");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "AudioStreamDetails",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "filename",
                schema: "library",
                table: "AttachmentStreamInfos",
                newName: "Filename");

            migrationBuilder.RenameColumn(
                name: "comment",
                schema: "library",
                table: "AttachmentStreamInfos",
                newName: "Comment");

            migrationBuilder.RenameColumn(
                name: "codec",
                schema: "library",
                table: "AttachmentStreamInfos",
                newName: "Codec");

            migrationBuilder.RenameColumn(
                name: "index",
                schema: "library",
                table: "AttachmentStreamInfos",
                newName: "Index");

            migrationBuilder.RenameColumn(
                name: "mime_type",
                schema: "library",
                table: "AttachmentStreamInfos",
                newName: "MimeType");

            migrationBuilder.RenameColumn(
                name: "codec_tag",
                schema: "library",
                table: "AttachmentStreamInfos",
                newName: "CodecTag");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "AttachmentStreamInfos",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "name",
                schema: "authentication",
                table: "ApiKeys",
                newName: "Name");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "authentication",
                table: "ApiKeys",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "date_last_activity",
                schema: "authentication",
                table: "ApiKeys",
                newName: "DateLastActivity");

            migrationBuilder.RenameColumn(
                name: "date_created",
                schema: "authentication",
                table: "ApiKeys",
                newName: "DateCreated");

            migrationBuilder.RenameColumn(
                name: "access_token",
                schema: "authentication",
                table: "ApiKeys",
                newName: "AccessToken");

            migrationBuilder.RenameIndex(
                name: "IX_api_keys_access_token",
                schema: "authentication",
                table: "ApiKeys",
                newName: "IX_ApiKeys_AccessToken");

            migrationBuilder.RenameColumn(
                name: "parent_item_id",
                schema: "library",
                table: "AncestorIds",
                newName: "ParentItemId");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "library",
                table: "AncestorIds",
                newName: "ItemId");

            migrationBuilder.RenameIndex(
                name: "IX_ancestor_ids_parent_item_id",
                schema: "library",
                table: "AncestorIds",
                newName: "IX_AncestorIds_ParentItemId");

            migrationBuilder.RenameColumn(
                name: "type",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "Type");

            migrationBuilder.RenameColumn(
                name: "overview",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "Overview");

            migrationBuilder.RenameColumn(
                name: "name",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "Name");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "short_overview",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "ShortOverview");

            migrationBuilder.RenameColumn(
                name: "row_version",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "RowVersion");

            migrationBuilder.RenameColumn(
                name: "log_severity",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "LogSeverity");

            migrationBuilder.RenameColumn(
                name: "item_id",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "ItemId");

            migrationBuilder.RenameColumn(
                name: "date_created",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "DateCreated");

            migrationBuilder.RenameIndex(
                name: "IX_activity_logs_date_created",
                schema: "activitylog",
                table: "ActivityLogs",
                newName: "IX_ActivityLogs_DateCreated");

            migrationBuilder.RenameColumn(
                name: "id",
                schema: "users",
                table: "AccessSchedules",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "user_id",
                schema: "users",
                table: "AccessSchedules",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "start_hour",
                schema: "users",
                table: "AccessSchedules",
                newName: "StartHour");

            migrationBuilder.RenameColumn(
                name: "end_hour",
                schema: "users",
                table: "AccessSchedules",
                newName: "EndHour");

            migrationBuilder.RenameColumn(
                name: "day_of_week",
                schema: "users",
                table: "AccessSchedules",
                newName: "DayOfWeek");

            migrationBuilder.RenameIndex(
                name: "IX_access_schedules_user_id",
                schema: "users",
                table: "AccessSchedules",
                newName: "IX_AccessSchedules_UserId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Users",
                schema: "users",
                table: "Users",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Preferences",
                schema: "users",
                table: "Preferences",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Permissions",
                schema: "users",
                table: "Permissions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Peoples",
                schema: "library",
                table: "Peoples",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Devices",
                schema: "authentication",
                table: "Devices",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Chapters",
                schema: "library",
                table: "Chapters",
                columns: new[] { "ItemId", "ChapterIndex" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_VideoStreamDetails",
                schema: "library",
                table: "VideoStreamDetails",
                columns: new[] { "ItemId", "StreamIndex" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_UserData",
                schema: "library",
                table: "UserData",
                columns: new[] { "ItemId", "UserId", "CustomDataKey" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_TrickplayInfos",
                schema: "library",
                table: "TrickplayInfos",
                columns: new[] { "ItemId", "Width" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_PeopleBaseItemMap",
                schema: "library",
                table: "PeopleBaseItemMap",
                columns: new[] { "ItemId", "PeopleId", "Role" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_MediaStreamInfos",
                schema: "library",
                table: "MediaStreamInfos",
                columns: new[] { "ItemId", "StreamIndex" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_MediaSegments",
                schema: "library",
                table: "MediaSegments",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_KeyframeData",
                schema: "library",
                table: "KeyframeData",
                column: "ItemId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ItemValuesMap",
                schema: "library",
                table: "ItemValuesMap",
                columns: new[] { "ItemValueId", "ItemId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_ItemValues",
                schema: "library",
                table: "ItemValues",
                column: "ItemValueId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ItemDisplayPreferences",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ImageInfos",
                schema: "library",
                table: "ImageInfos",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_HomeSection",
                schema: "displaypreferences",
                table: "HomeSection",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_DisplayPreferences",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_DeviceOptions",
                schema: "authentication",
                table: "DeviceOptions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_CustomItemDisplayPreferences",
                schema: "displaypreferences",
                table: "CustomItemDisplayPreferences",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItems",
                schema: "library",
                table: "BaseItems",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItemTvExtras",
                schema: "library",
                table: "BaseItemTvExtras",
                column: "ItemId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItemTrailerTypes",
                schema: "library",
                table: "BaseItemTrailerTypes",
                columns: new[] { "Id", "ItemId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItemProviders",
                schema: "library",
                table: "BaseItemProviders",
                columns: new[] { "ItemId", "ProviderId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItemMetadataFields",
                schema: "library",
                table: "BaseItemMetadataFields",
                columns: new[] { "Id", "ItemId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItemLiveTvExtras",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                column: "ItemId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItemImageInfos",
                schema: "library",
                table: "BaseItemImageInfos",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseItemAudioExtras",
                schema: "library",
                table: "BaseItemAudioExtras",
                column: "ItemId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AudioStreamDetails",
                schema: "library",
                table: "AudioStreamDetails",
                columns: new[] { "ItemId", "StreamIndex" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_AttachmentStreamInfos",
                schema: "library",
                table: "AttachmentStreamInfos",
                columns: new[] { "ItemId", "Index" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_ApiKeys",
                schema: "authentication",
                table: "ApiKeys",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AncestorIds",
                schema: "library",
                table: "AncestorIds",
                columns: new[] { "ItemId", "ParentItemId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_ActivityLogs",
                schema: "activitylog",
                table: "ActivityLogs",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AccessSchedules",
                schema: "users",
                table: "AccessSchedules",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_AccessSchedules_Users_UserId",
                schema: "users",
                table: "AccessSchedules",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AncestorIds_BaseItems_ItemId",
                schema: "library",
                table: "AncestorIds",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AncestorIds_BaseItems_ParentItemId",
                schema: "library",
                table: "AncestorIds",
                column: "ParentItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AttachmentStreamInfos_BaseItems_ItemId",
                schema: "library",
                table: "AttachmentStreamInfos",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AudioStreamDetails_MediaStreamInfos_ItemId_StreamIndex",
                schema: "library",
                table: "AudioStreamDetails",
                columns: new[] { "ItemId", "StreamIndex" },
                principalSchema: "library",
                principalTable: "MediaStreamInfos",
                principalColumns: new[] { "ItemId", "StreamIndex" },
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItemAudioExtras_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemAudioExtras",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItemImageInfos_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemImageInfos",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItemLiveTvExtras_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemLiveTvExtras",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItemMetadataFields_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemMetadataFields",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItemProviders_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemProviders",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItems_BaseItems_ParentId",
                schema: "library",
                table: "BaseItems",
                column: "ParentId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItemTrailerTypes_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemTrailerTypes",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseItemTvExtras_BaseItems_ItemId",
                schema: "library",
                table: "BaseItemTvExtras",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Chapters_BaseItems_ItemId",
                schema: "library",
                table: "Chapters",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Devices_Users_UserId",
                schema: "authentication",
                table: "Devices",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_DisplayPreferences_Users_UserId",
                schema: "displaypreferences",
                table: "DisplayPreferences",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_HomeSection_DisplayPreferences_DisplayPreferencesId",
                schema: "displaypreferences",
                table: "HomeSection",
                column: "DisplayPreferencesId",
                principalSchema: "displaypreferences",
                principalTable: "DisplayPreferences",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ImageInfos_Users_UserId",
                schema: "library",
                table: "ImageInfos",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ItemDisplayPreferences_Users_UserId",
                schema: "displaypreferences",
                table: "ItemDisplayPreferences",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ItemValuesMap_BaseItems_ItemId",
                schema: "library",
                table: "ItemValuesMap",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ItemValuesMap_ItemValues_ItemValueId",
                schema: "library",
                table: "ItemValuesMap",
                column: "ItemValueId",
                principalSchema: "library",
                principalTable: "ItemValues",
                principalColumn: "ItemValueId",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_KeyframeData_BaseItems_ItemId",
                schema: "library",
                table: "KeyframeData",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_MediaStreamInfos_BaseItems_ItemId",
                schema: "library",
                table: "MediaStreamInfos",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PeopleBaseItemMap_BaseItems_ItemId",
                schema: "library",
                table: "PeopleBaseItemMap",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PeopleBaseItemMap_Peoples_PeopleId",
                schema: "library",
                table: "PeopleBaseItemMap",
                column: "PeopleId",
                principalSchema: "library",
                principalTable: "Peoples",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Permissions_Users_UserId",
                schema: "users",
                table: "Permissions",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Preferences_Users_UserId",
                schema: "users",
                table: "Preferences",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UserData_BaseItems_ItemId",
                schema: "library",
                table: "UserData",
                column: "ItemId",
                principalSchema: "library",
                principalTable: "BaseItems",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UserData_Users_UserId",
                schema: "library",
                table: "UserData",
                column: "UserId",
                principalSchema: "users",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_VideoStreamDetails_MediaStreamInfos_ItemId_StreamIndex",
                schema: "library",
                table: "VideoStreamDetails",
                columns: new[] { "ItemId", "StreamIndex" },
                principalSchema: "library",
                principalTable: "MediaStreamInfos",
                principalColumns: new[] { "ItemId", "StreamIndex" },
                onDelete: ReferentialAction.Cascade);
        }
    }
}
