BadMethodCallException | |后面的方法Illuminate\Database\Schema



BadMethodCallException。。。方法Illuminate\Database\Schema\Blueprint::after不存在。我无法为我的项目迁移数据库。。。这就是我面对的错误

cmd错误,(我无法迁移(:

E:xampphtdocsface_clone1>php artisan migrate
Migrating: 2021_11_19_104856_update_users_table
BadMethodCallException
Method IlluminateDatabaseSchemaBlueprint::after does not exist.
at E:xampphtdocsface_clone1vendorlaravelframeworksrcIlluminateSupportTraitsMacroable.php:103
99|      */
100|     public function __call($method, $parameters)
101|     {
102|         if (! static::hasMacro($method)) {
> 103|             throw new BadMethodCallException(sprintf(
104|                 'Method %s::%s does not exist.', static::class, $method
105|             ));
106|         }
107|
• Bad Method Call: Did you mean IlluminateDatabaseSchemaBlueprint::date() ?
1   E:xampphtdocsface_clone1databasemigrations2021_11_19_104856_update_users_table.php:23
IlluminateDatabaseSchemaBlueprint::__call("after")
2   E:xampphtdocsface_clone1vendorlaravelframeworksrcIlluminateDatabaseSchemaBlueprint.php:88
UpdateUsersTable::{closure}(Object(IlluminateDatabaseSchemaBlueprint))
E:xampphtdocsface_clone1>

我的代码在这里:

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

class UpdateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table){
$table->after('name', function ($table){
$table->renameColumn('name', 'fname');
$table->string('lname');
$table->boolean('sex');
$table->date('b_day')->default('2021-01-01');
$table->string('image');
});
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
} 
}

已解决::谢谢bhucho[https://stackoverflow.com/users/9471283/bhucho]

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

class UpdateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table){
$table->renameColumn('name', 'fname');
$table->string('lname')->after('email');
$table->boolean('sex')->after('email');
$table->date('b_day')->default('2021-01-01')->after('email');
$table->string('image')->after('email');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

最新更新