Previous Video | Migrations Part 3: [ Ссылка ]
In Part 4, we will learn how to update data in table with Migration.
Suppose we want to update the age of our member with name "Rahul Gupta" from 40 to 20 then we can do this with Migration itself. No need to open database or in some cases if we don't have database access then we can do this with few commands by creating and processing migration file only.
So first of all, we will create migration file :-
php artisan make:migration update_members
See now our update_members file is ready. We will write update query in up function to update the age from 40 to 20 of our member "Rahul Gupta". And in down function we will update back the date from 20 to 40 so that when we run rollback command, it get rollback to our earlier state.
Now we will run "php artisan migrate" command to make the updation in table.
See now in members table, age of member Rahul Gupta updated from 40 to 20.
Now we can rollback the changes back to earlier state by running below command:
php artisan migrate:rollback
Now see age comes back to 40 for our member "Rahul Gupta".
In this way we can update any data in our database with Migrations command/files.
Thanks for watching :)
Next Video | Migrations Part 5: [ Ссылка ]
Ещё видео!