Skip to content

fix: harden account_filter migration with explicit ALTER (closes #47)#48

Merged
payown merged 1 commit into
mainfrom
fix/migration-add-column
Jun 16, 2026
Merged

fix: harden account_filter migration with explicit ALTER (closes #47)#48
payown merged 1 commit into
mainfrom
fix/migration-add-column

Conversation

@payown

@payown payown commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Found during Phase A behavioral verification. Closes #47.

What

The 1.1.0 upgrade added account_filter by re-running dbDelta() over the CREATE TABLE. dbDelta's in-place column diffing is formatting-sensitive and unreliable; in a real WordPress + SQLite test it did not add the column on an upgrade. Added an explicit, idempotent ensure_columns() (column check + ALTER TABLE ... ADD COLUMN) called from create_tables(), so activation and maybe_upgrade() both add it deterministically.

Verified (real WordPress, SQLite drop-in)

  • Rebuilt the table at the pre-1.1.0 schema, set db_version to 1.0.0, ran maybe_upgrade() → column added, db_version → 1.2.0, insert with account_filter succeeds.
  • Re-running the upgrade is idempotent.
  • Fresh installs unaffected (column is in the CREATE TABLE).

PHPCS exit 0, 22/22 unit tests pass.

Closes #47

🤖 Generated with Claude Code

closes #47)

Relying on dbDelta() to add account_filter to an existing outpost_hashtags
table is fragile (dbDelta is formatting-sensitive). Add a deterministic,
idempotent column check + ALTER TABLE in create_tables() (ensure_columns()),
so both activation and maybe_upgrade() reliably add the column on in-place
upgrades. Verified in a real WordPress install on the SQLite drop-in:
upgrading a pre-1.1.0-schema table now adds the column and is idempotent.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI review requested due to automatic review settings June 16, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Hardens the plugin’s schema migration for the outpost_hashtags.account_filter column by avoiding reliance on dbDelta()’s formatting-sensitive diffing behavior, ensuring deterministic upgrades (notably for SQLite drop-in environments).

Changes:

  • Calls a new ensure_columns() from create_tables() to explicitly add later-introduced columns via idempotent ALTER TABLE ... ADD COLUMN.
  • Adds column_exists() helper used to detect whether account_filter is present before applying the migration.
  • Updates the maybe_upgrade() comment to reflect the new deterministic migration step.

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

*/
private static function column_exists( $table, $column ) {
global $wpdb;
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- trusted table name; column is placeheld.
@payown payown merged commit 182aa91 into main Jun 16, 2026
2 checks passed
@payown payown deleted the fix/migration-add-column branch June 16, 2026 20:31
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.

fix: harden account_filter column migration (don't rely on dbDelta diffing)

2 participants