Skip to content

Tables

Tables are defined with $schema->table().

$schema->table('posts', function (Table $t): void {
    $t->id();
    $t->string('title');
    $t->text('body');
    $t->timestamps();
});

Schema::table() returns a DefinedTable, which can receive table-level metadata after the callback:

$schema->table('feedback', function (Table $t): void {
    $t->id();
    $t->text('body');
})->renamed('comments');

The Table builder inside the callback remains responsible for columns, indexes, checks, and foreign keys. DefinedTable describes metadata about the completed table declaration.

Common shortcuts

$t->id();
$t->timestamps();
$t->createdAt();
$t->updatedAt();
$t->softDeletes();
$t->rememberToken();

Dropping tables

If a database table no longer appears in the desired schema, Schemage plans a DropTable operation.

Dropping a table can permanently delete data. In interactive mode, Schemage requires reinforced confirmation. In non-interactive mode, use:

vendor/bin/schemage --yes --force