Files
pgsql-jellyfin/Jellyfin.Server/sql/schema_init/create_database_schema.sql
T
wjones 3e5d29225a Refactor SQLite Database Provider
- Removed unused classes and files related to SQLite database provider, including SqliteDesignTimeJellyfinDbFactory, ModelBuilderExtensions, PragmaConnectionInterceptor, AssemblyInfo, SqliteDatabaseProvider, DateTimeKindValueConverter.
- Updated tests to remove dependencies on removed classes and adjusted mocking for configuration sections.
- Added Microsoft.EntityFrameworkCore.Sqlite package reference to test project.
- Improved string handling in tests for better consistency and clarity.
- Refactored logging methods in JellyfinApplicationFactory for better readability and maintainability.
2026-05-03 09:39:00 -04:00

1881 lines
51 KiB
SQL

--
-- PostgreSQL database dump
--
\restrict BQanTgDKfPEe1ad123fH2eOQKfeiGuQ1HWaeH3TgqI0dLTNNmavSsSEklw1qhxQ
-- Dumped from database version 18.3
-- Dumped by pg_dump version 18.3
-- NOTE: Database creation is handled automatically by Jellyfin using configuration from database.xml
-- This script only creates schemas, tables, indexes, and constraints within the existing database
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: activitylog; Type: SCHEMA; Schema: -; Owner: jellyfin
--
CREATE SCHEMA activitylog;
ALTER SCHEMA activitylog OWNER TO jellyfin;
--
-- Name: authentication; Type: SCHEMA; Schema: -; Owner: jellyfin
--
CREATE SCHEMA authentication;
ALTER SCHEMA authentication OWNER TO jellyfin;
--
-- Name: displaypreferences; Type: SCHEMA; Schema: -; Owner: jellyfin
--
CREATE SCHEMA displaypreferences;
ALTER SCHEMA displaypreferences OWNER TO jellyfin;
--
-- Name: library; Type: SCHEMA; Schema: -; Owner: jellyfin
--
CREATE SCHEMA library;
ALTER SCHEMA library OWNER TO jellyfin;
--
-- Name: users; Type: SCHEMA; Schema: -; Owner: jellyfin
--
CREATE SCHEMA users;
ALTER SCHEMA users OWNER TO jellyfin;
--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
--
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: ActivityLogs; Type: TABLE; Schema: activitylog; Owner: jellyfin
--
CREATE TABLE activitylog.activity_logs (
id integer NOT NULL,
name character varying(512) NOT NULL,
overview character varying(512),
short_overview character varying(512),
type character varying(256) NOT NULL,
user_id uuid NOT NULL,
item_id character varying(256),
date_created timestamp with time zone NOT NULL,
log_severity integer NOT NULL,
row_version bigint NOT NULL
);
ALTER TABLE activitylog.activity_logs OWNER TO jellyfin;
--
-- Name: activity_logs_id_seq; Type: SEQUENCE; Schema: activitylog; Owner: jellyfin
--
ALTER TABLE activitylog.activity_logs ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME activitylog.activity_logs_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: ApiKeys; Type: TABLE; Schema: authentication; Owner: jellyfin
--
CREATE TABLE authentication.api_keys (
id integer NOT NULL,
date_created timestamp with time zone NOT NULL,
date_last_activity timestamp with time zone NOT NULL,
name character varying(64) NOT NULL,
access_token text NOT NULL
);
ALTER TABLE authentication.api_keys OWNER TO jellyfin;
--
-- Name: api_keys_id_seq; Type: SEQUENCE; Schema: authentication; Owner: jellyfin
--
ALTER TABLE authentication.api_keys ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME authentication.api_keys_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: DeviceOptions; Type: TABLE; Schema: authentication; Owner: jellyfin
--
CREATE TABLE authentication.device_options (
id integer NOT NULL,
device_id text NOT NULL,
custom_name text
);
ALTER TABLE authentication.device_options OWNER TO jellyfin;
--
-- Name: device_options_id_seq; Type: SEQUENCE; Schema: authentication; Owner: jellyfin
--
ALTER TABLE authentication.device_options ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME authentication.device_options_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: Devices; Type: TABLE; Schema: authentication; Owner: jellyfin
--
CREATE TABLE authentication.devices (
id integer NOT NULL,
user_id uuid NOT NULL,
access_token text NOT NULL,
app_name character varying(64) NOT NULL,
app_version character varying(32) NOT NULL,
device_name character varying(64) NOT NULL,
device_id character varying(256) NOT NULL,
is_active boolean NOT NULL,
date_created timestamp with time zone NOT NULL,
date_modified timestamp with time zone NOT NULL,
date_last_activity timestamp with time zone NOT NULL
);
ALTER TABLE authentication.devices OWNER TO jellyfin;
--
-- Name: devices_id_seq; Type: SEQUENCE; Schema: authentication; Owner: jellyfin
--
ALTER TABLE authentication.devices ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME authentication.devices_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: CustomItemDisplayPreferences; Type: TABLE; Schema: displaypreferences; Owner: jellyfin
--
CREATE TABLE displaypreferences.custom_item_display_preferences (
id integer NOT NULL,
user_id uuid NOT NULL,
item_id uuid NOT NULL,
client character varying(32) NOT NULL,
key text NOT NULL,
value text
);
ALTER TABLE displaypreferences.custom_item_display_preferences OWNER TO jellyfin;
--
-- Name: custom_item_display_preferences_id_seq; Type: SEQUENCE; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE displaypreferences.custom_item_display_preferences ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME displaypreferences.custom_item_display_preferences_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: DisplayPreferences; Type: TABLE; Schema: displaypreferences; Owner: jellyfin
--
CREATE TABLE displaypreferences.display_preferences (
id integer NOT NULL,
user_id uuid NOT NULL,
item_id uuid NOT NULL,
client character varying(32) NOT NULL,
show_sidebar boolean NOT NULL,
show_backdrop boolean NOT NULL,
scroll_direction integer NOT NULL,
index_by integer,
skip_forward_length integer NOT NULL,
skip_backward_length integer NOT NULL,
chromecast_version integer NOT NULL,
enable_next_video_info_overlay boolean NOT NULL,
dashboard_theme character varying(32),
tv_home character varying(32)
);
ALTER TABLE displaypreferences.display_preferences OWNER TO jellyfin;
--
-- Name: display_preferences_id_seq; Type: SEQUENCE; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE displaypreferences.display_preferences ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME displaypreferences.display_preferences_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: HomeSection; Type: TABLE; Schema: displaypreferences; Owner: jellyfin
--
CREATE TABLE displaypreferences.home_sections (
id integer NOT NULL,
display_preferences_id integer NOT NULL,
order integer NOT NULL,
type integer NOT NULL
);
ALTER TABLE displaypreferences.home_sections OWNER TO jellyfin;
--
-- Name: home_sections_id_seq; Type: SEQUENCE; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE displaypreferences.home_sections ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME displaypreferences.home_sections_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: ItemDisplayPreferences; Type: TABLE; Schema: displaypreferences; Owner: jellyfin
--
CREATE TABLE displaypreferences.item_display_preferences (
id integer NOT NULL,
user_id uuid NOT NULL,
item_id uuid NOT NULL,
client character varying(32) NOT NULL,
view_type integer NOT NULL,
remember_indexing boolean NOT NULL,
index_by integer,
remember_sorting boolean NOT NULL,
sort_by character varying(64) NOT NULL,
sort_order integer NOT NULL
);
ALTER TABLE displaypreferences.item_display_preferences OWNER TO jellyfin;
--
-- Name: item_display_preferences_id_seq; Type: SEQUENCE; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE displaypreferences.item_display_preferences ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME displaypreferences.item_display_preferences_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: AncestorIds; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.ancestor_ids (
parent_item_id uuid NOT NULL,
item_id uuid NOT NULL
);
ALTER TABLE library.ancestor_ids OWNER TO jellyfin;
--
-- Name: AttachmentStreamInfos; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.attachment_stream_infos (
item_id uuid NOT NULL,
index integer NOT NULL,
codec text,
codec_tag text,
comment text,
filename text,
mime_type text
);
ALTER TABLE library.attachment_stream_infos OWNER TO jellyfin;
--
-- Name: BaseItemImageInfos; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.base_item_image_infos (
id uuid NOT NULL,
path text NOT NULL,
date_modified timestamp with time zone,
image_type integer NOT NULL,
width integer NOT NULL,
height integer NOT NULL,
blurhash bytea,
item_id uuid NOT NULL
);
ALTER TABLE library.base_item_image_infos OWNER TO jellyfin;
--
-- Name: BaseItemMetadataFields; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.base_item_metadata_fields (
id integer NOT NULL,
item_id uuid NOT NULL
);
ALTER TABLE library.base_item_metadata_fields OWNER TO jellyfin;
--
-- Name: BaseItemProviders; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.base_item_providers (
item_id uuid NOT NULL,
provider_id text NOT NULL,
provider_value text NOT NULL
);
ALTER TABLE library.base_item_providers OWNER TO jellyfin;
--
-- Name: BaseItemTrailerTypes; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.base_item_trailer_types (
id integer NOT NULL,
item_id uuid NOT NULL
);
ALTER TABLE library.base_item_trailer_types OWNER TO jellyfin;
--
-- Name: BaseItems; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.base_items (
id uuid NOT NULL,
type text NOT NULL,
data text,
path text,
start_date timestamp with time zone,
end_date timestamp with time zone,
channel_id uuid,
is_movie boolean NOT NULL,
community_rating real,
custom_rating text,
index_number integer,
is_locked boolean NOT NULL,
name text,
official_rating text,
media_type text,
overview text,
parent_index_number integer,
premiere_date timestamp with time zone,
production_year integer,
genres text,
sort_name text,
forced_sort_name text,
run_time_ticks bigint,
date_created timestamp with time zone,
date_modified timestamp with time zone,
is_series boolean NOT NULL,
episode_title text,
is_repeat boolean NOT NULL,
preferred_metadata_language text,
preferred_metadata_country_code text,
date_last_refreshed timestamp with time zone,
date_last_saved timestamp with time zone,
is_in_mixed_folder boolean NOT NULL,
studios text,
external_service_id text,
tags text,
is_folder boolean NOT NULL,
inherited_parental_rating_value integer,
inherited_parental_rating_sub_value integer,
unrated_type text,
critic_rating real,
clean_name text,
presentation_unique_key text,
original_title text,
primary_version_id text,
date_last_media_added timestamp with time zone,
album text,
lufs real,
normalization_gain real,
is_virtual_item boolean NOT NULL,
series_name text,
season_name text,
external_series_id text,
tagline text,
production_locations text,
extra_ids text,
total_bitrate integer,
extra_type integer,
artists text,
album_artists text,
external_id text,
series_presentation_unique_key text,
show_id text,
owner_id text,
width integer,
height integer,
size bigint,
audio integer,
parent_id uuid,
top_parent_id uuid,
season_id uuid,
series_id uuid
);
ALTER TABLE library.base_items OWNER TO jellyfin;
--
-- Name: Chapters; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.chapters (
item_id uuid NOT NULL,
chapter_index integer NOT NULL,
start_position_ticks bigint NOT NULL,
name text,
image_path text,
image_date_modified timestamp with time zone
);
ALTER TABLE library.chapters OWNER TO jellyfin;
--
-- Name: ImageInfos; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.image_infos (
id integer NOT NULL,
user_id uuid,
path character varying(512) NOT NULL,
last_modified timestamp with time zone NOT NULL
);
ALTER TABLE library.image_infos OWNER TO jellyfin;
--
-- Name: image_infos_id_seq; Type: SEQUENCE; Schema: library; Owner: jellyfin
--
ALTER TABLE library.image_infos ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME library.image_infos_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: ItemValues; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.item_values (
item_value_id uuid NOT NULL,
type integer NOT NULL,
value text NOT NULL,
clean_value text NOT NULL
);
ALTER TABLE library.item_values OWNER TO jellyfin;
--
-- Name: ItemValuesMap; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.item_values_map (
item_id uuid NOT NULL,
item_value_id uuid NOT NULL
);
ALTER TABLE library.item_values_map OWNER TO jellyfin;
--
-- Name: KeyframeData; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.keyframe_data (
item_id uuid NOT NULL,
total_duration bigint NOT NULL,
keyframe_ticks bigint[]
);
ALTER TABLE library.keyframe_data OWNER TO jellyfin;
--
-- Name: MediaSegments; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.media_segments (
id uuid NOT NULL,
item_id uuid NOT NULL,
type integer NOT NULL,
end_ticks bigint NOT NULL,
start_ticks bigint NOT NULL,
segment_provider_id text NOT NULL
);
ALTER TABLE library.media_segments OWNER TO jellyfin;
--
-- Name: MediaStreamInfos; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.media_stream_infos (
item_id uuid NOT NULL,
stream_index integer NOT NULL,
stream_type integer NOT NULL,
codec text,
language text,
channel_layout text,
profile text,
aspect_ratio text,
path text,
is_interlaced boolean,
bit_rate integer,
channels integer,
sample_rate integer,
is_default boolean NOT NULL,
is_forced boolean NOT NULL,
is_external boolean NOT NULL,
height integer,
width integer,
average_frame_rate real,
real_frame_rate real,
level real,
pixel_format text,
bit_depth integer,
is_anamorphic boolean,
ref_frames integer,
codec_tag text,
comment text,
nal_length_size text,
is_avc boolean,
title text,
time_base text,
codec_time_base text,
color_primaries text,
color_space text,
color_transfer text,
dv_version_major integer,
dv_version_minor integer,
dv_profile integer,
dv_level integer,
rpu_present_flag integer,
el_present_flag integer,
bl_present_flag integer,
dv_bl_signal_compatibility_id integer,
is_hearing_impaired boolean,
rotation integer,
key_frames text,
hdr10_plus_present_flag boolean
);
ALTER TABLE library.media_stream_infos OWNER TO jellyfin;
--
-- Name: PeopleBaseItemMap; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.people_base_item_map (
role text NOT NULL,
item_id uuid NOT NULL,
people_id uuid NOT NULL,
sort_order integer,
list_order integer
);
ALTER TABLE library.people_base_item_map OWNER TO jellyfin;
--
-- Name: Peoples; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.peoples (
id uuid NOT NULL,
name text NOT NULL,
person_type text
);
ALTER TABLE library.peoples OWNER TO jellyfin;
--
-- Name: TrickplayInfos; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.trickplay_infos (
item_id uuid NOT NULL,
width integer NOT NULL,
height integer NOT NULL,
tile_width integer NOT NULL,
tile_height integer NOT NULL,
thumbnail_count integer NOT NULL,
interval integer NOT NULL,
bandwidth integer NOT NULL
);
ALTER TABLE library.trickplay_infos OWNER TO jellyfin;
--
-- Name: UserData; Type: TABLE; Schema: library; Owner: jellyfin
--
CREATE TABLE library.user_data (
custom_data_key text NOT NULL,
item_id uuid NOT NULL,
user_id uuid NOT NULL,
rating double precision,
playback_position_ticks bigint NOT NULL,
play_count integer NOT NULL,
is_favorite boolean NOT NULL,
last_played_date timestamp with time zone,
played boolean NOT NULL,
audio_stream_index integer,
subtitle_stream_index integer,
likes boolean,
retention_date timestamp with time zone
);
ALTER TABLE library.user_data OWNER TO jellyfin;
--
-- Name: __EFMigrationsHistory; Type: TABLE; Schema: public; Owner: jellyfin
--
CREATE TABLE public.__ef_migrations_history (
migration_id character varying(150) NOT NULL,
product_version character varying(32) NOT NULL
);
ALTER TABLE public.__ef_migrations_history OWNER TO jellyfin;
--
-- Name: bloat_tables; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.bloat_tables (
count bigint
);
ALTER TABLE public.bloat_tables OWNER TO postgres;
--
-- Name: AccessSchedules; Type: TABLE; Schema: users; Owner: jellyfin
--
CREATE TABLE users.access_schedules (
id integer NOT NULL,
user_id uuid NOT NULL,
day_of_week integer NOT NULL,
start_hour double precision NOT NULL,
end_hour double precision NOT NULL
);
ALTER TABLE users.access_schedules OWNER TO jellyfin;
--
-- Name: access_schedules_id_seq; Type: SEQUENCE; Schema: users; Owner: jellyfin
--
ALTER TABLE users.access_schedules ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME users.access_schedules_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: Permissions; Type: TABLE; Schema: users; Owner: jellyfin
--
CREATE TABLE users.permissions (
id integer NOT NULL,
user_id uuid,
kind integer NOT NULL,
value boolean NOT NULL,
row_version bigint NOT NULL,
permission_permissions_guid uuid
);
ALTER TABLE users.permissions OWNER TO jellyfin;
--
-- Name: permissions_id_seq; Type: SEQUENCE; Schema: users; Owner: jellyfin
--
ALTER TABLE users.permissions ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME users.permissions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: Preferences; Type: TABLE; Schema: users; Owner: jellyfin
--
CREATE TABLE users.preferences (
id integer NOT NULL,
user_id uuid,
kind integer NOT NULL,
value character varying(65535) NOT NULL,
row_version bigint NOT NULL,
preference_preferences_guid uuid
);
ALTER TABLE users.preferences OWNER TO jellyfin;
--
-- Name: preferences_id_seq; Type: SEQUENCE; Schema: users; Owner: jellyfin
--
ALTER TABLE users.preferences ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME users.preferences_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: Users; Type: TABLE; Schema: users; Owner: jellyfin
--
CREATE TABLE users.users (
id uuid NOT NULL,
username character varying(255) NOT NULL,
password character varying(65535),
must_update_password boolean NOT NULL,
audio_language_preference character varying(255),
authentication_provider_id character varying(255) NOT NULL,
password_reset_provider_id character varying(255) NOT NULL,
invalid_login_attempt_count integer NOT NULL,
last_activity_date timestamp with time zone,
last_login_date timestamp with time zone,
login_attempts_before_lockout integer,
max_active_sessions integer NOT NULL,
subtitle_mode integer NOT NULL,
play_default_audio_track boolean NOT NULL,
subtitle_language_preference character varying(255),
display_missing_episodes boolean NOT NULL,
display_collections_view boolean NOT NULL,
enable_local_password boolean NOT NULL,
hide_played_in_latest boolean NOT NULL,
remember_audio_selections boolean NOT NULL,
remember_subtitle_selections boolean NOT NULL,
enable_next_episode_auto_play boolean NOT NULL,
enable_auto_login boolean NOT NULL,
enable_user_preference_access boolean NOT NULL,
max_parental_rating_score integer,
max_parental_rating_sub_score integer,
remote_client_bitrate_limit integer,
internal_id bigint NOT NULL,
sync_play_access integer NOT NULL,
cast_receiver_id character varying(32),
row_version bigint NOT NULL
);
ALTER TABLE users.users OWNER TO jellyfin;
--
-- Name: ActivityLogs PK_ActivityLogs; Type: CONSTRAINT; Schema: activitylog; Owner: jellyfin
--
ALTER TABLE ONLY activitylog.activity_logs
ADD CONSTRAINT PK_ActivityLogs PRIMARY KEY (id);
--
-- Name: ApiKeys PK_ApiKeys; Type: CONSTRAINT; Schema: authentication; Owner: jellyfin
--
ALTER TABLE ONLY authentication.api_keys
ADD CONSTRAINT PK_ApiKeys PRIMARY KEY (id);
--
-- Name: DeviceOptions PK_DeviceOptions; Type: CONSTRAINT; Schema: authentication; Owner: jellyfin
--
ALTER TABLE ONLY authentication.device_options
ADD CONSTRAINT PK_DeviceOptions PRIMARY KEY (id);
--
-- Name: Devices PK_Devices; Type: CONSTRAINT; Schema: authentication; Owner: jellyfin
--
ALTER TABLE ONLY authentication.devices
ADD CONSTRAINT PK_Devices PRIMARY KEY (id);
--
-- Name: CustomItemDisplayPreferences PK_CustomItemDisplayPreferences; Type: CONSTRAINT; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE ONLY displaypreferences.custom_item_display_preferences
ADD CONSTRAINT PK_CustomItemDisplayPreferences PRIMARY KEY (id);
--
-- Name: DisplayPreferences PK_DisplayPreferences; Type: CONSTRAINT; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE ONLY displaypreferences.display_preferences
ADD CONSTRAINT PK_DisplayPreferences PRIMARY KEY (id);
--
-- Name: HomeSection PK_HomeSection; Type: CONSTRAINT; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE ONLY displaypreferences.home_sections
ADD CONSTRAINT PK_HomeSection PRIMARY KEY (id);
--
-- Name: ItemDisplayPreferences PK_ItemDisplayPreferences; Type: CONSTRAINT; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE ONLY displaypreferences.item_display_preferences
ADD CONSTRAINT PK_ItemDisplayPreferences PRIMARY KEY (id);
--
-- Name: AncestorIds PK_AncestorIds; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.ancestor_ids
ADD CONSTRAINT PK_AncestorIds PRIMARY KEY (item_id, parent_item_id);
--
-- Name: AttachmentStreamInfos PK_AttachmentStreamInfos; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.attachment_stream_infos
ADD CONSTRAINT PK_AttachmentStreamInfos PRIMARY KEY (item_id, index);
--
-- Name: BaseItemImageInfos PK_BaseItemImageInfos; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_image_infos
ADD CONSTRAINT PK_BaseItemImageInfos PRIMARY KEY (id);
--
-- Name: BaseItemMetadataFields PK_BaseItemMetadataFields; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_metadata_fields
ADD CONSTRAINT PK_BaseItemMetadataFields PRIMARY KEY (id, item_id);
--
-- Name: BaseItemProviders PK_BaseItemProviders; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_providers
ADD CONSTRAINT PK_BaseItemProviders PRIMARY KEY (item_id, provider_id);
--
-- Name: BaseItemTrailerTypes PK_BaseItemTrailerTypes; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_trailer_types
ADD CONSTRAINT PK_BaseItemTrailerTypes PRIMARY KEY (id, item_id);
--
-- Name: BaseItems PK_BaseItems; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_items
ADD CONSTRAINT PK_BaseItems PRIMARY KEY (id);
--
-- Name: Chapters PK_Chapters; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.chapters
ADD CONSTRAINT PK_Chapters PRIMARY KEY (item_id, chapter_index);
--
-- Name: ImageInfos PK_ImageInfos; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.image_infos
ADD CONSTRAINT PK_ImageInfos PRIMARY KEY (id);
--
-- Name: ItemValues PK_ItemValues; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.item_values
ADD CONSTRAINT PK_ItemValues PRIMARY KEY (item_value_id);
--
-- Name: ItemValuesMap PK_ItemValuesMap; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.item_values_map
ADD CONSTRAINT PK_ItemValuesMap PRIMARY KEY (item_value_id, item_id);
--
-- Name: KeyframeData PK_KeyframeData; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.keyframe_data
ADD CONSTRAINT PK_KeyframeData PRIMARY KEY (item_id);
--
-- Name: MediaSegments PK_MediaSegments; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.media_segments
ADD CONSTRAINT PK_MediaSegments PRIMARY KEY (id);
--
-- Name: MediaStreamInfos PK_MediaStreamInfos; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.media_stream_infos
ADD CONSTRAINT PK_MediaStreamInfos PRIMARY KEY (item_id, stream_index);
--
-- Name: PeopleBaseItemMap PK_PeopleBaseItemMap; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.people_base_item_map
ADD CONSTRAINT PK_PeopleBaseItemMap PRIMARY KEY (item_id, people_id, role);
--
-- Name: Peoples PK_Peoples; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.peoples
ADD CONSTRAINT PK_Peoples PRIMARY KEY (id);
--
-- Name: TrickplayInfos PK_TrickplayInfos; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.trickplay_infos
ADD CONSTRAINT PK_TrickplayInfos PRIMARY KEY (item_id, "Width");
--
-- Name: UserData PK_UserData; Type: CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.user_data
ADD CONSTRAINT PK_UserData PRIMARY KEY (item_id, user_id, custom_data_key);
--
-- Name: __EFMigrationsHistory PK___EFMigrationsHistory; Type: CONSTRAINT; Schema: public; Owner: jellyfin
--
ALTER TABLE ONLY public.__ef_migrations_history
ADD CONSTRAINT PK___EFMigrationsHistory PRIMARY KEY (migration_id);
--
-- Name: AccessSchedules PK_AccessSchedules; Type: CONSTRAINT; Schema: users; Owner: jellyfin
--
ALTER TABLE ONLY users.access_schedules
ADD CONSTRAINT PK_AccessSchedules PRIMARY KEY (id);
--
-- Name: Permissions PK_Permissions; Type: CONSTRAINT; Schema: users; Owner: jellyfin
--
ALTER TABLE ONLY users.permissions
ADD CONSTRAINT PK_Permissions PRIMARY KEY (id);
--
-- Name: Preferences PK_Preferences; Type: CONSTRAINT; Schema: users; Owner: jellyfin
--
ALTER TABLE ONLY users.preferences
ADD CONSTRAINT PK_Preferences PRIMARY KEY (id);
--
-- Name: Users PK_Users; Type: CONSTRAINT; Schema: users; Owner: jellyfin
--
ALTER TABLE ONLY users.users
ADD CONSTRAINT PK_Users PRIMARY KEY (id);
--
-- Name: IX_ActivityLogs_DateCreated; Type: INDEX; Schema: activitylog; Owner: jellyfin
--
CREATE INDEX IX_ActivityLogs_DateCreated ON activitylog.activity_logs USING btree (date_created);
--
-- Name: idx_activitylogs_userid_datecreated; Type: INDEX; Schema: activitylog; Owner: jellyfin
--
CREATE INDEX idx_activitylogs_userid_datecreated ON activitylog.activity_logs USING btree (user_id, date_created DESC) WHERE (user_id IS NOT NULL);
--
-- Name: IX_ApiKeys_AccessToken; Type: INDEX; Schema: authentication; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_ApiKeys_AccessToken ON authentication.api_keys USING btree (access_token);
--
-- Name: IX_DeviceOptions_DeviceId; Type: INDEX; Schema: authentication; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_DeviceOptions_DeviceId ON authentication.device_options USING btree (device_id);
--
-- Name: IX_Devices_AccessToken_DateLastActivity; Type: INDEX; Schema: authentication; Owner: jellyfin
--
CREATE INDEX IX_Devices_AccessToken_DateLastActivity ON authentication.devices USING btree (access_token, date_last_activity);
--
-- Name: IX_Devices_DeviceId; Type: INDEX; Schema: authentication; Owner: jellyfin
--
CREATE INDEX IX_Devices_DeviceId ON authentication.devices USING btree (device_id);
--
-- Name: IX_Devices_DeviceId_DateLastActivity; Type: INDEX; Schema: authentication; Owner: jellyfin
--
CREATE INDEX IX_Devices_DeviceId_DateLastActivity ON authentication.devices USING btree (device_id, date_last_activity);
--
-- Name: IX_Devices_UserId_DeviceId; Type: INDEX; Schema: authentication; Owner: jellyfin
--
CREATE INDEX IX_Devices_UserId_DeviceId ON authentication.devices USING btree (user_id, device_id);
--
-- Name: IX_CustomItemDisplayPreferences_UserId_ItemId_Client_Key; Type: INDEX; Schema: displaypreferences; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_CustomItemDisplayPreferences_UserId_ItemId_Client_Key ON displaypreferences.custom_item_display_preferences USING btree (user_id, item_id, client, "Key");
--
-- Name: IX_DisplayPreferences_UserId_ItemId_Client; Type: INDEX; Schema: displaypreferences; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_DisplayPreferences_UserId_ItemId_Client ON displaypreferences.display_preferences USING btree (user_id, item_id, client);
--
-- Name: IX_HomeSection_DisplayPreferencesId; Type: INDEX; Schema: displaypreferences; Owner: jellyfin
--
CREATE INDEX IX_HomeSection_DisplayPreferencesId ON displaypreferences.home_sections USING btree (display_preferences_id);
--
-- Name: IX_ItemDisplayPreferences_UserId; Type: INDEX; Schema: displaypreferences; Owner: jellyfin
--
CREATE INDEX IX_ItemDisplayPreferences_UserId ON displaypreferences.item_display_preferences USING btree (user_id);
--
-- Name: IX_AncestorIds_ParentItemId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_AncestorIds_ParentItemId ON library.ancestor_ids USING btree (parent_item_id);
--
-- Name: IX_BaseItemImageInfos_ItemId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItemImageInfos_ItemId ON library.base_item_image_infos USING btree (item_id);
--
-- Name: IX_BaseItemMetadataFields_ItemId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItemMetadataFields_ItemId ON library.base_item_metadata_fields USING btree (item_id);
--
-- Name: IX_BaseItemProviders_ProviderId_ProviderValue_ItemId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItemProviders_ProviderId_ProviderValue_ItemId ON library.base_item_providers USING btree (provider_id, provider_value, item_id);
--
-- Name: IX_BaseItemTrailerTypes_ItemId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItemTrailerTypes_ItemId ON library.base_item_trailer_types USING btree (item_id);
--
-- Name: IX_BaseItems_Id_Type_IsFolder_IsVirtualItem; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Id_Type_IsFolder_IsVirtualItem ON library.base_items USING btree (id, type, is_folder, is_virtual_item);
--
-- Name: IX_BaseItems_IsFolder_TopParentId_IsVirtualItem_PresentationUn~; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_IsFolder_TopParentId_IsVirtualItem_PresentationUn~ ON library.base_items USING btree (is_folder, top_parent_id, is_virtual_item, presentation_unique_key, date_created);
--
-- Name: IX_BaseItems_MediaType_TopParentId_IsVirtualItem_PresentationU~; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_MediaType_TopParentId_IsVirtualItem_PresentationU~ ON library.base_items USING btree ("MediaType", top_parent_id, is_virtual_item, presentation_unique_key);
--
-- Name: IX_BaseItems_ParentId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_ParentId ON library.base_items USING btree ("ParentId");
--
-- Name: IX_BaseItems_Path; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Path ON library.base_items USING btree (path);
--
-- Name: IX_BaseItems_PresentationUniqueKey; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_PresentationUniqueKey ON library.base_items USING btree (presentation_unique_key);
--
-- Name: IX_BaseItems_TopParentId_Id; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_TopParentId_Id ON library.base_items USING btree (top_parent_id, id);
--
-- Name: IX_BaseItems_Type_SeriesPresentationUniqueKey_IsFolder_IsVirtu~; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Type_SeriesPresentationUniqueKey_IsFolder_IsVirtu~ ON library.base_items USING btree (type, series_presentation_unique_key, is_folder, is_virtual_item);
--
-- Name: IX_BaseItems_Type_SeriesPresentationUniqueKey_PresentationUniq~; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Type_SeriesPresentationUniqueKey_PresentationUniq~ ON library.base_items USING btree (type, series_presentation_unique_key, presentation_unique_key, sort_name);
--
-- Name: IX_BaseItems_Type_TopParentId_Id; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Type_TopParentId_Id ON library.base_items USING btree (type, top_parent_id, id);
--
-- Name: IX_BaseItems_Type_TopParentId_IsVirtualItem_PresentationUnique~; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Type_TopParentId_IsVirtualItem_PresentationUnique~ ON library.base_items USING btree (type, top_parent_id, is_virtual_item, presentation_unique_key, date_created);
--
-- Name: IX_BaseItems_Type_TopParentId_PresentationUniqueKey; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Type_TopParentId_PresentationUniqueKey ON library.base_items USING btree (type, top_parent_id, presentation_unique_key);
--
-- Name: IX_BaseItems_Type_TopParentId_StartDate; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_BaseItems_Type_TopParentId_StartDate ON library.base_items USING btree (type, top_parent_id, start_date);
--
-- Name: IX_ImageInfos_UserId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_ImageInfos_UserId ON library.image_infos USING btree (user_id);
--
-- Name: IX_ItemValuesMap_ItemId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_ItemValuesMap_ItemId ON library.item_values_map USING btree (item_id);
--
-- Name: IX_ItemValues_Type_CleanValue; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_ItemValues_Type_CleanValue ON library.item_values USING btree (type, clean_value);
--
-- Name: IX_ItemValues_Type_Value; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_ItemValues_Type_Value ON library.item_values USING btree (type, value);
--
-- Name: IX_MediaStreamInfos_StreamIndex; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_MediaStreamInfos_StreamIndex ON library.media_stream_infos USING btree (stream_index);
--
-- Name: IX_MediaStreamInfos_StreamIndex_StreamType; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_MediaStreamInfos_StreamIndex_StreamType ON library.media_stream_infos USING btree (stream_index, stream_type);
--
-- Name: IX_MediaStreamInfos_StreamIndex_StreamType_Language; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_MediaStreamInfos_StreamIndex_StreamType_Language ON library.media_stream_infos USING btree (stream_index, stream_type, language);
--
-- Name: IX_MediaStreamInfos_StreamType; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_MediaStreamInfos_StreamType ON library.media_stream_infos USING btree (stream_type);
--
-- Name: IX_PeopleBaseItemMap_ItemId_ListOrder; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_PeopleBaseItemMap_ItemId_ListOrder ON library.people_base_item_map USING btree (item_id, list_order);
--
-- Name: IX_PeopleBaseItemMap_ItemId_SortOrder; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_PeopleBaseItemMap_ItemId_SortOrder ON library.people_base_item_map USING btree (item_id, sort_order);
--
-- Name: IX_PeopleBaseItemMap_PeopleId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_PeopleBaseItemMap_PeopleId ON library.people_base_item_map USING btree (people_id);
--
-- Name: IX_Peoples_Name; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_Peoples_Name ON library.peoples USING btree (name);
--
-- Name: IX_UserData_ItemId_UserId_IsFavorite; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_UserData_ItemId_UserId_IsFavorite ON library.user_data USING btree (item_id, user_id, is_favorite);
--
-- Name: IX_UserData_ItemId_UserId_LastPlayedDate; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_UserData_ItemId_UserId_LastPlayedDate ON library.user_data USING btree (item_id, user_id, last_played_date);
--
-- Name: IX_UserData_ItemId_UserId_PlaybackPositionTicks; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_UserData_ItemId_UserId_PlaybackPositionTicks ON library.user_data USING btree (item_id, user_id, playback_position_ticks);
--
-- Name: IX_UserData_ItemId_UserId_Played; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_UserData_ItemId_UserId_Played ON library.user_data USING btree (item_id, user_id, played);
--
-- Name: IX_UserData_UserId; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX IX_UserData_UserId ON library.user_data USING btree (user_id);
--
-- Name: baseitemproviders_providerid_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitemproviders_providerid_idx ON library.base_item_providers USING btree (provider_id, item_id);
--
-- Name: baseitemproviders_providervalue_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitemproviders_providervalue_idx ON library.base_item_providers USING btree (provider_value, provider_id);
--
-- Name: baseitems_communityrating_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_communityrating_idx ON library.base_items USING btree (community_rating DESC);
--
-- Name: baseitems_datecreated_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_datecreated_idx ON library.base_items USING btree (date_created DESC);
--
-- Name: baseitems_datemodified_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_datemodified_idx ON library.base_items USING btree (date_modified DESC);
--
-- Name: baseitems_parentid_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_parentid_idx ON library.base_items USING btree ("ParentId", type);
--
-- Name: baseitems_premieredate_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_premieredate_idx ON library.base_items USING btree (premiere_date DESC);
--
-- Name: baseitems_productionyear_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_productionyear_idx ON library.base_items USING btree (production_year DESC);
--
-- Name: baseitems_seriespresentationuniquekey_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_seriespresentationuniquekey_idx ON library.base_items USING btree (series_presentation_unique_key, "IndexNumber", "ParentIndexNumber");
--
-- Name: baseitems_sortname_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_sortname_idx ON library.base_items USING btree (sort_name);
--
-- Name: baseitems_topparentid_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX baseitems_topparentid_idx ON library.base_items USING btree (top_parent_id, type);
--
-- Name: idx_baseitems_datecreated_filtered; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_baseitems_datecreated_filtered ON library.base_items USING btree (date_created DESC, type, is_virtual_item) WHERE ((date_created IS NOT NULL) AND (is_virtual_item = false));
--
-- Name: idx_baseitems_presentationuniquekey_episodes; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_baseitems_presentationuniquekey_episodes ON library.base_items USING btree (presentation_unique_key, top_parent_id, is_virtual_item) WHERE ((type = 'MediaBrowser.Controller.Entities.TV.Episode'::text) AND (presentation_unique_key IS NOT NULL));
--
-- Name: idx_baseitems_topparentid_isfolder; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_baseitems_topparentid_isfolder ON library.base_items USING btree (top_parent_id, is_folder, is_virtual_item) WHERE (top_parent_id IS NOT NULL);
--
-- Name: idx_baseitems_type_isvirtualitem_topparentid; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_baseitems_type_isvirtualitem_topparentid ON library.base_items USING btree (type, is_virtual_item, top_parent_id) WHERE (is_virtual_item = false);
--
-- Name: idx_itemvalues_cleanvalue; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_itemvalues_cleanvalue ON library.item_values USING btree (clean_value) WHERE (clean_value IS NOT NULL);
--
-- Name: idx_itemvalues_id_cleanvalue; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_itemvalues_id_cleanvalue ON library.item_values USING btree (item_value_id, clean_value);
--
-- Name: idx_itemvalues_value; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_itemvalues_value ON library.item_values USING btree (value) WHERE (value IS NOT NULL);
--
-- Name: idx_itemvaluesmap_itemvalueid_itemid; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX idx_itemvaluesmap_itemvalueid_itemid ON library.item_values_map USING btree (item_value_id, item_id);
--
-- Name: mediastreaminfos_codec_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX mediastreaminfos_codec_idx ON library.media_stream_infos USING btree (codec);
--
-- Name: mediastreaminfos_itemid_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX mediastreaminfos_itemid_idx ON library.media_stream_infos USING btree (item_id, stream_type);
--
-- Name: peoplebaseitemmap_itemid_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX peoplebaseitemmap_itemid_idx ON library.people_base_item_map USING btree (item_id, people_id);
--
-- Name: peoplebaseitemmap_peopleid_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX peoplebaseitemmap_peopleid_idx ON library.people_base_item_map USING btree (people_id, item_id);
--
-- Name: userdata_lastplayeddate_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX userdata_lastplayeddate_idx ON library.user_data USING btree (last_played_date DESC);
--
-- Name: userdata_userid_isfavorite_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX userdata_userid_isfavorite_idx ON library.user_data USING btree (user_id, is_favorite);
--
-- Name: userdata_userid_played_idx; Type: INDEX; Schema: library; Owner: jellyfin
--
CREATE INDEX userdata_userid_played_idx ON library.user_data USING btree (user_id, played);
--
-- Name: IX_AccessSchedules_UserId; Type: INDEX; Schema: users; Owner: jellyfin
--
CREATE INDEX IX_AccessSchedules_UserId ON users.access_schedules USING btree (user_id);
--
-- Name: IX_Permissions_UserId_Kind; Type: INDEX; Schema: users; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_Permissions_UserId_Kind ON users.permissions USING btree (user_id, kind) WHERE (user_id IS NOT NULL);
--
-- Name: IX_Preferences_UserId_Kind; Type: INDEX; Schema: users; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_Preferences_UserId_Kind ON users.preferences USING btree (user_id, kind) WHERE (user_id IS NOT NULL);
--
-- Name: IX_Users_Username; Type: INDEX; Schema: users; Owner: jellyfin
--
CREATE UNIQUE INDEX IX_Users_Username ON users.users USING btree (username);
--
-- Name: Devices FK_Devices_Users_UserId; Type: FK CONSTRAINT; Schema: authentication; Owner: jellyfin
--
ALTER TABLE ONLY authentication.devices
ADD CONSTRAINT FK_Devices_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- Name: DisplayPreferences FK_DisplayPreferences_Users_UserId; Type: FK CONSTRAINT; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE ONLY displaypreferences.display_preferences
ADD CONSTRAINT FK_DisplayPreferences_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- Name: HomeSection FK_HomeSection_DisplayPreferences_DisplayPreferencesId; Type: FK CONSTRAINT; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE ONLY displaypreferences.home_sections
ADD CONSTRAINT FK_HomeSection_DisplayPreferences_DisplayPreferencesId FOREIGN KEY (display_preferences_id) REFERENCES displaypreferences.display_preferences(id) ON DELETE CASCADE;
--
-- Name: ItemDisplayPreferences FK_ItemDisplayPreferences_Users_UserId; Type: FK CONSTRAINT; Schema: displaypreferences; Owner: jellyfin
--
ALTER TABLE ONLY displaypreferences.item_display_preferences
ADD CONSTRAINT FK_ItemDisplayPreferences_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- Name: AncestorIds FK_AncestorIds_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.ancestor_ids
ADD CONSTRAINT FK_AncestorIds_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: AncestorIds FK_AncestorIds_BaseItems_ParentItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.ancestor_ids
ADD CONSTRAINT FK_AncestorIds_BaseItems_ParentItemId FOREIGN KEY (parent_item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: AttachmentStreamInfos FK_AttachmentStreamInfos_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.attachment_stream_infos
ADD CONSTRAINT FK_AttachmentStreamInfos_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: BaseItemImageInfos FK_BaseItemImageInfos_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_image_infos
ADD CONSTRAINT FK_BaseItemImageInfos_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: BaseItemMetadataFields FK_BaseItemMetadataFields_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_metadata_fields
ADD CONSTRAINT FK_BaseItemMetadataFields_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: BaseItemProviders FK_BaseItemProviders_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_providers
ADD CONSTRAINT FK_BaseItemProviders_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: BaseItemTrailerTypes FK_BaseItemTrailerTypes_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_item_trailer_types
ADD CONSTRAINT FK_BaseItemTrailerTypes_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: BaseItems FK_BaseItems_BaseItems_ParentId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.base_items
ADD CONSTRAINT FK_BaseItems_BaseItems_ParentId FOREIGN KEY ("ParentId") REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: Chapters FK_Chapters_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.chapters
ADD CONSTRAINT FK_Chapters_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: ImageInfos FK_ImageInfos_Users_UserId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.image_infos
ADD CONSTRAINT FK_ImageInfos_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- Name: ItemValuesMap FK_ItemValuesMap_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.item_values_map
ADD CONSTRAINT FK_ItemValuesMap_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: ItemValuesMap FK_ItemValuesMap_ItemValues_ItemValueId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.item_values_map
ADD CONSTRAINT FK_ItemValuesMap_ItemValues_ItemValueId FOREIGN KEY (item_value_id) REFERENCES library.item_values(item_value_id) ON DELETE CASCADE;
--
-- Name: KeyframeData FK_KeyframeData_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.keyframe_data
ADD CONSTRAINT FK_KeyframeData_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: MediaStreamInfos FK_MediaStreamInfos_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.media_stream_infos
ADD CONSTRAINT FK_MediaStreamInfos_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: PeopleBaseItemMap FK_PeopleBaseItemMap_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.people_base_item_map
ADD CONSTRAINT FK_PeopleBaseItemMap_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: PeopleBaseItemMap FK_PeopleBaseItemMap_Peoples_PeopleId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.people_base_item_map
ADD CONSTRAINT FK_PeopleBaseItemMap_Peoples_PeopleId FOREIGN KEY (people_id) REFERENCES library.peoples(id) ON DELETE CASCADE;
--
-- Name: UserData FK_UserData_BaseItems_ItemId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.user_data
ADD CONSTRAINT FK_UserData_BaseItems_ItemId FOREIGN KEY (item_id) REFERENCES library.base_items(id) ON DELETE CASCADE;
--
-- Name: UserData FK_UserData_Users_UserId; Type: FK CONSTRAINT; Schema: library; Owner: jellyfin
--
ALTER TABLE ONLY library.user_data
ADD CONSTRAINT FK_UserData_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- Name: AccessSchedules FK_AccessSchedules_Users_UserId; Type: FK CONSTRAINT; Schema: users; Owner: jellyfin
--
ALTER TABLE ONLY users.access_schedules
ADD CONSTRAINT FK_AccessSchedules_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- Name: Permissions FK_Permissions_Users_UserId; Type: FK CONSTRAINT; Schema: users; Owner: jellyfin
--
ALTER TABLE ONLY users.permissions
ADD CONSTRAINT FK_Permissions_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- Name: Preferences FK_Preferences_Users_UserId; Type: FK CONSTRAINT; Schema: users; Owner: jellyfin
--
ALTER TABLE ONLY users.preferences
ADD CONSTRAINT FK_Preferences_Users_UserId FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--
\unrestrict BQanTgDKfPEe1ad123fH2eOQKfeiGuQ1HWaeH3TgqI0dLTNNmavSsSEklw1qhxQ