Open halvardssm opened 3 years ago
I've just been prefixing the seed files with a number (like 10_my_seed_file.ts
), which seems to work fine.
@halvardssm why not take the laravel approach, and the user create/define a base seeder class that runs the other seeders? for example from a php project:
<?php
// database/seeders/DatabaseSeeder.php
namespace Database\Seeds;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
// Run in this order
$this->call(A::class);
$this->call(B::class);
$this->call(C::class);
$this->call(D::class);
}
}
I am inclined to the approach from @ebebbington but the question is then the implementation. I would say that the default behaviour should be the seed name in ascending order, and then an optional property in the config object (or a CLI flag) can give a path to a seed runner file. The only thing on my end which I am not too sure about is whether this should be a class or a function, but seeing as Nessie is fully class-based, we might as well continue on this path. I won't have time to implement this in the forseable future, so anyone are free to pick this up and send a PR :)
Is your feature request related to a problem? Please describe.
The seed files are currently run without any set order (if any it is alphabetical). We should add a property to the migration files which tells Nessie in which order the files should be run and if there are any dependencies/priorities.
As far as my imagination goes, we could do it the following ways, but feel free to chime in if you have another idea (not ordered, but numbered for easy reference):
Update: I will leave this open until I get some feedback or I figure out a solid way of doing this. It will not be included in the v2 release, but might be a part of a v2 minor release further down the line