Skip to content

fix: SQLite compatibility for WordPress Studio activation#1026

Merged
chubes4 merged 1 commit intomainfrom
fix/sqlite-compat
Apr 7, 2026
Merged

fix: SQLite compatibility for WordPress Studio activation#1026
chubes4 merged 1 commit intomainfrom
fix/sqlite-compat

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Apr 7, 2026

Summary

  • Fixes Feature Request: Data Machine activation fails on WordPress Studio (SQLite) #1025 — Data Machine fails to activate on WordPress Studio (SQLite)
  • Replaces all information_schema.COLUMNS + DB_NAME queries with SHOW COLUMNS via a new BaseRepository::column_exists() helper
  • The SQLite Database Integration translator already handles SHOW COLUMNS FROM table LIKE 'column', so no SQLite-specific SQL needed
  • Guards MODIFY COLUMN migrations (MySQL-only) behind BaseRepository::get_column_meta() which returns empty on SQLite
  • Adds BaseRepository::is_sqlite() detection using the canonical DATABASE_TYPE constant
  • Adds SQLite fallback for RetentionCommand table size stats

Files changed (9 files, 14 query sites)

File What changed
BaseRepository.php New is_sqlite(), column_exists(), get_column_meta() helpers
Pipelines.php 2x information_schemacolumn_exists()
Flows.php 2x information_schemacolumn_exists()
Jobs.php 4x information_schemacolumn_exists() / get_column_meta()
Agents.php Raw SHOW COLUMNScolumn_exists()
Chat.php 3x SHOW COLUMNScolumn_exists()
backfill.php 2x information_schemacolumn_exists()
migrations.php 2x information_schemacolumn_exists()
RetentionCommand.php information_schema.tables → SQLite fallback with COUNT(*)

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 TABLE with AUTO_INCREMENT, charset, etc. ✅

What it does not handle (and what was breaking activation):

  • information_schema.COLUMNS with column-specific WHERE clauses ❌
  • DB_NAME constant (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-kit to run Data Machine on Studio sites.

…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.
@chubes4 chubes4 merged commit 5c4acd8 into main Apr 7, 2026
1 check failed
@chubes4 chubes4 deleted the fix/sqlite-compat branch April 7, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Data Machine activation fails on WordPress Studio (SQLite)

1 participant