Base de données
Aperçu du schéma
Cette page montre comment un PHP schema blueprint typé est converti en SQL selon la grammaire de base de données active. Aucune commande n’est exécutée sur la base de données.
Mode
create
Table
_tmp_schema_demo_article
État
Aperçu prêtPreview only. No SQL was executed.
PHP blueprint
Entrée$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 généré
SortieCREATE 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.'