# 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'


version: 202209091100
rollback_sql:
  CREATE INDEX 'index_cloudsync_files_on_device_identifier_and_original_url' ON 'cloudsync_files' ('device_identifier', 'original_url')


version: 202209091100.021
rollback_sql:
  CREATE TABLE 'cloudsync_files' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'device_identifier' varchar(255), 'original_url' varchar(255), 'provider' varchar(255), 'new_key' varchar(255), 'query_string' varchar(255), 'extra_data' varchar(255))


version: 202209271322.011
rollback_sql:
  CREATE INDEX 'index_synchronization_files_on_sync_item_id' ON 'synchronization_files' ('sync_item_id' )


version: 202209271322.021
rollback_sql:
  CREATE INDEX 'index_synchronization_files_on_sync_list_id' ON 'synchronization_files' ('sync_list_id' )


version: 202209271322.031
rollback_sql:
  CREATE INDEX 'index_synchronization_files_on_client_identifier' ON 'synchronization_files' ('client_identifier' )


version: 202209271322.041
rollback_sql:
  CREATE TABLE IF NOT EXISTS 'synchronization_files' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'client_identifier' varchar(255), 'sync_list_id' integer(8), 'sync_item_id' integer(8), 'item_uri' varchar(255), 'num_parts' integer, 'state' integer, 'state_context' integer, 'extra_data' varchar(255))


version: 202209271322.061
rollback_sql:
  CREATE UNIQUE INDEX 'index_synced_play_queue_generators_on_sync_list_id_and_play_queue_generator_id' ON 'synced_play_queue_generators' ('sync_list_id', 'play_queue_generator_id' )


version: 202209271322.071
rollback_sql:
  CREATE INDEX 'index_synced_play_queue_generators_on_state' ON 'synced_play_queue_generators' ('state' )


version: 202209271322.081
rollback_sql:
  CREATE INDEX 'index_synced_play_queue_generators_on_changed_at' ON 'synced_play_queue_generators' ('changed_at' )


version: 202209271322.091
rollback_sql:
  CREATE INDEX 'index_synced_play_queue_generators_on_play_queue_generator_id' ON 'synced_play_queue_generators' ('play_queue_generator_id' )


version: 202209271322.101
rollback_sql:
  CREATE INDEX 'index_synced_play_queue_generators_on_playlist_id' ON 'synced_play_queue_generators' ('playlist_id' )


version: 202209271322.111
rollback_sql:
  CREATE INDEX 'index_synced_play_queue_generators_on_sync_item_id' ON 'synced_play_queue_generators' ('sync_item_id' )


version: 202209271322.121
rollback_sql:
  CREATE INDEX 'index_synced_play_queue_generators_on_sync_list_id' ON 'synced_play_queue_generators' ('sync_list_id' )


version: 202209271322.131
rollback_sql:
  CREATE TABLE IF NOT EXISTS 'synced_play_queue_generators' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'sync_list_id' integer(8), 'sync_item_id' integer(8), 'playlist_id' integer, 'play_queue_generator_id' integer, 'changed_at' integer(8), 'state' integer, 'state_context' integer, 'first_packaged_at' integer(8))


version: 202209271322.151
rollback_sql:
  CREATE UNIQUE INDEX 'index_synced_metadata_items_on_sync_list_id_and_metadata_item_id' ON 'synced_metadata_items' ('sync_list_id', 'metadata_item_id' )


version: 202209271322.161
rollback_sql:
  CREATE INDEX 'index_synced_metadata_items_library_section_id' ON 'synced_metadata_items' ('library_section_id')


version: 202209271322.191
rollback_sql:
  CREATE INDEX 'index_synced_metadata_items_on_first_packaged_at' ON 'synced_metadata_items' ('first_packaged_at' )


version: 202209271322.211
rollback_sql:
  CREATE INDEX 'index_synced_metadata_items_on_metadata_item_id' ON 'synced_metadata_items' ('metadata_item_id' )


version: 202209271322.221
rollback_sql:
  CREATE INDEX 'index_synced_metadata_items_on_sync_item_id' ON 'synced_metadata_items' ('sync_item_id' )


version: 202209271322.231
rollback_sql:
  CREATE INDEX 'index_synced_metadata_items_on_sync_list_id' ON 'synced_metadata_items' ('sync_list_id' )


version: 202209271322.241
rollback_sql:
  CREATE TABLE IF NOT EXISTS 'synced_metadata_items' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'sync_list_id' integer(8), 'sync_item_id' integer(8), 'metadata_item_id' integer, 'changed_at' integer(8), 'first_packaged_at' integer(8), 'state' integer, 'state_context' integer, 'selected_media_id' integer, 'selected_part_id' integer, 'media_decision' integer, 'file_size' integer(8), 'media_analysis_extra_data' varchar(255), 'parent_id' integer, 'library_section_id' integer)


version: 202209271322.261
rollback_sql:
  CREATE UNIQUE INDEX 'index_synced_library_sections_on_sync_list_id_and_library_section_id' ON 'synced_library_sections' ('sync_list_id', 'library_section_id')


version: 202209271322.281
rollback_sql:
  CREATE INDEX 'index_synced_library_sections_on_reference_count' ON 'synced_library_sections' ('reference_count')


version: 202209271322.291
rollback_sql:
  CREATE INDEX 'index_synced_library_sections_on_changed_at' ON 'synced_library_sections' ('changed_at')


version: 202209271322.301
rollback_sql:
  CREATE INDEX 'index_synced_library_sections_on_library_section_id' ON 'synced_library_sections' ('library_section_id')


version: 202209271322.311
rollback_sql:
  CREATE INDEX 'index_synced_library_sections_on_sync_list_id' ON 'synced_library_sections' ('sync_list_id')


version: 202209271322.321
rollback_sql:
  CREATE TABLE IF NOT EXISTS 'synced_library_sections' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'sync_list_id' integer(8), 'library_section_id' integer, 'changed_at' integer(8), 'reference_count' integer, 'first_packaged_at' integer(8), 'state' integer)


version: 202209271322.341
rollback_sql:
  CREATE UNIQUE INDEX 'index_synced_ancestor_items_on_sync_list_id_and_metadata_item_id' ON 'synced_ancestor_items' ('sync_list_id', 'metadata_item_id')


version: 202209271322.371
rollback_sql:
  CREATE INDEX 'index_synced_ancestor_items_on_reference_count' ON 'synced_ancestor_items' ('reference_count')


version: 202209271322.391
rollback_sql:
  CREATE INDEX 'index_synced_ancestor_items_on_metadata_item_id' ON 'synced_ancestor_items' ('metadata_item_id')


version: 202209271322.401
rollback_sql:
  CREATE INDEX 'index_synced_ancestor_items_on_sync_list_id' ON 'synced_ancestor_items' ('sync_list_id')


version: 202209271322.411
rollback_sql:
  CREATE TABLE IF NOT EXISTS 'synced_ancestor_items' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'sync_list_id' integer(8), 'metadata_item_id' integer, 'changed_at' integer(8), 'reference_count' integer, 'first_packaged_at' integer(8), 'parent_id' integer, 'state' integer)


version: 202209271322.441
rollback_sql:
  CREATE TABLE IF NOT EXISTS 'sync_schema_versions' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'version' integer, 'changed_at' integer(8))


version: 202210260000
rollback_sql:
  update directories 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: 202210260000.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'directories' AND type = 'table'


version: 202210260100
rollback_sql:
  update library_sections 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), scanned_at = iif(typeof(scanned_at) in ('integer', 'real'), datetime(scanned_at, 'unixepoch', 'localtime'), scanned_at)


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


version: 202210260200
rollback_sql:
  update section_locations 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), scanned_at = iif(typeof(scanned_at) in ('integer', 'real'), datetime(scanned_at, 'unixepoch', 'localtime'), scanned_at)


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


version: 202212012200
rollback_sql:
  update tags 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: 202212012200.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'tags' AND type = 'table'


version: 202212012300
rollback_sql:
  update taggings set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at)


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


version: 202212022100
rollback_sql:
  update media_grabs 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: 202212022100.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_grabs' AND type = 'table'


version: 202212022200
rollback_sql:
  update media_provider_resources set last_seen_at = iif(typeof(last_seen_at) in ('integer', 'real'), datetime(last_seen_at, 'unixepoch', 'localtime'), last_seen_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: 202212022200.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_provider_resources' AND type = 'table'


version: 202212022300
rollback_sql:
  update media_subscriptions 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: 202212022300.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_subscriptions' AND type = 'table'


version: 202309200901
rollback_sql:
  UPDATE external_metadata_items SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200902
rollback_sql:
  UPDATE hub_templates SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200903
rollback_sql:
  UPDATE locatables SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200904
rollback_sql:
  UPDATE media_grabs SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200905
rollback_sql:
  UPDATE media_provider_resources SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200906
rollback_sql:
  UPDATE media_stream_settings SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200907
rollback_sql:
  UPDATE media_subscriptions SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200908
rollback_sql:
  UPDATE metadata_agent_providers SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200909
rollback_sql:
  UPDATE metadata_item_clusters SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200910
rollback_sql:
  UPDATE metadata_item_setting_markers SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200911
rollback_sql:
  UPDATE media_items SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200912
rollback_sql:
  UPDATE media_parts SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200913
rollback_sql:
  UPDATE media_streams SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200914
rollback_sql:
  UPDATE metadata_item_settings SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200915
rollback_sql:
  UPDATE metadata_items SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200916
rollback_sql:
  UPDATE play_queue_generators SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200917
rollback_sql:
  UPDATE play_queues SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200918
rollback_sql:
  UPDATE taggings SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202309200919
rollback_sql:
  UPDATE tags SET extra_data = extra_data ->> 'url' WHERE extra_data IS NOT NULL and json_valid(extra_data)


version: 202312190800
rollback_sql:
  update blobs set created_at = iif(typeof(created_at) in ('integer', 'real'), datetime(created_at, 'unixepoch', 'localtime'), created_at)


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


version: 202401290800
rollback_sql:
  update locatables 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: 202401290800.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'locatables' AND type = 'table'


version: 202401290801
rollback_sql:
  update accounts 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: 202401290801.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'accounts' AND type = 'table'


version: 202401290802
rollback_sql:
  update metadata_item_clusters set starts_at = iif(typeof(starts_at) in ('integer', 'real'), datetime(starts_at, 'unixepoch', 'localtime'), starts_at),ends_at = iif(typeof(ends_at) in ('integer', 'real'), datetime(ends_at, 'unixepoch', 'localtime'), ends_at)


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


version: 202401290803
rollback_sql:
  update metadata_relations 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: 202401290803.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'metadata_relations' AND type = 'table'


version: 202401290804
rollback_sql:
  update play_queues 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: 202401290804.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'play_queues' AND type = 'table'


version: 202401290805
rollback_sql:
  update play_queue_generators 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: 202401290805.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'play_queue_generators' AND type = 'table'


version: 202401290806
rollback_sql:
  update plugins set installed_at = iif(typeof(installed_at) in ('integer', 'real'), datetime(installed_at, 'unixepoch', 'localtime'), installed_at),accessed_at = iif(typeof(accessed_at) in ('integer', 'real'), datetime(accessed_at, 'unixepoch', 'localtime'), accessed_at),modified_at = iif(typeof(modified_at) in ('integer', 'real'), datetime(modified_at, 'unixepoch', 'localtime'), modified_at)


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


version: 202401290807
rollback_sql:
  update devices 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: 202401290807.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'devices' AND type = 'table'


version: 202401290808
rollback_sql:
  update statistics_resources set at = iif(typeof(at) in ('integer', 'real'), datetime(at, 'unixepoch', 'localtime'), at)


version: 202401290808.011
rollback_sql:
  update statistics_media set at = iif(typeof(at) in ('integer', 'real'), datetime(at, 'unixepoch', 'localtime'), at)


version: 202401290808.021
rollback_sql:
  update statistics_bandwidth set at = iif(typeof(at) in ('integer', 'real'), datetime(at, 'unixepoch', 'localtime'), at)


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


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


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


version: 202402260802
rollback_sql:
  update library_timeline_entries set updated_at = iif(typeof(updated_at) in ('integer', 'real'), datetime(updated_at, 'unixepoch', 'localtime'), updated_at)


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


version: 202402260803
rollback_sql:
  update media_metadata_mappings 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: 202402260803.021
rollback_sql:
  UPDATE sqlite_schema SET sql = replace(sql, 'dt_integer(8)', 'datetime') WHERE name = 'media_metadata_mappings' AND type = 'table'


version: 20240718114400
rollback_sql:
  UPDATE library_sections SET agent = 'com.plexapp.agents.none', language = 'en' WHERE agent = 'tv.plex.agents.none' AND section_type = 13


version: 202407301359
rollback_sql:
  UPDATE library_sections SET agent = 'com.plexapp.agents.none', scanner = 'Plex Music Scanner', language = 'xn' WHERE agent = 'tv.plex.agents.none' AND scanner = 'Plex Music'


version: 202407301359.011
rollback_sql:
  UPDATE library_sections SET agent = 'com.plexapp.agents.none', scanner = 'Plex Series Scanner', language = 'xn' WHERE agent = 'tv.plex.agents.none' AND scanner = 'Plex TV Series'


version: 202407301359.021
rollback_sql:
  UPDATE library_sections SET agent = 'com.plexapp.agents.none', scanner = 'Plex Movie Scanner', language = 'xn' WHERE agent = 'tv.plex.agents.none' AND scanner = 'Plex Movie'


