Translate

Wednesday, October 9, 2024

Laravel : Change Table Name

Here's a guide on how to rename a table using the migration feature in Laravel version 10


The following is an example of a command-line interface (CLI) command to rename a column within a table :


php artisan make:migration rename_column_in_users_table --table=users


The command above will generate a file containing source code that will rename a column in a table.

Once we have successfully created a file named "2024_10_09_001126_rename_column_in_products_table.php", we will then edit the source code within this PHP file. This will allow us to execute the command to rename the desired column.

To perform table renames, you'll need to add the doctrine/dbal dependency. Copy the composer.phar file into your project directory. From your command line interface (CLI), navigate to your project directory and execute the following command:

composer require doctrine/dbal


After installing the dependency above, the PHP script for renaming the column will work properly.

No comments:

Post a Comment

Github : Perintah Untuk Update Repository Github

Ini adalah perintah di untuk update repository di Github : git status git add . git commit -m "update isi repository" ...