Skip to content

Columns

Column types

$t->id();
$t->string('name');
$t->char('code', 2);
$t->text('body');
$t->longText('content');
$t->int('age');
$t->bigInt('views');
$t->tinyInt('position');
$t->float('rating');
$t->double('score');
$t->decimal('price', 10, 2);
$t->boolean('active');
$t->date('birth_date');
$t->time('starts_at');
$t->datetime('published_at');
$t->timestamp('created_at');
$t->json('meta');
$t->uuid('uuid');
$t->enum('status', ['draft', 'published']);

Modifiers

$t->string('name')->nullable();
$t->int('age')->default(0);
$t->string('email')->unique('users_email_unique');
$t->string('slug')->index('posts_slug_index');
$t->timestamp('created_at')->defaultCurrentTimestamp();
$t->timestamp('updated_at')->defaultCurrentTimestamp()->onUpdateCurrentTimestamp();
$t->string('name')->comment('Display name');

Renaming columns

Column renaming is explicit:

$t->string('full_name', 500)
    ->renamed('name');

This tells Schemage that name should become full_name.

For MySQL/MariaDB, this may generate SQL using CHANGE COLUMN for compatibility.