Databáza

Náhľad schémy

Táto stránka ukazuje, ako sa typovaný PHP schema blueprint prevádza do SQL podľa aktívnej databázovej gramatiky. Nad databázou sa nespúšťa žiadny príkaz.

Režim
create
Tabuľka
_tmp_schema_demo_article
Stav
Náhľad je pripravený
Preview only. No SQL was executed.

PHP blueprint

Vstup
schema.php
$schema->create('_tmp_schema_demo_article', static function (TableBlueprint $table): void {
    $table->engine('InnoDB');
    $table->charset('utf8mb4');
    $table->collation('utf8mb4_unicode_ci');
    $table->comment('Demo article table generated by Schema preview.');

    $table->id('article_id')
        ->comment('Primary article identifier.');

    $table->string('title', 255)
        ->comment('Public article title.');

    $table->string('slug', 255)
        ->unique()
        ->comment('SEO friendly unique article URL slug.');

    $table->integer('article_status')
        ->default(1)
        ->comment('Article status flag. 1 = published, 0 = hidden.');

    $table->datetime('created_at')
        ->nullable()
        ->comment('Creation timestamp.');

    $table->datetime('updated_at')
        ->nullable()
        ->comment('Last update timestamp.');

    $table->index('article_status');
}, ifNotExists: true);

Vygenerované SQL

Výstup
statement-1.sql
CREATE TABLE IF NOT EXISTS `_tmp_schema_demo_article` (
	`article_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Primary article identifier.',
	`title` VARCHAR(255) NOT NULL COMMENT 'Public article title.',
	`slug` VARCHAR(255) NOT NULL COMMENT 'SEO friendly unique article URL slug.',
	`article_status` INT NOT NULL DEFAULT 1 COMMENT 'Article status flag. 1 = published, 0 = hidden.',
	`created_at` DATETIME NULL COMMENT 'Creation timestamp.',
	`updated_at` DATETIME NULL COMMENT 'Last update timestamp.',
	PRIMARY KEY (`article_id`),
	UNIQUE KEY `unique_slug` (`slug`),
	KEY `index_article_status` (`article_status`)
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Demo article table generated by Schema preview.'