我正在尝试迁移我的laravel项目。
但是当我输入migrate命令时,我收到了这个错误。我不明白为什么当我尝试迁移我的项目时它给我这个错误。
[ErrorException]
Undefined index: index_type
Exception trace:
() at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php:75
Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php:75
Doctrine\DBAL\Schema\MySqlSchemaManager->_getPortableTableIndexesList() at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:193
Doctrine\DBAL\Schema\AbstractSchemaManager->listTableIndexes() at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:286
Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php:320
Illuminate\Database\Schema\Grammars\Grammar->getChangedDiff() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php:302
Illuminate\Database\Schema\Grammars\Grammar->compileChange() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:107
Illuminate\Database\Schema\Blueprint->toSql() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:82
Illuminate\Database\Schema\Blueprint->build() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:229
Illuminate\Database\Schema\Builder->build() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:130
Illuminate\Database\Schema\Builder->table() at /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
Illuminate\Support\Facades\Facade::__callStatic() at /var/www/database/migrations/2016_10_25_222438_update_relationships_for_employee.php:20
Illuminate\Support\Facades\Schema::table() at /var/www/database/migrations/2016_10_25_222438_update_relationships_for_employee.php:20
UpdateRelationshipsForEmployee->up() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:373
Illuminate\Database\Migrations\Migrator->Illuminate\Database\Migrations\{closure}() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:380
Illuminate\Database\Migrations\Migrator->runMigration() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:162
Illuminate\Database\Migrations\Migrator->runUp() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:130
Illuminate\Database\Migrations\Migrator->runMigrationList() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:97
Illuminate\Database\Migrations\Migrator->run() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:66
Illuminate\Database\Console\Migrations\MigrateCommand->fire() at n/a:n/a
call_user_func_array() at /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:508
Illuminate\Container\Container->call() at /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:169
Illuminate\Console\Command->execute() at /var/www/vendor/symfony/console/Command/Command.php:256
Symfony\Component\Console\Command\Command->run() at /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:155
Illuminate\Console\Command->run() at /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:185
Illuminate\Console\Command->call() at /var/www/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php:66
Illuminate\Database\Console\Migrations\RefreshCommand->fire() at n/a:n/a
call_user_func_array() at /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:508
Illuminate\Container\Container->call() at /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:169
Illuminate\Console\Command->execute() at /var/www/vendor/symfony/console/Command/Command.php:256
Symfony\Component\Console\Command\Command->run() at /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:155
Illuminate\Console\Command->run() at /var/www/vendor/symfony/console/Application.php:820
Symfony\Component\Console\Application->doRunCommand() at /var/www/vendor/symfony/console/Application.php:187
Symfony\Component\Console\Application->doRun() at /var/www/vendor/symfony/console/Application.php:118
Symfony\Component\Console\Application->run() at /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:121
Illuminate\Foundation\Console\Kernel->handle() at /var/www/artisan:36
我的迁移文件位于下方。
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UpdateRelationshipsForEmployee extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::table('employee',function ($table){
$table->integer('retail_id')->unsigned()->index()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('employee', function ($table){
$table->integer('retail_id')->change();
});
//
}
}
答案 0 :(得分:0)
只需删除总数据库并运行命令即可 php artisan migrate:refresh --seed
您也可以维护您的数据库。 只需复制您的模型和迁移信息。 然后删除。 删除重新创建模型和表格后。
现在。转到数据库迁移表。删除员工行。 现在。删除您的员工表。
现在只是终端命令php artisan migrate
答案 1 :(得分:0)
检查您的操作系统语言环境或php语言环境,
无法在laravel使用的依赖库中正确转换大写字母,因为您的语言环境不同于en_us.UTF8
尝试
setlocale(LC_CTYPE,'en_US.UTF8');
使用en_us.UTF8进行大小写转换,而不考虑活动的语言环境。