Zizaco / confide

Confide is a authentication solution for Laravel 4
1.19k stars 258 forks source link

Down migration seems to use the migration provided in the package #505

Closed jeroenverfallie closed 9 years ago

jeroenverfallie commented 9 years ago

When setting up confide, I generated the migration as explained in the readme.

However, because I already had a users table, with foreign keys, I modified the migration file to add fields, and drop them in the down() method.

I like to test all my migrations in both ways, and when doing so, I discovered the rollback of this migration tries to drop the users table, instead of dropping the columns I specified.

Using a migrate:rollback --verbose, I noticed the rollback is using the file in vendor/zizaco/confide/migrations/ - How can I prevent this behaviour? Is there a reason for this?

  [Illuminate\Database\QueryException]
  SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table `users`)

Exception trace:
 () at vendor/laravel/framework/src/Illuminate/Database/Connection.php:625
 Illuminate\Database\Connection->runQueryCallback() at vendor/laravel/framework/src/Illuminate/Database/Connection.php:581
 Illuminate\Database\Connection->run() at vendor/laravel/framework/src/Illuminate/Database/Connection.php:370
 Illuminate\Database\Connection->statement() at vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:63
 Illuminate\Database\Schema\Blueprint->build() at vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:169
 Illuminate\Database\Schema\Builder->build() at vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:127
 Illuminate\Database\Schema\Builder->drop() at vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:208

 Illuminate\Support\Facades\Facade::__callStatic() at vendor/zizaco/confide/src/migrations/2013_01_13_172956_confide_setup_users_table.php:42
 Illuminate\Support\Facades\Schema::drop() at vendor/zizaco/confide/src/migrations/2013_01_13_172956_confide_setup_users_table.php:42

 ConfideSetupUsersTable->down() at vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:199
 Illuminate\Database\Migrations\Migrator->runDown() at vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:172
 Illuminate\Database\Migrations\Migrator->rollback() at vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php:59
 Illuminate\Database\Console\Migrations\RollbackCommand->fire() at vendor/laravel/framework/src/Illuminate/Console/Command.php:112
 Illuminate\Console\Command->execute() at vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
 Symfony\Component\Console\Command\Command->run() at vendor/laravel/framework/src/Illuminate/Console/Command.php:100
 Illuminate\Console\Command->run() at vendor/symfony/console/Symfony/Component/Console/Application.php:889
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Symfony/Component/Console/Application.php:193
 Symfony\Component\Console\Application->doRun() at vendor/symfony/console/Symfony/Component/Console/Application.php:124
 Symfony\Component\Console\Application->run() at artisan:59
Zizaco commented 9 years ago

ConfideSetupUsersTable assumes that you are creating a new table. If you are not, then you should change the up behavior and also the behavior of down to alter your table back to its previous state.

jeroenverfallie commented 9 years ago

I don't think you understood correctly.

I changed my up method, and my down method. But the rollback is using the down method of the internal file, and not mine, while the up is.

That's the real issue here.