Laravel Migration

Laravel is a framework which allows large migrations to gain control for your database. Migration files are very helpful in keep modifying and changing the database schema and stay refresh with the current going schema status. Migrations are a nice way to programmatically create and define databases. Laravel migrations provide mechanisms for creating and modifying database tables.

BENEFITS OF USING THIS FRAMEWORK

  • Offers simple authentication systems: This providing a flexible way of controlling over all the recourses.
  • Provides high performance: Laravel Migration way to create powerful applications which result in high performance.
  • Removes and fix all Errors
  • Works as the security blanket: Laravel migration provides security to all the applications by providing hashed passwords.

LARAVEL MIGRATION STRUCTURE

There are two methods included in laravel migration class structure.

  • Up 

           The Up method is to add columns, tabs, and indexes to the database. 

  • Down 

           The Down method is for turning back any operation that was performed by up method previously.

HOW DOES IT WORK?

Step1: Migration building

To develop migration, one has to create a command (make: migration create_users_table). In creating the migration, the options like ‘user table’ indicate the name of the table.

Step2: Migration formation

We have two methods  “up” and “down”.  “up” method, one can add new tables and columns to the database. Both the methods are opposite to each other.

Step3: Migration execution

It’s time for the execution of the migration by using the command “migrate”.

Step4: Table development

To create the database tables by using the ‘create’ command. Arguments will be used in this command that we have to mention the ‘table name’ and second is the ‘function'.

Schema::create(‘users’, function (Bprint $table) {
$table->increments(‘id’);
});

Step5: Columns Production

This step complete modification will be done by modifying, renaming and dropping the column attributes.

Schema::table(‘users’, function (Bprint $table) {
$table->string(’email’);
});

Step6: Index generating

In generating the index, the simple “unique” method will be used.

$table->string(’email’)->unique();