Base de datos

Vista previa del esquema

Esta página muestra cómo un PHP schema blueprint tipado se convierte en SQL según la gramática de base de datos activa. No se ejecuta ningún comando contra la base de datos.

Modo
create
Tabla
_tmp_schema_demo_article
Estado
Vista previa lista
Preview only. No SQL was executed.

PHP blueprint

Entrada
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);

SQL generado

Salida
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.'