schema-migration-reviewlisted
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