Baza danych

Podgląd schematu

Ta strona pokazuje, jak typowany PHP schema blueprint jest konwertowany do SQL według aktywnej gramatyki bazy danych. Żadne polecenie nie jest wykonywane na bazie danych.

Tryb
alter
Tabela
_tmp_schema_demo_article
Stan
Podgląd jest gotowy
Preview only. No SQL was executed.

PHP blueprint

Wejście
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');
});

Wygenerowany SQL

Wyjście
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`)