How to add index to an existing column in Laravel

If you want to add a new index to some columns in your existing table, you can do it pretty easily with Laravel migration. First, create the migration: Then edit the migration php file. In this example, we are adding two indexes to a table, parent_id and slug:

How to check the migration before running it in Laravel

Hello, friends. In Laravel you can check the queries which your migration will run before actually running it. This is called a “dry run”. You will have to use –pretend flag for that. See the example below: First, we create a migration: Now, let’s go and edit the migration, for example: Now we can “pretend” […]

How to delete a column from table in Laravel

To remove a column from a database table in Laravel, you need to create a migration, edit, and then run it in the command line interface. Create the migration You need to open your Laravel application folder in Terminal. Then run one of the following commands. Remember that you can skip typing underscore symbols, see […]