Sta*_*bie 2 mysql laravel laravel-4
我正在努力学习Laravel.我正在关注Quickstart文档但遇到了迁移问题.我正迈出这一步:http://laravel.com/docs/quick#creating-a-migration
当我运行该命令时php artisan migrate,命令行显示以下内容:
c:\wamp\www\laravel>php artisan migrate
Migration table created successfully.
Migrated: 2013_09_21_040037_create_users_table
Run Code Online (Sandbox Code Playgroud)
在数据库中,我看到一个migrations用1条记录创建的表.但是,我没有看到一张users桌子.所以,我不能继续本教程的ORM部分.
我有什么想法可能做错了吗?为什么不users创建表格?
编辑1(原始迁移文件):
<?php
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function($table)
{
$table->increments('id');
$table->string('email')->unique();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
Run Code Online (Sandbox Code Playgroud)
更新的Laravel应该Blueprint用于创建数据库模式.因此,尝试更改这样的用户迁移文件内容,
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table) {
$table->integer('id', true);
$table->string('name');
$table->string('username')->unique();
$table->string('email')->unique();
$table->string('password');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
Run Code Online (Sandbox Code Playgroud)
然后跑,
php artisan migrate:rollback
Run Code Online (Sandbox Code Playgroud)
然后再次迁移.
阅读API此处的文档http://laravel.com/api/class-Illuminate.Database.Schema.Blueprint.html
| 归档时间: |
|
| 查看次数: |
11012 次 |
| 最近记录: |