字段类型参考链接: 结构生成器
版本: Laravel 4.2
1. 创建migrate 文件
php artisan migrate:make create_lang_table
2. 编辑migrate文件
<?php use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; class CreateLangTable extends Migration { /**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::create('lang', function(Blueprint $table)
{
$table->increments('id');//主键自增
$table->string('local',50); //语言
$table->string('title',30); //标题
$table->tinyInteger('main')->nullable(); //主要语言
$table->tinyInteger('published')->default(1); //发布
$table->integer('ordering')->default(0); //排序
$table->timestamps();
});
} /**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
} }
3. 创建表
php artisan migrate
就会看到类似的信息:
vagrant@precise32:/var/www/html$ php artisan migrate
**************************************
* Application In Production! *
************************************** Do you really wish to run this command? yes
Migrated: 2015_11_01_114540_create_lang_table