Skip to content

Migrations & Seeders

Store repeatable schema changes inside site/migrations/ and demo or reference data seeders inside site/seeders/ so every environment stays synchronized through Git.

Command Arguments & Options Purpose
make:migration <name>, --type, --field, --fieldtype, --template, --role, --label, --parent, --module, --json Scaffolds a timestamped migration class in site/migrations/ (or a module’s migrations/ folder with --module).
migrate:install --json Creates the migrations tracking table if it does not exist yet.
migrate --step, --dry-run, --force, --json Executes all pending migrations in chronological order (Totoglu\Console\Migration\Migrator).
migrate:status --json Lists all discovered migrations with applied batch numbers or pending status.
migrate:rollback --step, --dry-run, --force, --json Rolls back the last batch (or --step=N migrations) by calling each migration’s down() method.
migrate:reset --dry-run, --force, --json Rolls back all applied migrations in reverse order.
migrate:refresh --dry-run, --force, --json Resets all applied migrations and re-runs them cleanly (rollback + migrate).
migrate:fresh --dry-run, --force, --json Drops the migrations table and re-runs every migration from scratch.
site/migrations/2026_06_15_000001_AddYachtSummaryField.php
<?php
declare(strict_types=1);
namespace ProcessWire;
return new class {
public function up(): void
{
$fields = wire()->fields;
if (!$fields->get('yacht_summary')) {
$field = new Field();
$field->type = wire()->modules->get('FieldtypeTextarea');
$field->name = 'yacht_summary';
$field->label = 'Yacht Summary';
$fields->save($field);
}
}
public function down(): void
{
$fields = wire()->fields;
$field = $fields->get('yacht_summary');
if ($field instanceof Field && $field->numFieldgroups() === 0) {
$fields->delete($field);
}
}
};
Command Arguments & Options Purpose
make:seeder <name>, --module, --json Scaffolds a new *Seeder.php class extending Totoglu\Console\Database\Seeder in site/seeders/ (or a module).
db:seed --class, --dry-run, --force, --json Executes DatabaseSeeder (or a targeted --class=FleetSeeder) against the active ProcessWire database.
site/seeders/FleetSeeder.php
<?php
declare(strict_types=1);
namespace ProcessWire;
use Totoglu\Console\Database\Seeder;
final class FleetSeeder extends Seeder
{
public function run(): void
{
$pages = wire()->pages;
$parent = $pages->get('/fleet/');
if (!$parent->id || $pages->has('parent=/fleet/, name=aegean-star')) {
return;
}
$pages->new([
'template' => 'yacht',
'parent' => $parent,
'name' => 'aegean-star',
'title' => 'Aegean Star',
]);
}
}

Next steps