【发布时间】:2019-02-24 19:43:45
【问题描述】:
我创建了一个 laravel 应用程序,一切都在我的本地主机上正常运行。我正在使用 XAMPP 和 PHPMyAdmin 在本地测试应用程序,当我将其上传到 Heroku 并配置数据库并运行“heroku run php artisan migrate”时,到目前为止没有错误。
我的应用程序是一个简单的表单,用户在其中注册信息并将其存储在数据库中。数据库由一些表组成。这是用户表的迁移
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('lastname');
$table->string('username')->uniqe();
$table->string('ssn');
$table->string('lastfour');
$table->unique(array('ssn','lastfour'));
$table->string('email')->unique();
$table->string('role')->default('Applicant');
$table ->foreign('role')
->references('name')
->on('role');
$table->date('applicationDate');
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->boolean('application_result')->nullable();
$table->rememberToken();
$table->timestamps();
});
}
以及权限配置文件迁移
public function up()
{
Schema::create('competence_profile', function (Blueprint $table) {
$table->increments('competence_profile_id');
$table->unsignedInteger('person_id');
$table ->foreign('person_id')
->references('id')
->on('users');
$table->String('competence');
$table ->foreign('competence')
->references('name')
->on('competence');
$table->integer('years_of_experience');
$table->timestamps();
});
}
但是,当我仅在 Heroku 上将表单提交到数据库时出现错误。如前所述,它在本地运行良好,我可以看到存储在 phpmyadmin 中的数据。这是 Heroku 显示的错误异常。
SQLSTATE[42703]:未定义列:7 错误:列“id”不存在 第 1 行:...t", "created_at") 值 ($1, $2, $3, $4, $5) 返回 "id" ^ (SQL: 插入 "competence_profile" ("person_id", “能力”、“年经验”、“更新时间”、“创造时间”) 值(4、设计师、6、2019-02-22 11:36:29、2019-02-22 11:36:29) 返回“id”)。
对于此错误的任何解释或帮助,我将不胜感激。即使在迁移中定义了该列,它也基本上找不到该列。
【问题讨论】:
-
你有没有发现heroku上的数据库结构和你的localhost很像?
-
SQLSTATE[42703]表示该列未定义。有用的是它带有纯文本描述:)