1 安装好最基本的laravel框架
2 创建migration文件:
./artisan migrate:make create-badmin-table
3 发现app/database/migration/下面多了一个php文件:
2014_10_19_090336_create-badmin-table.php
4 往up和down里面增加内容;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBadminTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('badmin', function($table)
{
$table->increments('id');
$table->string('nickname', 100)->unique();
$table->string('username', 100)->unique();
$table->string('email', 100)->unique();
$table->string('password', 64);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('badmin');
}
}
5 配置好local的database,app/config/local/database.php
return array(
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => ’test',
'username' => 'yejianfeng',
'password' => '123456',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
'migrations' => 'migrations',
);