This looks like a symptom of a different failure.
Without seeing the actual migration file I can only guess that it creates a table and then does something else (foreign keys to a users table perhaps?). So if any actions that are taken after the table is created fail, the whole migration is considered to not be applied, while leaving the newly created table in the database.
You'll have to manually delete the sessions
table and rerun the migration to see what the root cause is.
To avoid such errors in the future you might want to either break up your migrations into single step actions or wrap the complex up
and down
methods with DB::transaction
.
nCrazed said:
This looks like a symptom of a different failure.
Without seeing the actual migration file I can only guess that it creates a table and then does something else (foreign keys to a users table perhaps?). So if any actions that are taken after the table is created fail, the whole migration is considered to not be applied, while leaving the newly created table in the database.
You'll have to manually delete the
sessions
table and rerun the migration to see what the root cause is.To avoid such errors in the future you might want to either break up your migrations into single step actions or wrap the complex
up
anddown
methods withDB::transaction
.
Hi. Thanks for your quick response. I managed to fix the problem by deleting the sessions table in phpmyadmin. I have run into a new problem along the way.
I am currently trying to do this lynda course: (I don't know if you have a lynda account) http://www.lynda.com/Laravel-tutorials/Incorporating-data/181242/366506-4.html
The problem is that the users table is not being displayed in phpmyadmin.
Here is the create_users migration file.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsers extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function($newtable)
{
$newtable->increments('id');
$newtable->string('email')->unique;
$newtable->string('username', 100)->unique();
$newtable->string('password', 100);
$newtable->rememberToken();
$newtable->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
And here is the create_session_table migration file.
<?php
use Illuminate\Database\Migrations\Migration;
class CreateSessionTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sessions', function($t)
{
$t->string('id')->unique();
$t->text('payload');
$t->integer('last_activity');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('sessions');
}
The session and migration table is displaying in phpmyadmin but not the users table I made in the create_users migration.
Any ideas on the problem?
Thanks
I am also getting this error when running the command in the terminal.
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Cannot redeclare class CreateSessionTable","file":"\/Users\/Jarrod\/Documents\/authapp\/app\/database\/migrations\/2015_01_25_114421_create_session_table.php","line":32}}
!!!
Please check if there is any "create_user" migration registry in the "migrations" table. If there is one, delete it and rerun the migration
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community