Reputation: 40633
I'm trying to learn Laravel. I'm following the Quickstart documentation but have gotten into a problem with Migrations. I'm at this step: http://laravel.com/docs/quick#creating-a-migration
When I run the command php artisan migrate
, the command line displays the following:
c:\wamp\www\laravel>php artisan migrate
Migration table created successfully.
Migrated: 2013_09_21_040037_create_users_table
In the database, I see a migrations
table created with 1 record. However, I do not see a users
table. So, I can't continue on to the ORM portion of the tutorial.
Any ideas what I might be doing wrong? Why isn't the users
table getting created?
EDIT 1 (original migration file):
<?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');
}
}
Upvotes: 3
Views: 12806
Reputation: 69
I faced the same problem, after searching at Laravel documentation (link to documentation), i found an artisan command that resolve it :
php artisan migrate:refresh
The migrate:refresh command will roll back all of your migrations and then execute the migrate command. This command effectively re-creates your entire database
Upvotes: 0
Reputation: 23463
The updated Laravel should use Blueprint
for database schema creation.
So try to change your user migration file content like this,
<?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');
}
}
Then run,
php artisan migrate:rollback
and then migrate again.
Read the API
documentation here http://laravel.com/api/class-Illuminate.Database.Schema.Blueprint.html
Upvotes: 8