# SQL Column Conversion Reference - All Tables

## Activity Log Schema

### activity_logs (activitylog."ActivityLogs")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"Name"` | `name` |
| `"Overview"` | `overview` |
| `"ShortOverview"` | `short_overview` |
| `"Type"` | `type` |
| `"UserId"` | `user_id` |
| `"ItemId"` | `item_id` |
| `"DateCreated"` | `date_created` |
| `"LogSeverity"` | `log_severity` |
| `"RowVersion"` | `row_version` |

---

## Authentication Schema

### api_keys (authentication."ApiKeys")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"DateCreated"` | `date_created` |
| `"DateLastActivity"` | `date_last_activity` |
| `"Name"` | `name` |
| `"AccessToken"` | `access_token` |

### devices (authentication."Devices")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"AccessToken"` | `access_token` |
| `"AppName"` | `app_name` |
| `"AppVersion"` | `app_version` |
| `"DeviceName"` | `device_name` |
| `"DeviceId"` | `device_id` |
| `"IsActive"` | `is_active` |
| `"DateCreated"` | `date_created` |
| `"DateModified"` | `date_modified` |
| `"DateLastActivity"` | `date_last_activity` |

### device_options (authentication."DeviceOptions")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"DeviceId"` | `device_id` |
| `"CustomName"` | `custom_name` |

---

## Display Preferences Schema

### display_preferences (displaypreferences."DisplayPreferences")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"ItemId"` | `item_id` |
| `"Client"` | `client` |
| `"ShowSidebar"` | `show_sidebar` |
| `"ShowBackdrop"` | `show_backdrop` |
| `"ScrollDirection"` | `scroll_direction` |
| `"IndexBy"` | `index_by` |
| `"SkipForwardLength"` | `skip_forward_length` |
| `"SkipBackwardLength"` | `skip_backward_length` |
| `"ChromecastVersion"` | `chromecast_version` |
| `"EnableNextVideoInfoOverlay"` | `enable_next_video_info_overlay` |
| `"DashboardTheme"` | `dashboard_theme` |
| `"TvHome"` | `tv_home` |

### item_display_preferences (displaypreferences."ItemDisplayPreferences")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"ItemId"` | `item_id` |
| `"Client"` | `client` |
| `"ViewType"` | `view_type` |
| `"RememberIndexing"` | `remember_indexing` |
| `"IndexBy"` | `index_by` |
| `"RememberSorting"` | `remember_sorting` |
| `"SortBy"` | `sort_by` |
| `"SortOrder"` | `sort_order` |

### custom_item_display_preferences (displaypreferences."CustomItemDisplayPreferences")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"ItemId"` | `item_id` |
| `"Client"` | `client` |
| `"Key"` | `key` |
| `"Value"` | `value` |

### home_sections (displaypreferences."HomeSection")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"DisplayPreferencesId"` | `display_preferences_id` |
| `"Order"` | `order` |
| `"Type"` | `type` |

---

## Library Schema

### base_items (library."BaseItems") - 73 columns
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"Type"` | `type` |
| `"Data"` | `data` |
| `"Path"` | `path` |
| `"StartDate"` | `start_date` |
| `"EndDate"` | `end_date` |
| `"ChannelId"` | `channel_id` |
| `"IsMovie"` | `is_movie` |
| `"CommunityRating"` | `community_rating` |
| `"CustomRating"` | `custom_rating` |
| `"IndexNumber"` | `index_number` |
| `"IsLocked"` | `is_locked` |
| `"Name"` | `name` |
| `"OfficialRating"` | `official_rating` |
| `"MediaType"` | `media_type` |
| `"Overview"` | `overview` |
| `"ParentIndexNumber"` | `parent_index_number` |
| `"PremiereDate"` | `premiere_date` |
| `"ProductionYear"` | `production_year` |
| `"Genres"` | `genres` |
| `"SortName"` | `sort_name` |
| `"ForcedSortName"` | `forced_sort_name` |
| `"RunTimeTicks"` | `run_time_ticks` |
| `"DateCreated"` | `date_created` |
| `"DateModified"` | `date_modified` |
| `"IsSeries"` | `is_series` |
| `"EpisodeTitle"` | `episode_title` |
| `"IsRepeat"` | `is_repeat` |
| `"PreferredMetadataLanguage"` | `preferred_metadata_language` |
| `"PreferredMetadataCountryCode"` | `preferred_metadata_country_code` |
| `"DateLastRefreshed"` | `date_last_refreshed` |
| `"DateLastSaved"` | `date_last_saved` |
| `"IsInMixedFolder"` | `is_in_mixed_folder` |
| `"Studios"` | `studios` |
| `"ExternalServiceId"` | `external_service_id` |
| `"Tags"` | `tags` |
| `"IsFolder"` | `is_folder` |
| `"InheritedParentalRatingValue"` | `inherited_parental_rating_value` |
| `"InheritedParentalRatingSubValue"` | `inherited_parental_rating_sub_value` |
| `"UnratedType"` | `unrated_type` |
| `"CriticRating"` | `critic_rating` |
| `"CleanName"` | `clean_name` |
| `"PresentationUniqueKey"` | `presentation_unique_key` |
| `"OriginalTitle"` | `original_title` |
| `"PrimaryVersionId"` | `primary_version_id` |
| `"DateLastMediaAdded"` | `date_last_media_added` |
| `"Album"` | `album` |
| `"LUFS"` | `lufs` |
| `"NormalizationGain"` | `normalization_gain` |
| `"IsVirtualItem"` | `is_virtual_item` |
| `"SeriesName"` | `series_name` |
| `"SeasonName"` | `season_name` |
| `"ExternalSeriesId"` | `external_series_id` |
| `"Tagline"` | `tagline` |
| `"ProductionLocations"` | `production_locations` |
| `"ExtraIds"` | `extra_ids` |
| `"TotalBitrate"` | `total_bitrate` |
| `"ExtraType"` | `extra_type` |
| `"Artists"` | `artists` |
| `"AlbumArtists"` | `album_artists` |
| `"ExternalId"` | `external_id` |
| `"SeriesPresentationUniqueKey"` | `series_presentation_unique_key` |
| `"ShowId"` | `show_id` |
| `"OwnerId"` | `owner_id` |
| `"Width"` | `width` |
| `"Height"` | `height` |
| `"Size"` | `size` |
| `"Audio"` | `audio` |
| `"ParentId"` | `parent_id` |
| `"TopParentId"` | `top_parent_id` |
| `"SeasonId"` | `season_id` |
| `"SeriesId"` | `series_id` |

### chapters (library."Chapters")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemId"` | `item_id` |
| `"ChapterIndex"` | `chapter_index` |
| `"StartPositionTicks"` | `start_position_ticks` |
| `"Name"` | `name` |
| `"ImagePath"` | `image_path` |
| `"ImageDateModified"` | `image_date_modified` |

### media_stream_infos (library."MediaStreamInfos") - 51 columns
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemId"` | `item_id` |
| `"StreamIndex"` | `stream_index` |
| `"StreamType"` | `stream_type` |
| `"Codec"` | `codec` |
| `"Language"` | `language` |
| `"ChannelLayout"` | `channel_layout` |
| `"Profile"` | `profile` |
| `"AspectRatio"` | `aspect_ratio` |
| `"Path"` | `path` |
| `"IsInterlaced"` | `is_interlaced` |
| `"BitRate"` | `bit_rate` |
| `"Channels"` | `channels` |
| `"SampleRate"` | `sample_rate` |
| `"IsDefault"` | `is_default` |
| `"IsForced"` | `is_forced` |
| `"IsExternal"` | `is_external` |
| `"Height"` | `height` |
| `"Width"` | `width` |
| `"AverageFrameRate"` | `average_frame_rate` |
| `"RealFrameRate"` | `real_frame_rate` |
| `"Level"` | `level` |
| `"PixelFormat"` | `pixel_format` |
| `"BitDepth"` | `bit_depth` |
| `"IsAnamorphic"` | `is_anamorphic` |
| `"RefFrames"` | `ref_frames` |
| `"CodecTag"` | `codec_tag` |
| `"Comment"` | `comment` |
| `"NalLengthSize"` | `nal_length_size` |
| `"IsAvc"` | `is_avc` |
| `"Title"` | `title` |
| `"TimeBase"` | `time_base` |
| `"CodecTimeBase"` | `codec_time_base` |
| `"ColorPrimaries"` | `color_primaries` |
| `"ColorSpace"` | `color_space` |
| `"ColorTransfer"` | `color_transfer` |
| `"DvVersionMajor"` | `dv_version_major` |
| `"DvVersionMinor"` | `dv_version_minor` |
| `"DvProfile"` | `dv_profile` |
| `"DvLevel"` | `dv_level` |
| `"RpuPresentFlag"` | `rpu_present_flag` |
| `"ElPresentFlag"` | `el_present_flag` |
| `"BlPresentFlag"` | `bl_present_flag` |
| `"DvBlSignalCompatibilityId"` | `dv_bl_signal_compatibility_id` |
| `"IsHearingImpaired"` | `is_hearing_impaired` |
| `"Rotation"` | `rotation` |
| `"KeyFrames"` | `key_frames` |
| `"Hdr10PlusPresentFlag"` | `hdr10_plus_present_flag` |

### attachment_stream_infos (library."AttachmentStreamInfos")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemId"` | `item_id` |
| `"Index"` | `index` |
| `"Codec"` | `codec` |
| `"CodecTag"` | `codec_tag` |
| `"Comment"` | `comment` |
| `"Filename"` | `filename` |
| `"MimeType"` | `mime_type` |

### image_infos (library."ImageInfos")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"Path"` | `path` |
| `"LastModified"` | `last_modified` |

### base_item_image_infos (library."BaseItemImageInfos")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"Path"` | `path` |
| `"DateModified"` | `date_modified` |
| `"ImageType"` | `image_type` |
| `"Width"` | `width` |
| `"Height"` | `height` |
| `"Blurhash"` | `blurhash` |
| `"ItemId"` | `item_id` |

### base_item_metadata_fields (library."BaseItemMetadataFields")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"ItemId"` | `item_id` |

### base_item_providers (library."BaseItemProviders")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemId"` | `item_id` |
| `"ProviderId"` | `provider_id` |
| `"ProviderValue"` | `provider_value` |

### base_item_trailer_types (library."BaseItemTrailerTypes")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"ItemId"` | `item_id` |

### item_values (library."ItemValues")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemValueId"` | `item_value_id` |
| `"Type"` | `type` |
| `"Value"` | `value` |
| `"CleanValue"` | `clean_value` |

### item_values_map (library."ItemValuesMap")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemId"` | `item_id` |
| `"ItemValueId"` | `item_value_id` |

### peoples (library."Peoples")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"Name"` | `name` |
| `"PersonType"` | `person_type` |

### people_base_item_map (library."PeopleBaseItemMap")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Role"` | `role` |
| `"ItemId"` | `item_id` |
| `"PeopleId"` | `people_id` |
| `"SortOrder"` | `sort_order` |
| `"ListOrder"` | `list_order` |

### user_data (library."UserData")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"CustomDataKey"` | `custom_data_key` |
| `"ItemId"` | `item_id` |
| `"UserId"` | `user_id` |
| `"Rating"` | `rating` |
| `"PlaybackPositionTicks"` | `playback_position_ticks` |
| `"PlayCount"` | `play_count` |
| `"IsFavorite"` | `is_favorite` |
| `"LastPlayedDate"` | `last_played_date` |
| `"Played"` | `played` |
| `"AudioStreamIndex"` | `audio_stream_index` |
| `"SubtitleStreamIndex"` | `subtitle_stream_index` |
| `"Likes"` | `likes` |
| `"RetentionDate"` | `retention_date` |

### ancestor_ids (library."AncestorIds")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ParentItemId"` | `parent_item_id` |
| `"ItemId"` | `item_id` |

### trickplay_infos (library."TrickplayInfos")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemId"` | `item_id` |
| `"Width"` | `width` |
| `"Height"` | `height` |
| `"TileWidth"` | `tile_width` |
| `"TileHeight"` | `tile_height` |
| `"ThumbnailCount"` | `thumbnail_count` |
| `"Interval"` | `interval` |
| `"Bandwidth"` | `bandwidth` |

### media_segments (library."MediaSegments")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"ItemId"` | `item_id` |
| `"Type"` | `type` |
| `"EndTicks"` | `end_ticks` |
| `"StartTicks"` | `start_ticks` |
| `"SegmentProviderId"` | `segment_provider_id` |

### keyframe_data (library."KeyframeData")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"ItemId"` | `item_id` |
| `"TotalDuration"` | `total_duration` |
| `"KeyframeTicks"` | `keyframe_ticks` |

### library_options (library."LibraryOptions") - Note: Not yet found in schema, may need verification
Expected columns (from LibraryOptionsEntity EF mapping):
- LibraryPath (primary key, text/string)
- DateModified (timestamp with time zone)

---

## Users Schema

### users (users."Users") - 36+ columns
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"Username"` | `username` |
| `"Password"` | `password` |
| `"MustUpdatePassword"` | `must_update_password` |
| `"AudioLanguagePreference"` | `audio_language_preference` |
| `"AuthenticationProviderId"` | `authentication_provider_id` |
| `"PasswordResetProviderId"` | `password_reset_provider_id` |
| `"InvalidLoginAttemptCount"` | `invalid_login_attempt_count` |
| `"LastActivityDate"` | `last_activity_date` |
| `"LastLoginDate"` | `last_login_date` |
| `"LoginAttemptsBeforeLockout"` | `login_attempts_before_lockout` |
| `"MaxActiveSessions"` | `max_active_sessions` |
| `"SubtitleMode"` | `subtitle_mode` |
| `"PlayDefaultAudioTrack"` | `play_default_audio_track` |
| `"SubtitleLanguagePreference"` | `subtitle_language_preference` |
| `"DisplayMissingEpisodes"` | `display_missing_episodes` |
| `"DisplayCollectionsView"` | `display_collections_view` |
| `"EnableLocalPassword"` | `enable_local_password` |
| `"HidePlayedInLatest"` | `hide_played_in_latest` |
| `"RememberAudioSelections"` | `remember_audio_selections` |
| `"RememberSubtitleSelections"` | `remember_subtitle_selections` |
| `"EnableNextEpisodeAutoPlay"` | `enable_next_episode_auto_play` |
| `"EnableAutoLogin"` | `enable_auto_login` |
| `"EnableUserPreferenceAccess"` | `enable_user_preference_access` |
| `"MaxParentalRatingScore"` | `max_parental_rating_score` |
| `"MaxParentalRatingSubScore"` | `max_parental_rating_sub_score` |
| `"RemoteClientBitrateLimit"` | `remote_client_bitrate_limit` |
| `"InternalId"` | `internal_id` |
| `"SyncPlayAccess"` | `sync_play_access` |
| `"CastReceiverId"` | `cast_receiver_id` |
| `"RowVersion"` | `row_version` |

### permissions (users."Permissions")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"Kind"` | `kind` |
| `"Value"` | `value` |
| `"RowVersion"` | `row_version` |
| `"Permission_Permissions_Guid"` | `permission_permissions_guid` |

### preferences (users."Preferences")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"Kind"` | `kind` |
| `"Value"` | `value` |
| `"RowVersion"` | `row_version` |
| `"Preference_Preferences_Guid"` | `preference_preferences_guid` |

### access_schedules (users."AccessSchedules")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"Id"` | `id` |
| `"UserId"` | `user_id` |
| `"DayOfWeek"` | `day_of_week` |
| `"StartHour"` | `start_hour` |
| `"EndHour"` | `end_hour` |

---

## Special System Tables

### __ef_migrations_history (public."__EFMigrationsHistory")
| Current (SQL) | Target (snake_case) |
|--------------|-------------------|
| `"MigrationId"` | `migration_id` |
| `"ProductVersion"` | `product_version` |

---

## Summary Statistics

- **Total Application Tables**: 19
- **Total Library Schema Tables**: 19 (with BaseItems being the largest at 73 columns)
- **Total Media Stream Columns**: 51 (MediaStreamInfos is the second-largest table)
- **Total Columns Across All Tables**: ~250+
- **Sequences to Rename**: 17 (one per auto-increment table)
- **Special System Table**: 1 (`__EFMigrationsHistory`)

---

Generated: 2025-05-01  
For use in create_database_schema.sql conversion from quoted PascalCase to lowercase/snake_case identifiers
