前提
laravel6でユーザが入力した内容にそって筋トレのメニューを作るシステムを作っています。
herokuを使用してデプロイする際に問題が発生しました。
発生している問題・エラーメッセージ
ローカル環境(aws cloud9)では問題なく動くのですがherokuで開くとUndefined table: 7 ERROR: relation "テーブル名" does not existエラーが発生します。
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "muscles" does not exist LINE 1: select * from "muscles" where "sex_id" = $1 ^ (SQL: select * from "muscles" where "sex_id" = 1)
heroku logs --tailで確認したところ
at=error code=H14 desc="No web processes running" method=GET path="/" host=dry-headland-02253.herokuapp.com request_id=db2f8fff-0bf4-46e7-a180-01b8485f2c79 fwd="121.83.72.127" dyno= connect= service= status=503 bytes= protocol=https 2022-12-14T16:21:57.626509+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=dry-headland-02253.herokuapp.com request_id=1f55ac48-803d-4b2b-b0a6-12ffdbf22cda fwd="121.83.72.127" dyno= connect= service= status=503 bytes= protocol=https
の繰り返しでした。
該当のソースコード
主テーブルがnames
従テーブルがmuscles
でリレーションを繋いでいます。
create_muscles_table.php
1<?php 2 3use Illuminate\Database\Migrations\Migration; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Support\Facades\Schema; 6 7class CreateMusclesTable extends Migration 8{ 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('muscles', function (Blueprint $table) { 17 $table->bigIncrements('id'); 18 $table->integer('sex_id'); 19 $table->integer('objective_id'); 20 $table->integer('part_id'); 21 $table->integer('equipment_id'); 22 $table->unsignedBigInteger('name_id'); 23 $table->rememberToken(); 24 $table->timestamps(); 25 $table->foreign('name_id') 26 ->references('id')->on('names') 27 ->onDelete('cascade'); 28 }); 29 } 30 31 /** 32 * Reverse the migrations. 33 * 34 * @return void 35 */ 36 public function down() 37 { 38 Schema::dropIfExists('muscles'); 39 } 40}
create_names_table.php
1<?php 2 3use Illuminate\Database\Migrations\Migration; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Support\Facades\Schema; 6 7class CreateNamesTable extends Migration 8{ 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('names', function (Blueprint $table) { 17 $table->bigIncrements('id'); 18 $table->text('event_name'); 19 $table->text('event_picture'); 20 $table->text('event_precautions'); 21 $table->timestamps(); 22 }); 23 } 24 25 /** 26 * Reverse the migrations. 27 * 28 * @return void 29 */ 30 public function down() 31 { 32 Schema::dropIfExists('names'); 33 } 34} 35
試したこと
teratail、stack overflowで検索してでてきた内容は全て試したつもりです。
・heroku restart --app の実行->問題なく再起動
・外部キーの確認(元からunsignedBigIntegerとbigIncrementsで揃えれてました)
参照https://teratail.com/questions/129527
・heroku run rails c の実行->Running rails console on ⬢ dry-headland-02253... up, run.4989 (Eco)bash: rails: command not found と表示、railsと書いているので関係なさそう..?
参照https://qiita.com/ryonishimura37/items/b72ecc829f9501857528
・heroku rake db:reset 及び heroku rake db:migrate の実行
->rakefileがないと言われたことからrails用のコマンドなので関係なさそう...?
参照https://stackoverflow.com/questions/5450930/heroku-postgres-error-pgerror-error-relation-organizations-does-not-exist
・web: muscleという内容だけですがアプリ下にProcfileも存在します(ちゃんと頭大文字)
参照https://creepfablic.site/2019/06/15/heroku-procfile-matome/
・heroku ps:scale web=1 の実行 ->変化なし
参照https://devcenter.heroku.com/articles/error-codes#h14-no-web-dynos-running
・heroku.ymlの作成->変化無し
参照https://hatolabo.com/programming/heroku-ssh-login
補足情報(FW/ツールのバージョンなど)
herokuが無料から有料になったことに最近気づき、github educationに登録してクレジットを受け取り、Eco DynoとMini Postgresを有効にしています。
初心者のため、情報不足などありましたらご指摘頂けると幸いです。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。