4

I have been working with Laravel for about a couple of months now - loving it. Have a question about the workflow that is recommended for managing changes to the database.

I have a test database that I used to develop my app, and when I was reasonably happy, I created a production database by copying the structure in phpMyAdmin. I had built the initial database on phpMyAdmin, as I was not familiar with the Laravel Migrations.

Now I am at a point where I better understand the power of Laravel Migrations, and would like to use them going forward to update the test database and move those changes to the production.

What is the course of action for me? Can I delete everything in the app/database/migrations dir and start from scratch? Will there be issues down the line calling php artisan migrate in my test and production environment?

Thanks in advance for the responses!

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Venky Rao
  • 106
  • 1
  • 7

1 Answers1

1

Short answer: no problems. If you just add/alter/remove tables/columns in the up() and down() methods.

Longer answer: still no problem. As long as you don't drop a table that is not created in an up() method.

But let's say you get to work with another developer, that person also wants to develop on a local DB. But you don't have the migration for it - so the new dev needs to run the initial structure from test DB, and then apply the new migrations.

In that case I would start with 1 big migration where you create all the initial tables, and in the down() the drops of those tables, so the new dev can just run the migrate and start coding.

edit: and after that migration for the initial structure, just add new ones while developing ;)

Rob Gordijn
  • 6,381
  • 1
  • 22
  • 29