Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Francesco's avatar

Excluding some files/tables from Migrate:Refresh

Hi,

Let say i Have 5 tables, and for each of them i have a migration file. 3 of them will never be modified and they contains a lot of data (5GB). There's a way, while using migrate:refresh, to exclude these 3 tablese from the refresh ? I would avoid to call the migrate:refresh for all the tables.

0 likes
4 replies
SaeedPrez's avatar

One way is to migrate the 3 tables that don't change and then do another migration with the 2 tables that you are working on. Instead of migrate:refresh you can then use migrate:rollback and migrate to redo the last migration (with the 2 tables).

Francesco's avatar

HUmmm i think I have to study better how migrate work behind the scene. If i make migrate:rollback then ALL is rolled back. Or may be you are saying that rollback rollback the last migration and so i have to make 2 separate migration ?

I think I found my error.

I made the first migration just to setup this tables that dont change (they are "geonames" tables by the way). Then i made a modification to the laravel user migration files in order to add some new fields, some of them with foreign keys pointing to the geonames tables. Here I run a migrate:Refresh...but I think I had to run a migrate in order to update only the user table, right ?

Francesco's avatar

Yep, my error approaching the migration concept is to view the migration files like a kind of "table property declarations". So I would expect to find in a file all the information related to the current composition of the table. Actually migration is a different thing. Is a way to log (and of course execute), in a "PHP-speaking" way, all modification made to tables definition.

This means that during development, for sure a lot of delta-migration files will be generated, maybe related to single tables.

I'm just trying now to figure out how, when development is done, I can cleanup the migration folder and having some migrations files that atually map 1 to 1 the tables structure. I guess step would be:

  1. Drop the migration table
  2. Create from scrath new migration files (excpet the ones related to the table that I never wanted to change).
  3. php artisan migration

Sorry for writing (and asking) newbie stuff, just thinking aloud (hoping that someone will stop me saying "hey, you are doing/thinkin it wrong :P )

Please or to participate in this conversation.