fix: SQLite compatibility for WordPress Studio activation#1026
Merged
Conversation
…closes #1025) Data Machine fails to activate on WordPress Studio (SQLite) because migration code uses information_schema.COLUMNS + DB_NAME — neither of which exist in SQLite. Changes: - Add BaseRepository::is_sqlite(), column_exists(), get_column_meta() - Replace all information_schema + DB_NAME column checks with column_exists() using SHOW COLUMNS (which the SQLite translator already handles) - Guard MODIFY COLUMN migrations behind get_column_meta() which returns empty on SQLite (MODIFY is MySQL-only, tables are created with correct types from the start via dbDelta) - Add SQLite fallback for RetentionCommand table stats Affects: Pipelines, Flows, Jobs, Agents, Chat, migrations, backfill, RetentionCommand — 9 files, 14 query sites fixed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
information_schema.COLUMNS+DB_NAMEqueries withSHOW COLUMNSvia a newBaseRepository::column_exists()helperSHOW COLUMNS FROM table LIKE 'column', so no SQLite-specific SQL neededMODIFY COLUMNmigrations (MySQL-only) behindBaseRepository::get_column_meta()which returns empty on SQLiteBaseRepository::is_sqlite()detection using the canonicalDATABASE_TYPEconstantRetentionCommandtable size statsFiles changed (9 files, 14 query sites)
BaseRepository.phpis_sqlite(),column_exists(),get_column_meta()helpersPipelines.phpinformation_schema→column_exists()Flows.phpinformation_schema→column_exists()Jobs.phpinformation_schema→column_exists()/get_column_meta()Agents.phpSHOW COLUMNS→column_exists()Chat.phpSHOW COLUMNS→column_exists()backfill.phpinformation_schema→column_exists()migrations.phpinformation_schema→column_exists()RetentionCommand.phpinformation_schema.tables→ SQLite fallback withCOUNT(*)Why this works
The SQLite Database Integration plugin has a query translator that already handles:
SHOW COLUMNS FROM table LIKE 'column'✅SHOW TABLES LIKE 'pattern'✅ALTER TABLE ADD COLUMN✅ALTER TABLE ADD KEY(via index creation) ✅CREATE TABLEwith AUTO_INCREMENT, charset, etc. ✅What it does not handle (and what was breaking activation):
information_schema.COLUMNSwith column-specific WHERE clauses ❌DB_NAMEconstant (doesn't exist on SQLite — causes PHP fatal) ❌ALTER TABLE MODIFY COLUMN(not supported in SQLite) ❌Context
WordPress Studio is the standard local dev environment for Automattic employees. This fix is required for
mattic-agent-kitto run Data Machine on Studio sites.