-
Notifications
You must be signed in to change notification settings - Fork 53
Update SQLite plugin to 2.2.3 and enable new driver #1506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I tested importing, exporting, and sync for combinations:
The pull action for the last one still fails, but it's being addressed under WordPress/sqlite-database-integration#203. If I manually apply this change to the driver on my site before the pull, the issue with undefined DB_NAME is resolved. However, another problem, |
|
|
||
| const wpConfigConsts = {}; | ||
| const wpConfigConsts = { | ||
| WP_SQLITE_AST_DRIVER: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set the constant to enable the new driver for the site's WP admin and frontend.
| // Execute the command to export directly to the temp file | ||
| const { stderr, exitCode } = await server.executeWpCliCommand( | ||
| `sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php`, | ||
| `sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php --enable-ast-driver`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set the parameter to enable the AST driver for CLI actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably won't add more commands, but I wonder if we should opt-in to use the AST driver more broadly. Like enable it by default, or auto-append the parameter in the wp-cli-process, similarly to how we increase the timeout:
studio/src/lib/wp-cli-process.ts
Lines 67 to 70 in 48bf68b
| const timeout = | |
| args[ 0 ] === 'sqlite' && [ 'import', 'export' ].includes( args[ 1 ] ) | |
| ? IMPORT_EXPORT_RESPONSE_TIMEOUT | |
| : DEFAULT_RESPONSE_TIMEOUT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but we should remove this parameter as soon as the SQLite driver enables it by default. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, let's leave it as it is. There is no risk that we'll introduce more SQLite commands and forget to add the parameter in the meantime. 👍
|
Issues covered in previous comment are fixed now. |
sejas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the test instructions but I'm getting the DB_NAME error. @wojtekn , do you know if that's expected?
Node error:
Success: Exporting database...
<br />
<b>Fatal error</b>: Uncaught Error: Undefined constant "Automattic\WP_CLI\SQLite\DB_NAME" in /tmp/sqlite-command/src/SQLiteDriverFactory.php:24
| // Execute the command to export directly to the temp file | ||
| const { stderr, exitCode } = await server.executeWpCliCommand( | ||
| `sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php`, | ||
| `sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php --enable-ast-driver`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably won't add more commands, but I wonder if we should opt-in to use the AST driver more broadly. Like enable it by default, or auto-append the parameter in the wp-cli-process, similarly to how we increase the timeout:
studio/src/lib/wp-cli-process.ts
Lines 67 to 70 in 48bf68b
| const timeout = | |
| args[ 0 ] === 'sqlite' && [ 'import', 'export' ].includes( args[ 1 ] ) | |
| ? IMPORT_EXPORT_RESPONSE_TIMEOUT | |
| : DEFAULT_RESPONSE_TIMEOUT; |
|
Thanks for testing it @sejas .
Could you open this site's SQLite driver in |
src/constants.ts
Outdated
|
|
||
| // SQLite | ||
| export const SQLITE_DATABASE_INTEGRATION_VERSION = 'v2.1.17-alpha.1'; | ||
| export const SQLITE_DATABASE_INTEGRATION_VERSION = 'v2.2.2'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the new version v2.2.3
| export const SQLITE_DATABASE_INTEGRATION_VERSION = 'v2.2.2'; | |
| export const SQLITE_DATABASE_INTEGRATION_VERSION = 'v2.2.3; |
| // Execute the command to export directly to the temp file | ||
| const { stderr, exitCode } = await server.executeWpCliCommand( | ||
| `sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php`, | ||
| `sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php --enable-ast-driver`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, let's leave it as it is. There is no risk that we'll introduce more SQLite commands and forget to add the parameter in the meantime. 👍
Actually I have the version Also we'll need to test the push process. I got an error when importing a dump that used the SQLite 2.2.2 without the new parameter in the command. |
|
I think we need to add another test instruction at the beginning. We need to run |
|
@sejas all the instructions were written for 2.2.3, but I haven't pushed the code change for that. I've pushed 2.2.3 now. I've added an explicit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wojtekn , I was able to execute the testing steps and export the database without any "errors".
But I see the database dump is almost empty. It has only one line:
-- Dump completed on 2025-07-10T12:15:57+00:00
|
After some more testing, the empty dump only happens in one of my sites. I confirmed the site has the 2.2.3 plugin, and removed other plugins like Gutenberg. The site starts correctly in Studio and I can access wp-admin. I'll test the site with the old driver. The rest of sites export the database correctly and I was able to pull and push to production. 👍 |
|
On trunk, and after replacing the sqlite plugin to 2.1.17-alpha, the database is exported correctly. |
|
@sejas Is there a way for me to reproduce that? Perhaps a DB dump? (We can also share it on Slack.) |
|
I'll share the database. Let me know if you need the whole site. |
|
@sejas So I checked this, and for me, the issue seems to be those problems with It seems to be like this:
I think the solution is:
|
sejas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this PR with the latest commit Automattic/wp-cli-sqlite-command@957e06a on sqlite command and I confirm it works in all my sites, even the one that was failing.
I also have to say the export database is much faster than the regular driver.
bcotrim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this PR in the context of STU-611 and it seems to be working without issues.
👍
@JanJakes @sejas there may still be a use case for which it won't work - for the site that was imported with a custom database name in However, the fix for such a case is straightforward - the user should change the database name in the config file to |
In SQLite Database Integration 2.2.4, this should fail with |


Related issues
Proposed Changes
I propose to update the SQLite plugin to 2.2.3 and enable the new driver.
The driver uses constants to enable the new driver, but due to Playground/Studio/WP CLI specifics, the WP CLI command doesn't have access to the constants defined through Playground code. Thus, I used a custom WP CLI parameter to enable the driver explicitly. We can deprecate that parameter when we enable the driver by default.
Release plan:
wp-cli-sqlite-commandPR and release new version of library. Any Studio installation will automatically upgrade to the latest version, and the latest version of the command will still work with Studio that uses the SQLite driver 2.1.17-alpha.1Testing Instructions
npm installwp-cli-sqlite-commandPR locally (Add support for the new SQLite driver wp-cli-sqlite-command#10)composer install --no-dev --optimize-autoloader --ignore-platform-reqsin thewp-cli-sqlite-commanddirectorywp-files/sqlite-commandin the Studio code with a symlink to your localwp-cli-sqlite-commanddirectorynpm start. It will copy the symlinked command files to directory underserver-files/.sqlfile is created.sqlfile and validate that the dump is correct - dump which uses AST driver will havewp_commentmetaas the first dumped table. Confirm that field has types with length set, thatENGINE=InnoDBexists.In steps 1-5, we are ensuring that Studio uses the development version of the WP CLI SQLite command. Those won't be needed when we merge the release
wp-cli-sqlite-commandPR and release a new version.The test cases worth testing:
trunkwith SQLite driver 2.1.17-alpha.1 and WP CLI SQLite v1.0.6 - current version, to confirm everything works.trunkwith SQLite driver 2.1.17-alpha.1 and WP CLI SQLite fromnew-sqlite-driverbranch - to confirm current Studio installation will work when we release new WP CLI SQLite and when Studio automatically upgrades it.update/sqlite-plugin-to-2.2.0branch with SQLite driver 2.2.3 and WP CLI SQLite fromnew-sqlite-driverbranch - to confirm everything works fine with AST driverPre-merge Checklist