← ClaudeAtlas

schema-migration-reviewlisted

Use when reviewing or writing a database schema change for Bugzilla 5.0+/Harmony - anything touching Bugzilla/Install/DB.pm, Bugzilla/DB/Schema.pm, or code calling bz_add_column/bz_column_info/bz_alter_column/bz_add_index. Covers idempotent upgrade-script patterns, the abstract-schema type system, and the specific DB-specific SQL functions Harmony's own test suite forbids for MySQL/PostgreSQL/SQLite portability. Trigger for "will this migration run safely twice", "is this portable across databases", or schema/DDL patch review.
topunix/bugzilla-skills · ★ 0 · API & Backend · score 64
Install: claude install-skill topunix/bugzilla-skills
# Bugzilla Schema Migration Review Bugzilla upgrade code runs unconditionally on every `checksetup.pl`/install invocation, against installations at every prior schema version — so every migration in `Bugzilla::Install::DB` must be safe to run against a database that already has the change applied. Portability across MySQL, PostgreSQL, and SQLite is enforced by an actual test (`t/013db_portability.t`), not just convention. Sources are in `reference/`; nothing here is asserted without a citation to the public `bugzilla/harmony` source tree. ## Idempotency pattern The standard pattern in `Bugzilla::Install::DB` is: check whether the change already exists, and only apply it if not. ```perl # Column if (!$dbh->bz_column_info('fielddefs', 'obsolete')) { $dbh->bz_add_column('fielddefs', 'obsolete', {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'}); } # Index if (!$dbh->bz_index_info('email_rates', 'email_rates_message_ts_idx')) { $dbh->bz_add_index('email_rates', 'email_rates_message_ts_idx', ['message_ts']); } ``` When reviewing a new migration function: - A bare `$dbh->bz_add_column(...)` with no preceding `bz_column_info` check is a review finding — it will error (or silently duplicate, depending on driver) on a second run. - `bz_alter_column` is self-guarding: per its POD, "If the new type is the same as the old type, the function returns without changing anything," so it doesn't need a manual existence check the way `bz_add_column` does. - `bz_dro