Snipe-it: Error while running artisan migrate

Created on 28 Mar 2015  路  13Comments  路  Source: snipe/snipe-it

I have changed the production settings according to my database configuration !
I am getting this error when i run php artisan migrate

#0 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(190): Symfony\Component\Console\Application->find('upgrade')
#1 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 C:\wamp_new\www\snipe\artisan(59): Symfony\Component\Console\Application->run()
#3 {main} [] []
[2015-03-28 18:05:26] production.ERROR: exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'snipeit_laravel.users' doesn't exist' in C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php:369
Stack trace:
#0 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php(369): PDOStatement->execute(Array)
#1 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php(617): Illuminate\Database\Connection->Illuminate\Database\{closure}(Object(Illuminate\Database\MySqlConnection), 'alter table `us...', Array)
#2 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php(581): Illuminate\Database\Connection->runQueryCallback('alter table `us...', Array, Object(Closure))
#3 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php(370): Illuminate\Database\Connection->run('alter table `us...', Array, Object(Closure))
#4 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Schema\Blueprint.php(63): Illuminate\Database\Connection->statement('alter table `us...')
#5 C:\wamp_new\www\snipe\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 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Schema\Builder.php(94): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint))
#7 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(211): Illuminate\Database\Schema\Builder->table('users', Object(Closure))
#8 C:\wamp_new\www\snipe\app\database\migrations\2013_03_23_193214_update_users_table.php(20): Illuminate\Support\Facades\Facade::__callStatic('table', Array)
#9 C:\wamp_new\www\snipe\app\database\migrations\2013_03_23_193214_update_users_table.php(20): Illuminate\Support\Facades\Schema::table('users', Object(Closure))
#10 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php(135): UpdateUsersTable->up()
#11 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php(111): Illuminate\Database\Migrations\Migrator->runUp('2013_03_23_1932...', 1, false)
#12 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php(82): Illuminate\Database\Migrations\Migrator->runMigrationList(Array, false)
#13 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php(70): Illuminate\Database\Migrations\Migrator->run('C:\\wamp_new\\www...', false)
#14 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Console\Command.php(112): Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#15 C:\wamp_new\www\snipe\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 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Console\Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 C:\wamp_new\www\snipe\artisan(59): Symfony\Component\Console\Application->run()
#21 {main}

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'snipeit_laravel.users' doesn't exist (SQL: alter table `users` add `deleted_at` timestamp null, add `website` varchar(255) null, add `country` varchar(255) null, add `gravatar` varchar(255) null)' in C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php:625
Stack trace:
#0 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php(581): Illuminate\Database\Connection->runQueryCallback('alter table `us...', Array, Object(Closure))
#1 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Connection.php(370): Illuminate\Database\Connection->run('alter table `us...', Array, Object(Closure))
#2 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Schema\Blueprint.php(63): Illuminate\Database\Connection->statement('alter table `us...')
#3 C:\wamp_new\www\snipe\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 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Schema\Builder.php(94): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint))
#5 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(211): Illuminate\Database\Schema\Builder->table('users', Object(Closure))
#6 C:\wamp_new\www\snipe\app\database\migrations\2013_03_23_193214_update_users_table.php(20): Illuminate\Support\Facades\Facade::__callStatic('table', Array)
#7 C:\wamp_new\www\snipe\app\database\migrations\2013_03_23_193214_update_users_table.php(20): Illuminate\Support\Facades\Schema::table('users', Object(Closure))
#8 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php(135): UpdateUsersTable->up()
#9 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php(111): Illuminate\Database\Migrations\Migrator->runUp('2013_03_23_1932...', 1, false)
#10 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php(82): Illuminate\Database\Migrations\Migrator->runMigrationList(Array, false)
#11 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php(70): Illuminate\Database\Migrations\Migrator->run('C:\\wamp_new\\www...', false)
#12 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Console\Command.php(112): Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#13 C:\wamp_new\www\snipe\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))
#14 C:\wamp_new\www\snipe\vendor\laravel\framework\src\Illuminate\Console\Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 C:\wamp_new\www\snipe\vendor\symfony\console\Symfony\Component\Console\Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 C:\wamp_new\www\snipe\artisan(59): Symfony\Component\Console\Application->run()
#19 {main} [] []
waiting on OP not a bug

Most helpful comment

Are you using Laravel 5 in your application. I had the same issue, turns out i was making some database calls in my custom service provider class. I only had to comment out the lines, and re-run php artisan migrate again. It worked

All 13 comments

it sounds like you changed your database configuration to one where the tables were never installed because the artisan install wasn't run on it. You have to run artisan install before you run migrations, as the install is what creates the tables on whatever database you've specified.

I did not change anything ! after I ran dump-autoload command, I ran php artisan migrate:install ! I created a database snipeit_laravel and changed the user credentials according to my configuraion.

I ran php artisan migrate:install It created migration table successfully and after that when I run php artisan migrate, its throwing the same error again.

no need for the screaming .. we are all trying to help here.. did you try running php composer.phar update ?

Yes, as @Nubianprince said, we're trying to help you. Calm down.

The important error out of that stack trace is 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'snipeit_laravel.users' doesn't exist'.

This means that for any variety of reasons, your installer can find a valid database, but no tables have been created in the one it's connecting to, or they're named something else so the installer cannot recognize them.

You said you didn't change anything, and yet the very first sentence in your original ticket is: "I have changed the production settings according to my database configuration !", so clearly, you have changed something.

  • Are you using a table prefix in app/config/production/database.php?
  • Is there in fact a file at app/config/production/database.php?
  • Does that file in app/config/production/database.php contain the correct login information for your database?
  • When you look at your database, what tables do you see?

It sounds to me like you you installed the app, changed the database configs to your production database (which has not had the installer run on it), and are now trying to migrate tables that don't exist yet. Run php artisan app:install on your current database.

I sincerely apologize guys if my reply seemed rude or arrogant! I did not mean it that way! Thank you for your polite replies and yes I'll try these immediately when I get home! Thank you and I apologize once again

No worries, @mageshkumaar - I think it was probably all the exclamation marks that made it seem like you were yelling.

jake-hug

Any luck on this?

Are you using Laravel 5 in your application. I had the same issue, turns out i was making some database calls in my custom service provider class. I only had to comment out the lines, and re-run php artisan migrate again. It worked

@razamehdi-vteams Snipe-IT is Laravel 4.2.

Closing this ticket for inactivity. We can reopen it if OP replies.

@razamehdi-vteams , you save my day.
Problem solve after added some checking in my custom service provider.

if ( Schema::hasTable('tablename') ) {
codehere
}

Helped me too

guys i have the same issue

Was this page helpful?
0 / 5 - 0 ratings