Skip to content

feat: refactor upgrade routine and add v0.6.0 migrations#321

Merged
dkotter merged 9 commits intodevelopfrom
feat/upgrade-0.6.0
Mar 19, 2026
Merged

feat: refactor upgrade routine and add v0.6.0 migrations#321
dkotter merged 9 commits intodevelopfrom
feat/upgrade-0.6.0

Conversation

@justlevine
Copy link
Copy Markdown
Contributor

@justlevine justlevine commented Mar 18, 2026

What?

This PR creates a new Upgrades routine to handle scalable plugin upgrades and data migrations. Additionally it:

  • Creates the new WordPress/AI/Admin/Upgrades/V0_6_0 for migrating the ai_experiments_* => wpai_feature_* options changed in feat!: Refactor Experiments to be a type of Feature #316
  • Refactors Migrations/Credential_Migration to Admin/Upgrades/V0_5_0.
  • Adds an activation hook to trigger migrations on.

Why?

A central and future-compatible way to scale plugin upgrades.

How?

  1. On plugin activation (or admin_init as a fallback), the Upgrades routine checks gets the db version, and checks if any Abstract_Upgrade classes need to run, by comparing it with the Abstract_Upgrade::$version
  2. If the upgrade succeeds, the db version is upgraded to the Abstract_Upgrade::$version. If it fails, then the Upgrade routine stops and an admin notice is displayed.
  3. One all Upgrade routines succeed, the latest plugin version is saved to the databse.

Todo

  • Backfill tests.

Use of AI Tools

  • Github Copilot autocomplete
  • PHPUnit tests were backfilled by GPT 5.4 and then heavily deslopped.

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

Before After
Open WordPress Playground Preview

@justlevine justlevine requested a review from Copilot March 18, 2026 22:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the legacy credential migration into a versioned upgrade framework and introduces an activation-time upgrade trigger, with an additional v0.6.0 option rename migration.

Changes:

  • Replaces the old Credential_Migration with a new Admin\Upgrades framework (Abstract_Upgrade, Upgrades, activation hook).
  • Moves the v0.5.0 credential migration logic into Admin\Upgrades\V0_5_0 and updates integration tests accordingly.
  • Adds a new v0.6.0 upgrade class to migrate ai_experiment_* options to wpai_* equivalents.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/Integration/Includes/Migrations/Credential_MigrationTest.php Updates integration tests to target the new V0_5_0 upgrade routine and version option key.
includes/bootstrap.php Switches from direct migration call to Upgrades->init() and adds an activation hook to run upgrades.
includes/Migrations/Credential_Migration.php Removes the legacy migration class (replaced by versioned upgrades).
includes/Admin/Upgrades/V0_5_0.php Implements the v0.5.0 credential migration as an upgrade routine class.
includes/Admin/Upgrades/V0_6_0.php Adds option migration logic for v0.6.0 (old ai_experiment_* → new wpai_*).
includes/Admin/Upgrades/Abstract_Upgrade.php Introduces reusable base class for versioned upgrade routines with WP_Error reporting.
includes/Admin/Upgrades.php Adds orchestrator that runs upgrade classes, stores DB version, and shows failure notice.
includes/Admin/Activation.php Adds activation callback that triggers upgrades during plugin activation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 82.75862% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.48%. Comparing base (561768c) to head (3c64c5d).
⚠️ Report is 30 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Admin/Upgrades.php 82.05% 7 Missing ⚠️
includes/Admin/Upgrades/Abstract_Upgrade.php 66.66% 4 Missing ⚠️
includes/Admin/Activation.php 66.66% 1 Missing ⚠️
includes/Admin/Upgrades/V0_5_0.php 91.66% 1 Missing ⚠️
includes/Admin/Upgrades/V0_6_0.php 95.00% 1 Missing ⚠️
includes/bootstrap.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #321      +/-   ##
=============================================
+ Coverage      57.05%   57.48%   +0.42%     
- Complexity       591      610      +19     
=============================================
  Files             42       46       +4     
  Lines           3083     3147      +64     
=============================================
+ Hits            1759     1809      +50     
- Misses          1324     1338      +14     
Flag Coverage Δ
unit 57.48% <82.75%> (+0.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jeffpaul jeffpaul added this to the 0.6.0 milestone Mar 18, 2026
@jeffpaul jeffpaul requested a review from dkotter March 18, 2026 23:18
justlevine and others added 2 commits March 19, 2026 16:23
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
dkotter
dkotter previously approved these changes Mar 19, 2026
@dkotter dkotter mentioned this pull request Mar 19, 2026
33 tasks
@justlevine
Copy link
Copy Markdown
Contributor Author

Tests backfilled 🚀

@dkotter dkotter merged commit 270d258 into develop Mar 19, 2026
19 checks passed
@dkotter dkotter deleted the feat/upgrade-0.6.0 branch March 19, 2026 17:08
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.

Rename plugin from “AI Experiments” to “AI” and define feature vs experiment classification

4 participants