🥳
【音声ファイルアップロード機能】laravel migration カラム名変更
composerで"doctrine/dbal"をインストール
$ composer require doctrine/dbal
更新用のmigtarionファイル作成
php artisan make:migration rename_music_files_to_music_file_on_music_files_table --table=music_files
2021_07_02_222036_rename_music_files_to_music_file_on_music_files_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RenameMusicFilesToMusicFileOnMusicFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('music_files', function (Blueprint $table) {
$table->renameColumn('music_files', 'music_file');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('music_files', function (Blueprint $table) {
$table->renameColumn('music_file', 'music_files');
});
}
}
実行
php artisan migrate
終わり
rollbackについて
Discussion