Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jeroenverfallie opened this issue Jan 27, 2015 · 2 comments
Closed

Comments

@jeroenverfallie
Copy link

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
Copy link
Owner

Zizaco commented Jan 31, 2015

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants