drfraker / snipe-migrations

Blazing fast database migrations for Laravel tests.
MIT License
290 stars 32 forks source link

Allow Snipe to seed the database after migrating it #24

Closed jackwh closed 5 years ago

jackwh commented 5 years ago

I often need to seed the database with some basic values before running my tests, and I'm sure this is the case for others too.

I've added a configuration option to allow Snipe to automatically seed the database after refreshing it. If seeding takes place, it will store the seeded data to the snapshot. This can save a lot of time over re-seeding the database at the beginning of every test — in my own testing, I managed to halve the time a test suite took when using this technique.

By default, seeding is switched off. A configuration setting allows for it to be turned on, and you can specify which seed class to use as well.

I also tidied up a couple of small areas of the code as I was going through it.

Let me know what you think!

dan-rally commented 5 years ago

@JackWH Not sure if you still intending to continue with this PR, if not would you like anyone else to pick up on it? I might be able to if needed. My team would also really like this functionality so keen to get it merged in if possible. Many thanks.

drfraker commented 5 years ago

@dan-rally I don't mind merging this feature, but I would prefer that it automatically update the snapshot if config('snipe.seed-database') is true and there has been a change to a seed file. The whole point of the package is to make the snapshot automated. From what I can tell, this PR will not automatically cause a new snapshot to be created if a seeder has been modified. If you want to add that, I can merge this feature.