PlannrCrm / laravel-fast-refresh-database

🚀 Refresh your test databases faster than you've ever seen before
MIT License
415 stars 18 forks source link

Not really an issue just an possible speed upgrade #3

Closed Tray2 closed 1 year ago

Tray2 commented 1 year ago

In many of my test files I run a before each function where I seed a static table. The content of this table would never change from inside the application.

beforeEach(function () {
  $this->seed(MediaTypeSeeder::class);
});

So my thought is that if it somehow would be possible to add some kind of FastTableSeeder trait. that takes an array of seeder classes and keeps track of the checksum, and only runs them if needed, just like the migration:fresh.

In my case we are talking about 4 records, but for around 300 tests it becomes 1200 inserts, which takes time.

And maybe you want to be able force a run for each test file in the suite.

krzysztofrewak commented 1 year ago

I was thinking about the same issue. Maybe the better approach would be to run all migrations with seeders once and then created a dump of entire "base" database. With this approach migrate:fresh would not be ran anymore as we would need to recreate a dump file.

Tray2 commented 1 year ago

That is an option, but I feel that you shouldn't run any seeders that you don't need.

sinnbeck commented 1 year ago

If you set the seeder on your TestCase class it will automatically be seeded with the migrations (once). Just be aware that changes to this seeder will require that you manually delete or alter the checksum file


public $seeder = SomeSeeder::class
Tray2 commented 1 year ago

I tried that, but it didn't make any difference with seeding of around 3K records in one seeder.

Tray2 commented 1 year ago

I think this one can be closed without further a do