Database

Schema Preview

This page shows how a typed PHP schema blueprint is translated into SQL by the active database grammar. No statement is executed against the database.

Mode
alter
Table
_tmp_schema_demo_article
Status
Preview ready
Preview only. No SQL was executed.

PHP blueprint

Input
schema.php
$schema->table('_tmp_schema_demo_article', static function (TableBlueprint $table): void {
    $table->string('meta_title', 255)
        ->nullable()
        ->after('title')
        ->comment('Optional SEO meta title.');

    $table->string('meta_description', 500)
        ->nullable()
        ->after('meta_title')
        ->comment('Optional SEO meta description.');

    $table->index('meta_title');
});

Generated SQL

Output
statement-1.sql
ALTER TABLE `_tmp_schema_demo_article` ADD `meta_title` VARCHAR(255) NULL COMMENT 'Optional SEO meta title.' AFTER `title`
statement-2.sql
ALTER TABLE `_tmp_schema_demo_article` ADD `meta_description` VARCHAR(500) NULL COMMENT 'Optional SEO meta description.' AFTER `meta_title`
statement-3.sql
ALTER TABLE `_tmp_schema_demo_article` ADD KEY `index_meta_title` (`meta_title`)