Developer documentation for the lightweight, PHP-FPM-oriented Bhitti framework.
Migrations are plain PHP files returning up and down closures. The migration system supports MySQL, PostgreSQL, and SQLite.
php run migrate:create users
Create an alteration migration:
php run migrate:alter users
Both commands accept --path=... for a custom migration directory.
<?php
use Bhitti\Database\Migration\Schema;
use Bhitti\Database\Migration\Blueprint as Table;
return [
'up' => static function (): void {
Schema::create('users', static function (Table $table): void {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamps();
});
},
'down' => static function (): void {
Schema::dropIfExists('users');
},
];
php run migrate
Specify a named SQL connection:
php run migrate --connection=pgsql
Rollback the last batch:
php run migrate:rollback
Rollback a number of most recent migrations:
php run migrate:rollback --step=2
Bhitti no longer stores migration file checksums. Editing an already-run migration does not require --allow-modified; rollback executes the current down closure. In a deployed application, prefer a new migration for subsequent schema changes.
php run migrate:status
Statuses are pending, ran, or missing.
The migration repository stores:
migration
batch
executed_at
When application debug mode is off, migrate and migrate:rollback require explicit confirmation with:
php run migrate --force
php run migrate:rollback --force
Bhitti uses migration locking to prevent concurrent migration runners. PostgreSQL and SQLite migration steps are wrapped transactionally where supported; MySQL DDL is not treated as transaction-safe by the migrator.