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

migration db error #30

Closed
jianfengye opened this issue Feb 9, 2015 · 5 comments
Closed

migration db error #30

jianfengye opened this issue Feb 9, 2015 · 5 comments

Comments

@jianfengye
Copy link

[vagrant@localhost lstarter]$ php artisan migrate
Migration table created successfully.
exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1005 Can't create table 'lstarter.#sql-60f_8' (errno: 150)' in /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php:358
Stack trace:
#0 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php(358): PDOStatement->execute(Array)
#1 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php(606): Illuminate\Database\Connection->Illuminate\Database\{closure}(Object(Illuminate\Database\MySqlConnection), 'alter table `as...', Array)
#2 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): Illuminate\Database\Connection->runQueryCallback('alter table `as...', Array, Object(Closure))
#3 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php(359): Illuminate\Database\Connection->run('alter table `as...', Array, Object(Closure))
#4 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php(63): Illuminate\Database\Connection->statement('alter table `as...')
#5 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(169): Illuminate\Database\Schema\Blueprint->build(Object(Illuminate\Database\MySqlConnection), Object(Illuminate\Database\Schema\Grammars\MySqlGrammar))
#6 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(112): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint))
#7 /vagrant/lstarter/storage/framework/compiled.php(5223): Illuminate\Database\Schema\Builder->create('assigned_roles', Object(Closure))
#8 /vagrant/lstarter/database/migrations/2014_10_16_115128_entrust_setup_tables.php(34): Illuminate\Support\Facades\Facade::__callStatic('create', Array)
#9 /vagrant/lstarter/database/migrations/2014_10_16_115128_entrust_setup_tables.php(34): Illuminate\Support\Facades\Schema::create('assigned_roles', Object(Closure))
#10 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(135): EntrustSetupTables->up()
#11 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(111): Illuminate\Database\Migrations\Migrator->runUp('2014_10_16_1151...', 1, false)
#12 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(82): Illuminate\Database\Migrations\Migrator->runMigrationList(Array, false)
#13 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(73): Illuminate\Database\Migrations\Migrator->run('/vagrant/lstart...', false)
#14 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#15 /vagrant/lstarter/storage/framework/compiled.php(922): call_user_func_array(Array, Array)
#16 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Console/Command.php(115): Illuminate\Container\Container->call(Array)
#17 /vagrant/lstarter/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Console/Command.php(101): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /vagrant/lstarter/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /vagrant/lstarter/vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /vagrant/lstarter/vendor/symfony/console/Symfony/Component/Console/Application.php(126): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(91): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /vagrant/lstarter/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 {main}

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[HY000]: General error: 1005 Can't create table 'lstarter.#sql-60f_8' (errno: 150) (SQL: alter table `assigned_roles` add constraint assigned_roles_user_id_foreign foreign key (`user_id`) references `users` (`id`) on delete cascade)' in /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php:614
Stack trace:
#0 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): Illuminate\Database\Connection->runQueryCallback('alter table `as...', Array, Object(Closure))
#1 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Connection.php(359): Illuminate\Database\Connection->run('alter table `as...', Array, Object(Closure))
#2 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php(63): Illuminate\Database\Connection->statement('alter table `as...')
#3 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(169): Illuminate\Database\Schema\Blueprint->build(Object(Illuminate\Database\MySqlConnection), Object(Illuminate\Database\Schema\Grammars\MySqlGrammar))
#4 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(112): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint))
#5 /vagrant/lstarter/storage/framework/compiled.php(5223): Illuminate\Database\Schema\Builder->create('assigned_roles', Object(Closure))
#6 /vagrant/lstarter/database/migrations/2014_10_16_115128_entrust_setup_tables.php(34): Illuminate\Support\Facades\Facade::__callStatic('create', Array)
#7 /vagrant/lstarter/database/migrations/2014_10_16_115128_entrust_setup_tables.php(34): Illuminate\Support\Facades\Schema::create('assigned_roles', Object(Closure))
#8 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(135): EntrustSetupTables->up()
#9 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(111): Illuminate\Database\Migrations\Migrator->runUp('2014_10_16_1151...', 1, false)
#10 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(82): Illuminate\Database\Migrations\Migrator->runMigrationList(Array, false)
#11 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(73): Illuminate\Database\Migrations\Migrator->run('/vagrant/lstart...', false)
#12 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#13 /vagrant/lstarter/storage/framework/compiled.php(922): call_user_func_array(Array, Array)
#14 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Console/Command.php(115): Illuminate\Container\Container->call(Array)
#15 /vagrant/lstarter/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /vagrant/lstarter/vendor/laravel/framework/src/Illuminate/Console/Command.php(101): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /vagrant/lstarter/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /vagrant/lstarter/vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
@stojankukrika
Copy link
Collaborator

I do not test in vagrant. On localhost(XAMPP) works well.

@mclxly
Copy link

mclxly commented Feb 10, 2015

@jianfengye I meet the same problem(foreign key). Hope this help you.

Fix 1:
2014_10_12_000000_create_users_table.php
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->engine = 'InnoDB';

Fix 2:
2014_10_18_195027_create_language_table.php
public function up()
{
Schema::create( 'language', function(Blueprint $table){
$table->engine = 'InnoDB';

@stojankukrika
Copy link
Collaborator

Thank you @mclxly!

@mclxly
Copy link

mclxly commented Feb 10, 2015

@stojankukrika So fast~ Great job~

@stojankukrika
Copy link
Collaborator

TNX for help and support my work @mclxly and others! 👍

@zcosmin20 zcosmin20 mentioned this issue Dec 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants