xxxxxxxxxx
Schema::rename($currentTableName, $newTableName);
xxxxxxxxxx
php artisan make:migration rename_table-name_column
up(){
Schema::table('table-name', function(Blueprint $table){
$table->renameColumn('old-name', 'new-name');
});
}
down(){
Schema::table('table-name', function(Blueprint $table) {
$table->renameColumn('new-name', 'old-name');
});
}
xxxxxxxxxx
# first must run this command
composer require doctrine/dbal
# then try
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('from', 'to');
});
#then migrate it
php artisan migrate
xxxxxxxxxx
# command line terminal
composer require doctrine/dbal
php artisan make:migration update_oldFileName_table
# write this in your migration file. Change from and to by your column info
public function up()
{
Schema::table('delivery_credit', function (Blueprint $table) {
$table->renameColumn('from','to');
});
}
}
public function down()
{
Schema::table('delivery_credit', function (Blueprint $table) {
$table->renameColumn('to','from');
});
}
# in your terminal
php artisan migrate
xxxxxxxxxx
php artisan make:migration rename_author_id_in_posts_table --table=posts
Composer Package to Install to use rename column
xxxxxxxxxx
composer require doctrine/dbal
xxxxxxxxxx
public function up()
{
Schema::table('posts', function (Blueprint $table) {
$table->renameColumn('author_ID', 'user_id');
});
}
xxxxxxxxxx
php artisan make:migration alter_your_table --table=your_table