[11.x] Fix SQLite schema dumps containing internal `sqlite_*` objects

Merged
BA
2y ago
+42-3

This PR updates the SQLite schema dump to remove all CREATE TABLE sqlite_* statements. Laravel already removes CREATE TABLE sqlite_sequence(...); if it exists, this PR ensures that we also remove CREATE TABLE sqlite_stat1(...);, CREATE TABLE sqlite_stat4(...);, etc.

These SQLite internal schema object names are reserved and cannot be created except by SQLite itself, so trying to loading dumps that contain any of these statements will fail. The sqlite_stat1 and sqlite_stat4 tables will exist in any SQLite database with data in it that has ever had the PRAGMA optimize; command run, which is likely a significant portion of them since it's recommended in the SQLite docs. There may be other tables with reserved names too, like sqlite_stat2 or sqlite_autoindex_1; this PR ensures they are all removed.

Fixes #52131.