Support the ongoing development of Laravel.io →
Session Database Forms
Last updated 2 years ago.
0

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.

0

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 and down methods with DB::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

Last updated 9 years ago.
0

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}}
!!!
0

Please check if there is any "create_user" migration registry in the "migrations" table. If there is one, delete it and rerun the migration

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jazza96 jazza96 Joined 18 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.