# schema_migrations

version: 20180324032400
rollback_sql:
  update metadata_items set absolute_index=`index`,`index`=1 where metadata_type=18;update metadata_items set absolute_index=null where absolute_index is not null and metadata_type in (1,2)


version: 20190403100000
rollback_sql:
  update media_provider_resources set uri='https://podcasts.provider.plex.tv' where uri='provider://tv.plex.provider.podcasts';update media_provider_resources set uri='https://podcasts-staging.provider.plex.tv' where uri='provider://tv.plex.provider.podcasts-staging';


version: 20190520131302
rollback_sql:
  update media_provider_resources set parent_id = null where parent_id in (select parent_id from media_provider_resources where identifier = 'tv.plex.providers.epg.cloud');


version: 20190520131303
rollback_sql:
  delete from media_provider_resources where id in (select parent_id from media_provider_resources where identifier = 'tv.plex.providers.epg.cloud');


version: 20190919032400
rollback_sql:
  UPDATE library_sections set agent='com.plexapp.agents.plexmusic', scanner='Plex Premium Music Scanner' where agent='tv.plex.agents.music'


version: 20200131193503
rollback_sql:
  UPDATE metadata_items SET extra_data = replace(extra_data, 'pv%3AreadOnly=', 'at%3AreadOnly=') WHERE extra_data LIKE '%pv^%3AreadOnly=%' escape '^'


version: 20200401131300
rollback_sql:
  UPDATE library_sections SET user_fields = replace(replace(user_fields, 'pr%3Ahidden=0', 'pr%includeInGlobal=1'), 'pr%3Ahidden=1', 'pr%3AincludeInGlobal=0') WHERE user_fields LIKE '%pr^%3Ahidden=%' escape '^'


version: 500000000001
rollback_sql:
  CREATE TRIGGER fts4_tag_titles_after_insert AFTER INSERT ON tags BEGIN INSERT INTO fts4_tag_titles(docid, tag) VALUES(new.rowid, new.tag); END


version: 500000000001.011
rollback_sql:
  CREATE TRIGGER fts4_tag_titles_after_update AFTER UPDATE ON tags BEGIN INSERT INTO fts4_tag_titles(docid, tag) VALUES(new.rowid, new.tag); END


version: 500000000001.021
rollback_sql:
  CREATE TRIGGER fts4_tag_titles_before_delete BEFORE DELETE ON tags BEGIN DELETE FROM fts4_tag_titles WHERE docid=old.rowid; END


version: 500000000001.031
rollback_sql:
  CREATE TRIGGER fts4_tag_titles_before_update BEFORE UPDATE ON tags BEGIN DELETE FROM fts4_tag_titles WHERE docid=old.rowid; END


version: 500000000001.041
rollback_sql:
  CREATE TRIGGER fts4_metadata_titles_after_insert AFTER INSERT ON metadata_items BEGIN INSERT INTO fts4_metadata_titles(docid, title, title_sort, original_title) VALUES(new.rowid, new.title, new.title_sort, new.original_title); END


version: 500000000001.051
rollback_sql:
  CREATE TRIGGER fts4_metadata_titles_after_update AFTER UPDATE ON metadata_items BEGIN INSERT INTO fts4_metadata_titles(docid, title, title_sort, original_title) VALUES(new.rowid, new.title, new.title_sort, new.original_title); END


version: 500000000001.061
rollback_sql:
  CREATE TRIGGER fts4_metadata_titles_before_delete BEFORE DELETE ON metadata_items BEGIN DELETE FROM fts4_metadata_titles WHERE docid=old.rowid; END


version: 500000000001.071
rollback_sql:
  CREATE TRIGGER fts4_metadata_titles_before_update BEFORE UPDATE ON metadata_items BEGIN DELETE FROM fts4_metadata_titles WHERE docid=old.rowid; END


version: 202107221100
rollback_sql:
  update metadata_items set refreshed_at=NULL where id in (select DISTINCT metadata_items.id from metadata_items join media_items on media_items.metadata_item_id = metadata_items.id where media_items.id in ( select DISTINCT media_item_id from media_streams where language<>'' and length(language)<>3 and url<>'' and url<>'blob://'))


version: 202107221100.011
rollback_sql:
  update media_items set media_analysis_version=0 where media_analysis_version>0 and id in (select distinct media_item_id from media_streams where language<>'' and length(language)<>3)


version: 202203040100
rollback_sql:
  update metadata_items set originally_available_at = iif(typeof(originally_available_at) in ('integer', 'real'), datetime(originally_available_at, 'unixepoch'), originally_available_at), available_at = iif(typeof(available_at) in ('integer', 'real'), datetime(available_at, 'unixepoch', 'localtime'), available_at), expires_at = iif(typeof(expires_at) in ('integer', 'real'), datetime(expires_at, 'unixepoch', 'localtime'), expires_at), refreshed_at = iif(typeof(refreshed_at) in ('integer', 'real'), datetime(refreshed_at, 'unixepoch', 'localtime'), refreshed_at), added_at = iif(typeof(added_at) in ('integer', 'real'), datetime(added_at, 'unixepoch', 'localtime'), added_at), created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at), deleted_at = iif(typeof(deleted_at) in ('integer', 'real'), datetime(deleted_at, 'unixepoch', 'localtime'), deleted_at)


version: 202203040100.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'metadata_items' AND type = 'table'


version: 202203220200
rollback_sql:
  update media_items set begins_at = iif(typeof(begins_at) in ('integer', 'real'), datetime(begins_at, 'unixepoch'), begins_at), ends_at = iif(typeof(ends_at) in ('integer', 'real'), datetime(ends_at, 'unixepoch'), ends_at), created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at), deleted_at = iif(typeof(deleted_at) in ('integer', 'real'), datetime(deleted_at, 'unixepoch', 'localtime'), deleted_at)


version: 202203220200.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_items' AND type = 'table'


version: 202204252200
rollback_sql:
  update media_parts set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at), deleted_at = iif(typeof(deleted_at) in ('integer', 'real'), datetime(deleted_at, 'unixepoch', 'localtime'), deleted_at)


version: 202204252200.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_parts' AND type = 'table'


version: 202204252300
rollback_sql:
  update media_streams set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at)


version: 202204252300.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_streams' AND type = 'table'


version: 202204252330
rollback_sql:
  update metadata_item_settings set last_viewed_at = iif(typeof(last_viewed_at) in ('integer', 'real'), datetime(last_viewed_at, 'unixepoch', 'localtime'), last_viewed_at), last_skipped_at = iif(typeof(last_skipped_at) in ('integer', 'real'), datetime(last_skipped_at, 'unixepoch', 'localtime'), last_skipped_at), last_rated_at = iif(typeof(last_rated_at) in ('integer', 'real'), datetime(last_rated_at, 'unixepoch', 'localtime'), last_rated_at), created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at)


version: 202204252330.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'metadata_item_settings' AND type = 'table'


version: 202205090900
rollback_sql:
  update media_item_settings set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at)


version: 202205090900.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_item_settings' AND type = 'table'


version: 202205090930
rollback_sql:
  update media_part_settings set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at)


version: 202205090930.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_part_settings' AND type = 'table'


version: 202205090940
rollback_sql:
  update media_stream_settings set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at)


version: 202205090940.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_stream_settings' AND type = 'table'


version: 202205091600
rollback_sql:
  update metadata_item_views set originally_available_at = iif(typeof(originally_available_at) in ('integer', 'real'), datetime(originally_available_at, 'unixepoch', 'localtime'), originally_available_at), viewed_at = iif(typeof(viewed_at) in ('integer', 'real'), datetime(viewed_at, 'unixepoch', 'localtime'), viewed_at)


version: 202205091600.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'metadata_item_views' AND type = 'table'


version: 202205091700
rollback_sql:
  update view_settings set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at), updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at)


version: 202205091700.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'view_settings' AND type = 'table'


# tags

tag: Optimized for Mobile
created_at: 2022-07-20 16:21:23
updated_at: 2022-07-20 16:21:23
extra_data:
  sr%3AdeviceProfile=Universal%20Mobile&sr%3AmediaSettings=advancedSubtitles%3Dburn%26autoAdjustQuality%3D0%26directPlay%3D1%26directStream%3D1%26directStreamAudio%3D1%26subtitles%3Dauto%26videoBitrate%3D4000%26videoQuality%3D74%26videoResolution%3D1280x720


tag: Optimized for TV
created_at: 2022-07-20 16:21:23
updated_at: 2022-07-20 16:21:23
extra_data:
  sr%3AdeviceProfile=Universal%20TV&sr%3AmediaSettings=advancedSubtitles%3Dburn%26autoAdjustQuality%3D0%26directPlay%3D1%26directStream%3D1%26directStreamAudio%3D1%26subtitles%3Dauto%26videoBitrate%3D8000%26videoQuality%3D99%26videoResolution%3D1920x1080


tag: Original Quality
created_at: 2022-07-20 16:21:23
updated_at: 2022-07-20 16:21:23
extra_data:
  sr%3AdeviceProfile=Universal%20TV&sr%3AmediaSettings=advancedSubtitles%3Dburn%26autoAdjustQuality%3D0%26directPlay%3D1%26directStream%3D1%26directStreamAudio%3D1%26subtitles%3Dauto


