-
-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
MySQL/MariaDB, SQLite and PostgreSQL have first-class support for the version table. Any other PDO driver falls back to the MySQL grammar. The statements you write inside migrations can target whatever your driver supports. See Database Drivers.
No. Migration files are discovered by globbing Migration_*.php in the
configured folder and are required directly. If they declare a namespace, set
the namespace option so Barbarian can resolve the
fully-qualified class name.
Set the namespace option (or the namespace key in barbarian.json) to match
the namespace your migration classes declare. The version name remains the
unqualified class name; the namespace is only used to load the class.
The migration file was discovered but has no row in the version table yet — it
has never been applied. After up it becomes up; after down it becomes
down. See CLI Commands.
up skips migrations already recorded as Up. To re-run one anyway, target it
explicitly — up --version=... forces a re-run — or call
upMigration($m, true) from code.
A migration must return true for the runner to record the state change.
Returning false (or throwing) leaves the recorded status untouched so the
migration can be retried. See
Writing Migrations.
Yes — set migrationTable (in code) or table_name (in barbarian.json). The
name must match ^[A-Za-z_][A-Za-z0-9_]*$.
No. create only reads the configuration to know where (and under which
namespace) to write the file. You can scaffold migrations with the database
offline.
No. Migrations are not wrapped in a transaction, and several engines (notably
MySQL) commit implicitly on DDL. Keep migrations small and make each down() a
faithful inverse of its up().
up (without --version) applies migrations in ascending file-name order.
down (without --version) reverts them in reverse order, so dependencies
are torn down after the things that depend on them.
The CLI is built on InitPHP Console, where
--long tokens are arguments. Use the double-dash form:
--version=..., --config=..., --dir=....
Build a Migrations and call
upMigration()/downMigration(). See Programmatic Usage.
Open an issue at github.com/InitPHP/Barbarian/issues or start a thread in Discussions.
initphp/barbarian · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
Guide
Reference
Practical Guides
Help