Can no longer update library database with sqlite3

This has worked for me:

# Be save
service plexmediaserver stop
# This is the location for Plex Media Server SQLite Databases
cd '/Plex Media Server/Plug-in Support/Databases'
# This is the location for Plex Media Server Program/Executable on TrueNAS iocage jails
/usr/local/share/plexmediaserver
# Try a simple SELECT
/usr/local/share/plexmediaserver/Plex\ Media\ Server --sqlite com.plexapp.plugins.library.db \
"SELECT * FROM metadata_items LIMIT 2"
#
#Better do a quick count on how many rows are affected

/usr/local/share/plexmediaserver/Plex\ Media\ Server --sqlite com.plexapp.plugins.library.db \
 "SELECT COUNT(*) FROM metadata_items WHERE added_at LIKE '2021-05-23 10%' AND originally_available_at IS NOT NULL"

Returned 4301 rows 
# DANGER DANGER doing the UPDATE STATEMENT
/usr/local/share/plexmediaserver/Plex\ Media\ Server --sqlite com.plexapp.plugins.library.db \
 "UPDATE metadata_items SET added_at = originally_available_at WHERE added_at LIKE '2021-05-23 10%' AND originally_available_at IS NOT NULL;"
#
# Now do a quick count again on how many rows are affected
/usr/local/share/plexmediaserver/Plex\ Media\ Server --sqlite com.plexapp.plugins.library.db \
 "SELECT COUNT(*) FROM metadata_items WHERE added_at LIKE '2021-05-23 10%' AND originally_available_at IS NOT NULL"

Returned 31 rows
# To get an idea what those files are… (BTW here this has to do with how Nextcloud does instant uploads from my phone, it is okay-ish)
/usr/local/share/plexmediaserver/Plex\ Media\ Server --sqlite com.plexapp.plugins.library.db \
 "SELECT added_at, originally_available_at, title FROM metadata_items WHERE added_at LIKE '2021-05-23 10%' AND originally_available_at IS NOT NULL "
2021-05-23 10:16:14|2021-05-23 10:16:14|Video 21-05-04 08-11-33 6159
2021-05-23 10:16:14|2021-05-23 10:16:14|Video 21-05-04 15-21-01 6161
2021-05-23 10:16:14|2021-05-23 10:16:14|Video 21-05-04 15-59-37 6162
2021-05-23 10:16:14|2021-05-23 10:16:14|Video 21-05-09 10-05-12 6191
2021-05-23 10:16:14|2021-05-23 10:16:14|Video 21-05-18 19-02-59 6282
2021-05-23 10:16:17|2021-05-23 10:16:17|Video 21-04-24 08-40-14 6103
2021-05-23 10:16:17|2021-05-23 10:16:17|Video 21-04-27 11-29-57 6104
2021-05-23 10:16:21|2021-05-23 10:16:21|Video 21-04-28 15-21-46 6106
2021-05-23 10:16:32|2021-05-23 10:16:32|Video 21-01-24 09-52-27 5589
2021-05-23 10:16:38|2021-05-23 10:16:38|Video 21-01-24 16-15-47 5598
2021-05-23 10:16:38|2021-05-23 10:16:38|Video 21-01-24 16-15-47 5599
2021-05-23 10:16:38|2021-05-23 10:16:38|Video 21-01-27 20-42-37 5609
2021-05-23 10:16:38|2021-05-23 10:16:38|Video 21-01-28 12-14-33 5611
2021-05-23 10:16:39|2021-05-23 10:16:39|Video 21-01-29 13-13-52 5617
2021-05-23 10:16:40|2021-05-23 10:16:40|Video 21-03-13 17-55-51 5855
2021-05-23 10:16:43|2021-05-23 10:16:43|Video 21-02-12 09-34-41 5738
2021-05-23 10:16:43|2021-05-23 10:16:43|Video 21-02-13 13-11-51 5747
2021-05-23 10:16:44|2021-05-23 10:16:44|Video 21-02-13 16-37-50 5748
2021-05-23 10:16:44|2021-05-23 10:16:44|Video 21-02-14 09-32-39 5757
2021-05-23 10:16:44|2021-05-23 10:16:44|Video 21-02-14 15-02-03 5763
2021-05-23 10:16:47|2021-05-23 10:16:47|Video 20-11-06 21-59-08 5185
2021-05-23 10:16:47|2021-05-23 10:16:47|Video 20-11-16 18-05-08 5206
2021-05-23 10:16:47|2021-05-23 10:16:47|Video 20-11-21 17-05-20 5218
2021-05-23 10:16:47|2021-05-23 10:16:47|Video 20-11-22 12-56-08 5245
2021-05-23 10:16:47|2021-05-23 10:16:47|Video 20-11-22 12-57-44 5246
2021-05-23 10:16:48|2021-05-23 10:16:48|Video 20-11-28 10-33-44 5280
2021-05-23 10:16:50|2021-05-23 10:16:50|Video 20-12-12 21-33-10 5361
2021-05-23 10:16:51|2021-05-23 10:16:51|Video 20-12-13 11-07-02 5364
2021-05-23 10:16:53|2021-05-23 10:16:53|Video 20-12-24 11-45-56 5405
2021-05-23 10:17:01|2021-05-23 10:17:01|Video 20-12-31 19-31-15 5475
2021-05-23 10:17:21|2021-05-23 10:17:21|Video 20-04-09 10-58-39 3861

Hope this will help others
Cheers

3 Likes