EricKwan
EricKwan

Reputation: 31

Laravel migration without losing the real data

Is there a possible way to run artisan command to refresh a database without any lost any data?

In my past working, laravel with propel can make the database but doesn't lose any real data with propel:migration:diff.

Anyway with laravel default artisan migrate can it do it the same way?

Upvotes: 3

Views: 3399

Answers (1)

tptcat
tptcat

Reputation: 3961

By definition, refreshing the database (php artisan migrate:refresh) means you are removing all of the data.

The idea is that you're rolling back and re-running all of your migrations which would likely mean that your schema has changed a bit if not significantly and therefore the current data in your database might not match the new schema (and if it did then why would you be refreshing).

A better approach is to add to your migrations to alter columns and tables as you move through your development. In fact, this is one of the main advantages of having this type of "version control" for your DB.

Upvotes: 4

Related Questions