Migrations
Antares ships its own migration system built on raw PDO, with no ORM required. It works independently of the Eloquent bridge or any other ORM you choose to use.
Connection
Section titled “Connection”Migrations connect with these variables from .env (or the real environment, which wins):
| Variable | Default | Notes |
|---|---|---|
DB_DRIVER | mysql | mysql, pgsql, sqlite, sqlsrv or oci (Oracle) |
DB_HOST | 127.0.0.1 | Not used for SQLite |
DB_PORT | the driver’s default | 3306, 5432, 1433 or 1521 |
DB_DATABASE | (empty) | Database name; the file path for SQLite; the service name for Oracle |
DB_USERNAME | (empty) | |
DB_PASSWORD | (empty) | |
DB_CHARSET | utf8mb4 | MySQL only |
DB_DSN | (none) | A complete PDO connection string, used instead of all of the above except username and password |
The connection string is built for each driver:
DB_DRIVER | Connection string |
|---|---|
mysql | mysql:host=…;port=…;dbname=…;charset=… |
pgsql | pgsql:host=…;port=…;dbname=… |
sqlite | sqlite:{DB_DATABASE} |
sqlsrv | sqlsrv:Server={host},{port};Database=… |
oci | oci:dbname=//{host}:{port}/{service name} |
PHP needs the matching PDO extension (pdo_mysql, pdo_pgsql, pdo_sqlite, pdo_sqlsrv or pdo_oci). Use DB_DSN for anything else, such as an Oracle TNS name:
DB_DRIVER=ociDB_DSN="oci:dbname=PROD_TNS;charset=AL32UTF8"The migrations table needs Oracle 12c or newer (it uses an identity column).
Creating a Migration
Section titled “Creating a Migration”php vendor/bin/antares make:migration create_users_tableThis creates a file in database/migrations/ with a timestamp prefix, e.g. 2026_01_15_103000_create_users_table.php. It contains a plain class (no namespace, no base class) whose name is the file name without the timestamp, in PascalCase:
<?php
declare(strict_types=1);
final class CreateUsersTable{ public function up(\PDO $pdo): void { $pdo->exec(" CREATE TABLE users ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) "); }
public function down(\PDO $pdo): void { $pdo->exec("DROP TABLE IF EXISTS users"); }}Keep the class name and file name in sync: the runner derives the class name from the file name. Class names must be unique across all migrations.
Running Migrations
Section titled “Running Migrations”Run all pending migrations:
php vendor/bin/antares migrateMigrations are tracked in a migrations table by file name. Already-run migrations are skipped, and everything run together is recorded as one batch.
Rolling Back
Section titled “Rolling Back”Roll back the last batch of migrations:
php vendor/bin/antares migrate:rollbackMigrations in the last batch are rolled back in reverse order, calling each migration’s down() method.
How It Works
Section titled “How It Works”- Migration files live in
database/migrations/(relative to where you run the command, normally the project root) - Files are sorted by name, so the timestamp prefix sets the order
- The
migrationstable is created automatically on first run - Each migration receives a raw
PDOinstance, set to throw exceptions on errors - Migrations are not wrapped in a transaction: if one fails halfway, the ones before it stay applied and recorded
ORM Independence
Section titled “ORM Independence”Migrations use raw PDO directly, so they work regardless of which ORM you use. Pair them with the Eloquent bridge, use a different ORM, or skip an ORM entirely.