前提・実現したいこと
HerokuのPostgreSQL上でLaravelのウェブアプリを開発しています。
int型で作成したと思っていたカラムを誤ってstring型で作成してしまっていました。
なので、migrationファイルを作成して変更を試みたのですが、どうも勝手に変換はしてくれなそうで、なにかしらの指定をしなきゃいけないようです。
作成したmigrationファイル
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class EditSchoolIdUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('users', function (Blueprint $table) { $table->integer('school_id')->nullable()->change(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('users', function (Blueprint $table) { // }); } }
migrateコマンド実行時のエラー文
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "school_id" cannot be cast automatically to type integer HINT: You might need to specify "USING school_id::integer".
試したこと
int型を使う指定をしろということなのでしょうが、ググってみてもどのように指定すればいいのかわからず、質問させていただきました。
よろしくお願いします!
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/04/24 03:30
2018/04/24 03:36