2013-09-21 5 views
2

Laravel을 배우려고합니다. 빠른 시작 설명서를 따르고 있지만 마이그레이션에 문제가 있습니다. 나는이 단계에있어 : ​​Laravel 마이그레이션 - 테이블이 생성되지 않음

데이터베이스에서
c:\wamp\www\laravel>php artisan migrate 
Migration table created successfully. 
Migrated: 2013_09_21_040037_create_users_table 

, 내가 한 기록으로 만든 migrations 표를 참조하십시오 : 나는 명령 php artisan migrate을 실행하면 http://laravel.com/docs/quick#creating-a-migration

는 명령 줄에서 다음이 표시됩니다. 그러나 users 테이블이 표시되지 않습니다. 따라서 튜토리얼의 ORM 부분으로 넘어갈 수 없습니다.

내가 잘못 생각한 아이디어가 있습니까? users 테이블이 생성되지 않는 이유는 무엇입니까?

EDIT 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'); 
    } 

} 

답변

7

업데이트 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'); 
    } 

} 

그런 다음 실행이 같은 사용자 마이그레이션 파일 내용을 변경

php artisan migrate:rollback 

을 시도하고 다시 이동한다.

는 "사용자"테이블이 처음부터 만들어지지 않을 경우 삭제 될 수 없기 때문에 여기 http://laravel.com/api/class-Illuminate.Database.Schema.Blueprint.html

+1

내가 롤백 수없는 API 설명서를 참조하십시오. 대신 데이터베이스를 수동으로 재설정했습니다. 코드가 작동했습니다. 왜 그랬을까요? 튜토리얼을 단계별로 따라했습니다. – StackOverflowNewbie

+0

처음으로 테이블 생성 또는 위아래로 코드를 작성하는 코드를 작성하지 않았다고 생각합니다. 지금 작동합니까? – devo

+1

원본 코드를 작성하지 않았습니다. 튜토리얼의 단계를 따랐습니다. 내 질문을 업데이트하고 원본 마이그레이션 파일을 게시했습니다. 왜 그게 효과가 없었어? 왜 코드가 작동합니까? – StackOverflowNewbie

관련 문제