创建migrate 文件
php artisan make:migration create_comments_table
编辑表字段
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCommentTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('comment',function(Blueprint $table){
$table->engine = 'InnoDB';
$table->increments('id'); //int(10)主键
$table->integer('news_id'); //int(11)
$table->biginteger('news_idtwo'); //int(20)
$table->datetime('time'); // -mm-dd h:i:s;
$table->integer('parent_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
创建表
php artisan migrate

本文介绍如何使用Laravel的Artisan命令创建一个名为comments的数据库表迁移,并详细展示了表结构的设计,包括不同字段类型及其用途。
405

被折叠的 条评论
为什么被折叠?



