Laravel Migrate: (Re)fresh, Rollback, or Reset?

preview_player
Показать описание
There are quite a lot of commands for the migrations that look similar on the surface. Let me show you how they work, in practice.

Related links:

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

Thanks Povilas for your great tips as always. 👏 👏 👏

One additional tip is that `php migrate --step` gives each migration a unique batch id which you allows you the ability to rollback each migration individually. This is especially handy during development.

Samuel.Mwangi
Автор

Laravel Daily is seriously the best resource. I spend every day browsing the docs for on-demand needs, but Laravel Daily really keeps me learning and growing as a developer. Thank you so much for your amazing channel.

ellmatic
Автор

Before migrating, first time I use '--pretend' flag to see what actually will change. It`s like double check for me to see, what have I written in laravel and what will actually be done in database.

TzK
Автор

The only explanation I found that actually explains it!! Thank you!

luckss
Автор

i like the explanation. personally, I use php artisan migrate:refresh --path=migration_file.php
and I totally agree with the down methods, there are lots of data lost if not careful.

dkazinz
Автор

I usually have a down() method while I'm developing, so I can do easy rollbacks, but then I'll comment out the down() method before deploying to production.

yezperdk
Автор

Been using Laravel 5+ years. Never used down migrations.

phoenixedge
Автор

I use rollback all the time on my local environment, for example even writing migration and testing it. And it's not a good idea to fresh all tables every time because I have some data already and I'm authorised for example...
But I never use rollback on production of course.

gotoslovakia
Автор

I did mess up! One-month data was lost because of that.

SalomDunyoIT
Автор

Hi have a problem,
I refresh the migration but now i can't login again because auth::attempt return always false.

rezahakimi
Автор

isn't down method is good for example:
you ship a new feature with new DB columns that are "not null", But when deploying you found out the code had an issue that impactfull on users so you decide to revert the changes from git and deploy again, but now the column still exists and its throws new error becouse previouse code doesn't handle it ...

I think the down method is good only for immediate rollback after deploying for large-scale applications, in case something is not right so you have controll on the state of you application.
other than that, yeah, no need for it.

azzhraanee
Автор

Hi Povilas, doesn't migrate:rollback --step, limit the roll back migration files you suggest instead of rolling back batches?

miguelviegas
Автор

What if you already have data on a table and you have to do some updates like adding a column or two, is it possible to do that with migrate command or you can only do it manually ?

ailtondevesse
Автор

How to get data back? I accidentally run "php artisan migrate:fresh"

CodingBirdsOnline
Автор

with greetings! I have a question, Sometime when developer run migrate:refresh (or accidentally delete database by giving this command), data gone, Can we add some kind of double check using artisan command (like: are you sure to run this command, this will remove all data! Y/N?) before executing this command???

RehmanKhan-zvrl
Автор

excuse me sir, what happen if some project laravel is not use model, i mean the flow is from controller get data and then throw to view? thank you before, i hope you'll answer my question

dutanugraha
Автор

Hi I accidentally "php migrate --refresh" my database and unfortunately all tables dropped when I wanted to connect again I'm facing some issues. Actually the website is in Linux Server where the front end is vue, backend is laravel & the database in mysql. I have an issue in login page where it produces error "the server responded with a status of 500 (Internal Server Error):8080/api/login". The

laravel.log produced this error

[2023-01-12 15:24:19] local.ERROR: Argument 2 passed to must be of the type int, null given, called in on line 55 {"exception":"[object] 0): Argument 2 passed to must be of the type int, null given, called in on line 55 at Is there anywhere to solve this?

thaneshvaranravendran
join shbcf.ru