When running php artisan migrate
I get the an error when it is trying to create the migrations table in mysql:
In Connection.php line 664:
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`id` int u
nsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default cha
racter set utf8 collate 'utf8_unicode_ci')
In Connection.php line 452:
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
Here is the full error log:
In Connection.php line 664:
[Illuminate\Database\QueryException (42000)]
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`id` int u
nsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default cha
racter set utf8 collate 'utf8_unicode_ci')
Exception trace:
() at /home/vagrant/api/vendor/illuminate/database/Connection.php:664
Illuminate\Database\Connection->runQueryCallback() at /home/vagrant/api/vendor/illuminate/database/Connection.php:624
Illuminate\Database\Connection->run() at /home/vagrant/api/vendor/illuminate/database/Connection.php:459
Illuminate\Database\Connection->statement() at /home/vagrant/api/vendor/illuminate/database/Schema/Blueprint.php:97
Illuminate\Database\Schema\Blueprint->build() at /home/vagrant/api/vendor/illuminate/database/Schema/Builder.php:278
Illuminate\Database\Schema\Builder->build() at /home/vagrant/api/vendor/illuminate/database/Schema/Builder.php:167
Illuminate\Database\Schema\Builder->create() at /home/vagrant/api/vendor/illuminate/database/Migrations/DatabaseMigrationRepository.php:157
Illuminate\Database\Migrations\DatabaseMigrationRepository->createRepository() at /home/vagrant/api/vendor/illuminate/database/Console/Migrations/InstallCommand.php:54
Illuminate\Database\Console\Migrations\InstallCommand->handle() at n/a:n/a
call_user_func_array() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:32
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:90
Illuminate\Container\BoundMethod::callBoundMethod() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:34
Illuminate\Container\BoundMethod::call() at /home/vagrant/api/vendor/illuminate/container/Container.php:576
Illuminate\Container\Container->call() at /home/vagrant/api/vendor/illuminate/console/Command.php:183
Illuminate\Console\Command->execute() at /home/vagrant/api/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /home/vagrant/api/vendor/illuminate/console/Command.php:170
Illuminate\Console\Command->run() at /home/vagrant/api/vendor/illuminate/console/Command.php:198
Illuminate\Console\Command->call() at /home/vagrant/api/vendor/illuminate/database/Console/Migrations/MigrateCommand.php:93
Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase() at /home/vagrant/api/vendor/illuminate/database/Console/Migrations/MigrateCommand.php:63
Illuminate\Database\Console\Migrations\MigrateCommand->handle() at n/a:n/a
call_user_func_array() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:32
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:90
Illuminate\Container\BoundMethod::callBoundMethod() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:34
Illuminate\Container\BoundMethod::call() at /home/vagrant/api/vendor/illuminate/container/Container.php:576
Illuminate\Container\Container->call() at /home/vagrant/api/vendor/illuminate/console/Command.php:183
Illuminate\Console\Command->execute() at /home/vagrant/api/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /home/vagrant/api/vendor/illuminate/console/Command.php:170
Illuminate\Console\Command->run() at /home/vagrant/api/vendor/symfony/console/Application.php:921
Symfony\Component\Console\Application->doRunCommand() at /home/vagrant/api/vendor/symfony/console/Application.php:273
Symfony\Component\Console\Application->doRun() at /home/vagrant/api/vendor/symfony/console/Application.php:149
Symfony\Component\Console\Application->run() at /home/vagrant/api/vendor/illuminate/console/Application.php:90
Illuminate\Console\Application->run() at /home/vagrant/api/vendor/laravel/lumen-framework/src/Console/Kernel.php:115
Laravel\Lumen\Console\Kernel->handle() at /home/vagrant/api/artisan:35
In Connection.php line 452:
[PDOException (42000)]
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
Exception trace:
() at /home/vagrant/api/vendor/illuminate/database/Connection.php:452
PDO->prepare() at /home/vagrant/api/vendor/illuminate/database/Connection.php:452
Illuminate\Database\Connection->Illuminate\Database\{closure}() at /home/vagrant/api/vendor/illuminate/database/Connection.php:657
Illuminate\Database\Connection->runQueryCallback() at /home/vagrant/api/vendor/illuminate/database/Connection.php:624
Illuminate\Database\Connection->run() at /home/vagrant/api/vendor/illuminate/database/Connection.php:459
Illuminate\Database\Connection->statement() at /home/vagrant/api/vendor/illuminate/database/Schema/Blueprint.php:97
Illuminate\Database\Schema\Blueprint->build() at /home/vagrant/api/vendor/illuminate/database/Schema/Builder.php:278
Illuminate\Database\Schema\Builder->build() at /home/vagrant/api/vendor/illuminate/database/Schema/Builder.php:167
Illuminate\Database\Schema\Builder->create() at /home/vagrant/api/vendor/illuminate/database/Migrations/DatabaseMigrationRepository.php:157
Illuminate\Database\Migrations\DatabaseMigrationRepository->createRepository() at /home/vagrant/api/vendor/illuminate/database/Console/Migrations/InstallCommand.php:54
Illuminate\Database\Console\Migrations\InstallCommand->handle() at n/a:n/a
call_user_func_array() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:32
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:90
Illuminate\Container\BoundMethod::callBoundMethod() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:34
Illuminate\Container\BoundMethod::call() at /home/vagrant/api/vendor/illuminate/container/Container.php:576
Illuminate\Container\Container->call() at /home/vagrant/api/vendor/illuminate/console/Command.php:183
Illuminate\Console\Command->execute() at /home/vagrant/api/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /home/vagrant/api/vendor/illuminate/console/Command.php:170
Illuminate\Console\Command->run() at /home/vagrant/api/vendor/illuminate/console/Command.php:198
Illuminate\Console\Command->call() at /home/vagrant/api/vendor/illuminate/database/Console/Migrations/MigrateCommand.php:93
Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase() at /home/vagrant/api/vendor/illuminate/database/Console/Migrations/MigrateCommand.php:63
Illuminate\Database\Console\Migrations\MigrateCommand->handle() at n/a:n/a
call_user_func_array() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:32
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:90
Illuminate\Container\BoundMethod::callBoundMethod() at /home/vagrant/api/vendor/illuminate/container/BoundMethod.php:34
Illuminate\Container\BoundMethod::call() at /home/vagrant/api/vendor/illuminate/container/Container.php:576
Illuminate\Container\Container->call() at /home/vagrant/api/vendor/illuminate/console/Command.php:183
Illuminate\Console\Command->execute() at /home/vagrant/api/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /home/vagrant/api/vendor/illuminate/console/Command.php:170
Illuminate\Console\Command->run() at /home/vagrant/api/vendor/symfony/console/Application.php:921
Symfony\Component\Console\Application->doRunCommand() at /home/vagrant/api/vendor/symfony/console/Application.php:273
Symfony\Component\Console\Application->doRun() at /home/vagrant/api/vendor/symfony/console/Application.php:149
Symfony\Component\Console\Application->run() at /home/vagrant/api/vendor/illuminate/console/Application.php:90
Illuminate\Console\Application->run() at /home/vagrant/api/vendor/laravel/lumen-framework/src/Console/Kernel.php:115
Laravel\Lumen\Console\Kernel->handle() at /home/vagrant/api/artisan:35
I have tried destroying and rebuilding the vagrant instance, plus removed and reinstalled composer packages, but the problem persists.
As requested, migration files:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTeachersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('teachers', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('address');
$table->string('phone');
$table->string('profession');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('teachers');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateStudentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('students', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('address');
$table->string('phone');
$table->string('career');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('students');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCoursesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('courses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->text('description');
$table->integer('value')->unsigned();
$table->bigInteger('teacher_id')->unsigned();
$table->foreign('teacher_id')->references('id')->on('teachers');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('courses');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCourseStudentTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('course_student', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('course_id')->unsigned();
$table->foreign('course_id')->references('id')->on('courses');
$table->bigInteger('student_id')->unsigned();
$table->foreign('student_id')->references('id')->on('students');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('course_student');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('role_id');
$table->string('email')->unique();
$table->string('first_name');
$table->string('last_name');
$table->string('password');
$table->tinyInteger('status')->default(1);
$table->tinyInteger('master')->default(0);
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSystemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('systems', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->tinyInteger('status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('systems');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_roles', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->bigInteger('system_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_roles');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserRolePermissionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_role_permissions', function (Blueprint $table) {
$table->bigInteger('user_role_id');
$table->bigInteger('permission_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_role_permissions');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserRolePermissionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_role_permissions', function (Blueprint $table) {
$table->bigInteger('user_role_id');
$table->bigInteger('permission_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_role_permissions');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLeadTypesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lead_types', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('branch_id');
$table->string('name');
$table->string('token')->nullable();
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('lead_types');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLeadStatusesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lead_statuses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('branch_id');
$table->string('name');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('lead_statuses');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLeadsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('leads', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('lead_type_id');
$table->bigInteger('status_id');
$table->bigInteger('owner_id');
$table->string('description');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('leads');
}
}
On a side note the most recent package I added to the system was for mongodb jenssegers/mongodb but disabling this has made no difference.
config/database.php
<?php
return [
'default' => 'mysql',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST'),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
],
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGODB_HOST'),
'port' => env('MONGODB_PORT'),
'database' => env('MONGODB_DATABASE'),
'username' => env('MONGODB_USERNAME'),
'password' => env('MONGODB_PASSWORD'),
'options' => [
'database' => 'admin'
]
],
]
];
Requested .env file:
APP_NAME=APP
APP_ENV=local
APP_KEY=ka0mdHChmnMoQzSqWle7Zez
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
JWT_SECRET=VJXaIerVvIMXAF7w0Tt6FsMU8
migration
files – Lisalisabetconfig/database.php
? – Ottiecreate table ``
here the name of the table is blank – Attorneyatlawphp artisan migrate:install
orphp artisan migrate:install --database=mysql
to specify the database connection to use.. – Edna