微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SQLSTATE[42804] 尝试 Heroku 运行 php artisan migrate 时出错

如何解决SQLSTATE[42804] 尝试 Heroku 运行 php artisan migrate 时出错

我一直在尝试从 AWS Cloud9 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);
    }
    
}

这是相关模型。

template <typename C>
static yes& f(typename std::enable_if<
    std::is_same<decltype(static_cast<typename C::const_iterator(C::*)() const>(&C::begin)),typename C::const_iterator(C::*)() const>::value>::type*);

filariasis_medications 表的当前描述: MysqL> 描述 filariasis_medications; enter image description here

解决方法

您在迁移中的括号前放置了一个空格,然后将其删除。将 $table->smallInteger ('administered'); 更改为 $table->smallInteger('administered');

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?