migrations

Guides writing and debugging OrangeHRM database migrations using Doctrine DBAL SchemaHelper.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill migrations-snow-gift111
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrations
Source: https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone/tree/main/.agents/skills/migrations
Command: npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill migrations-snow-gift111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? OrangeHRM uses a custom forward-only migration system with no rollback, no Doctrine Migrations bundle, and a hand-maintained version registry, so writing or debugging a migration without knowing the conventions leads to migrations that never run, half-applied schemas, or broken upgrades. ## Core Features & Use Cases - Migration authoring guidance: Explains the AbstractMigration contract, the MIGRATIONS_MAP registry, and the Doctrine DBAL SchemaHelper patterns for creating tables, changing columns, and juggling foreign keys. - Install vs upgrade semantics: Clarifies how the installer runs all migrations from 3.3.3 while the upgrader runs only newer versions, plus the migration:up dev command for iterating on a single migration. - Recovery and debugging: Documents how to diagnose failed migrations via ohrm_migration_log, resolve "previous migration incomplete" errors, and recover half-applied schemas. - Use Case: When shipping OrangeHRM 5.9.0, you create installer/Migration/V5_9_0/Migration.php, register it in MIGRATIONS_MAP, bump build/build.xml, update CHANGELOG.TXT, and test with migration:up before running the full upgrader path. ## Quick Start Ask the agent to create a new OrangeHRM migration for version 5.9.0 that adds a column to an existing table and registers it correctly.

Frequently Asked Questions about migrations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a new OrangeHRM database migration?

Create installer/Migration/V<x_y_z>/Migration.php extending AbstractMigration, implement up() using getSchemaHelper() and createQueryBuilder(), return the exact version string from getVersion(), then register the class at the end of AppSetupUtility::MIGRATIONS_MAP.

How do I test an OrangeHRM migration without a full reinstall?

Run php devTools/core/console.php migration:up with the fully qualified migration class name. It executes up() and writes instance.version, but skips ohrm_migration_log and version-range checks, so make the migration idempotent or reset between runs.

Should I use raw SQL or SchemaHelper in OrangeHRM migrations?

Use SchemaHelper with Doctrine DBAL for all new 5.x migrations; raw SQL dumps are the legacy V3.3.3 baseline pattern imported from 4.x and must not be used for new work. Raw executeStatement is acceptable only for operations DBAL cannot express.

Why does my OrangeHRM migration not run after I added it?

The most common cause is forgetting to register the class in AppSetupUtility::MIGRATIONS_MAP, since a migration only runs when listed there. Also verify build.xml version and CHANGELOG.TXT were updated for the release.

How do I recover from a failed OrangeHRM migration?

Query ohrm_migration_log for the row with finished_at IS NULL to identify the failed version. In development, run instance:reset and instance:reinstall; in production, restore from a database backup rather than fixing forward on the live database.

Can OrangeHRM migrations be rolled back?

No, OrangeHRM migrations are forward-only with no down() method and no rollback mechanism. Reverting a release requires restoring a database backup taken before the upgrade.