If you ever run into this:
Error: Unable to set up server: sqlite3_statement_backend::prepare: no such table: schema_migrations for SQL: select version from schema_migrations order by version (N4soci10soci_errorE)
when starting a Plex docker image you built with nix and pkgs, like so:
pkgs.dockerTools.buildImage {
name = "repo/plex-media-server";
copyToRoot = [ pkgs.plexRaw ];
config.Entrypoint = [
"${pkgs.plexRaw}/lib/plexmediaserver/Plex Media Server"
];
}
It’s because of this. So make sure to copy the initial plex db into the image as well (like the module does)
pkgs.dockerTools.buildImage {
name = "repo/plex-media-server";
runAsRoot = ''
#!${pkgs.runtimeShell}
cat "${pkgs.plexRaw.basedb}" >/db
'';
...
}
That is all.
EDIT: Oh. And the reason why I posted this is because when Plex is unable to copy the template database it is not a fatal error. It happily moves on with launching and starts sqlite, which then creates an empty database (hence the error). And if you run this in kubernetes where container starts are retried, the initial error message is hidden in the very first log that has been rotated into oblivion by the restarts. Afterwards Plex sees the empty db and thinks it doesn’t need to copy the template, so no error message about not being able to find the file.