SQLite version 3.18.0 2017-03-28 18:48:43
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> PRAGMA optimize;
Error: database schema has changed
Notice that VACUUM; ANALYZE; works, as well as PRAGMA optimize; VACUUM;
Given that PRAGMA optimize only calls ANALYZE as of 3.18 on tables that
might benefit, I'd expect it to behave the same as an ANALYZE call --
i.e. either both should return an error, or both should pass.