B
B
BarneyGumble2018-07-27 20:27:33
Database migration
BarneyGumble, 2018-07-27 20:27:33

How to use migrations in Laravel?

The Laravel documentation says that migrations are a type of version control for the database, but I didn’t really understand how it all works and how to use it correctly.
As far as I understand, migrations help developers maintain a single DB STRUCTURE
For example, one programmer writes a product catalog, the second authorizes . One created fields in the products table, the second created fields in the users table. They did all this through migrations, wrote their own code, pushed it, and went to rest. In the morning, each of them updated the repository, pulled each other's changes, applied migrations, and now both have the same database structure . Everything is more or less clear here.
But what about data?
One programmer yesterday, among other things, created new products in the database, the second new users. They updated the database structures, but each has its own data. One sits with filled goods and empty users, the other vice versa. Some unfinished version control is obtained.
Or does it all happen in some other way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2018-07-27
@Maksclub

https://github.com/fzaninotto/Faker -- you can generate different data:
Factories in Laravel
An example of generating users through a factory and a faker Populating
10 users through the factory above

Y
Yan-s, 2018-07-27
@Yan-s

Such situations are best avoided altogether. The problem can be solved in different ways, in some cases nothing prevents you from taking out the migration and changing the data itself if there really is such a need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question