SQLSTATE[42804] 尝试 heroku 运行 php artisan migrate 时出错
SQLSTATE[42804] Error when trying to heroku run php artisan migrate
我一直在尝试从 AWS Cloud9 heroku run php artisan migrate
,但没有成功。我该如何解决这个问题?如果有人能帮助我,我将不胜感激。非常感谢!
我收到三个错误,都是在说
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "administered" cannot be cast automatically to type smallint
HINT: You might need to specify "USING administered::smallint"
问题迁移文件如下:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ChangeFilariasisMedicationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('filariasis_medications', function (Blueprint $table) {
$table->dropColumn('administered');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('filariasis_medications', function (Blueprint $table) {
$table->smallInteger ('administered');
});
}
}
这是相关模型。
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
// 追加
use App\AdministeredDate;
use App\User;
use Illuminate\Notifications\Notifiable;
use App\Notifications\ReminderMail;
class FilariasisMedication extends Model
{
protected $fillable = [
'start_date',
'number_of_times',
'counter',
'administered'
];
protected $dates = [
'start_date',
];
use Notifiable;
/**
* この投薬スケジュールを所有するユーザ(Userモデルとの関係を定義)
*/
public function medication_user()
{
return $this->belongsTo(User::class);
}
/**
* この投薬スケジュールに属する投薬確定日(AdministeredDateモデルとの関係を定義)
*/
public function administered_date()
{
return $this->hasMany(AdministeredDate::class);
}
}
filariasis_medicationstable的当前描述:
mysql> 描述 filariasis_medications;
enter image description here
您在迁移中的括号前放置了 space,请将其删除。
来自 $table->smallInteger ('administered');
到$table->smallInteger('administered');
我一直在尝试从 AWS Cloud9 heroku run php artisan migrate
,但没有成功。我该如何解决这个问题?如果有人能帮助我,我将不胜感激。非常感谢!
我收到三个错误,都是在说
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "administered" cannot be cast automatically to type smallint
HINT: You might need to specify "USING administered::smallint"
问题迁移文件如下:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ChangeFilariasisMedicationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('filariasis_medications', function (Blueprint $table) {
$table->dropColumn('administered');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('filariasis_medications', function (Blueprint $table) {
$table->smallInteger ('administered');
});
}
}
这是相关模型。
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
// 追加
use App\AdministeredDate;
use App\User;
use Illuminate\Notifications\Notifiable;
use App\Notifications\ReminderMail;
class FilariasisMedication extends Model
{
protected $fillable = [
'start_date',
'number_of_times',
'counter',
'administered'
];
protected $dates = [
'start_date',
];
use Notifiable;
/**
* この投薬スケジュールを所有するユーザ(Userモデルとの関係を定義)
*/
public function medication_user()
{
return $this->belongsTo(User::class);
}
/**
* この投薬スケジュールに属する投薬確定日(AdministeredDateモデルとの関係を定義)
*/
public function administered_date()
{
return $this->hasMany(AdministeredDate::class);
}
}
filariasis_medicationstable的当前描述: mysql> 描述 filariasis_medications; enter image description here
您在迁移中的括号前放置了 space,请将其删除。
来自 $table->smallInteger ('administered');
到$table->smallInteger('administered');