I've been using knex and bookshelf, and they've been great! I come from a rails background and found knex missing seed files, so I've developed the functionality. Included in this pull request are:
Create seed files with
Run seed files with
Seed files are intended to destroy existing data if necessary and then seed with correct data. Example seed file:
Example knexfile config:
Tests are included as well and cover things similar to what the migration tests cover.
There is a repo you can clone that shows the seed file functionality:
Comments, thoughts, and questions are welcome!
@nsantorello This is awesome. Had a quick question about how you use this, if you have a second. Do you use it for seeding data in production? For example, when using a migration to add a new table in production, do you use a seed file to insert seed data for that? I've been using migrations for that, as only the migrations which need to run, run - it seems like the seed functionality will always run every seed file.
@briandela It can be as simple as this depending on your use case:
If you have seed data in a table mixed with non-seed data, you can emulate upsert functionality:
Let me know if that answers your question.