Migrations play a very important role in any MVC Framework. They work as a version control for your database. By using Migrations we can update the database schema and stay up to date on the current schema. By using Migration we can easily manage our schema.
Migrations Creation:
In laravel5 Migrations can be create using the following command.
Command:
`php artisan make:migration createUserTableName`
when you type this command and see the folder app/database/migrations. Here we can see our migration table has been created according to the timestamp. If we want to indicate our table name then by using --table and --create we can indicate the name of the table.
Command:
php artisan make:migration tableName --table=users
php artisan make:migration tableName --create=users
Running Migrations:
Running all migration file we use the command.
Command:
php artisan migrate
Forcing Migrations In Production:
There are are some command which we have to run very carefully because they may cause to lose the data.For block those command we will use this command.
Command:
`php artisan migrate --force`
Rolling Back Migrations:
To roll back the last migration operation we will use the command.
Command:
`php artisan migrate:rollback`
and to roll back whole migration command we will use
php artisan migrate:reset
These all command we use for migration in laravel 5.x
0 Comment(s)