Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priority run seed #718

Closed
visavi opened this issue Dec 15, 2015 · 15 comments
Closed

Priority run seed #718

visavi opened this issue Dec 15, 2015 · 15 comments
Labels

Comments

@visavi
Copy link

visavi commented Dec 15, 2015

For example, I have 2 files, PostsSeeder and UsersSeeder
between them have connections with foreign keys
if you run the seed:run, an error occurs because the first perform PostsSeeder, and it requires a user
how to make so that UsersSeeder run earlier than PostsSeeder?

Option to rename the file do not really like, as tables in a database, and a lot of Seed files too much
You can get lost

@robmorgan
Copy link
Member

hi @visavi at the moment the only way is to run them manually, e.g:

phinx seed:run -e development -s UsersSeeder
phinx seed:run -e development -s PostsSeeder

Other tools accomplish this by having a master seeding class that essentially calls Seeders in the relevant order. We could look into something similar in the future if many users request this.

@visavi
Copy link
Author

visavi commented Dec 15, 2015

#719 priority seeds

@ricco24
Copy link

ricco24 commented Jun 12, 2016

👍 for this feature

@jasonherndon
Copy link

jasonherndon commented Jul 14, 2016

Definitely voting for this feature ... is #719 still an active PR?

@visavi
Copy link
Author

visavi commented Jul 15, 2016

there is now an opportunity to put multiple seeders, http://docs.phinx.org/en/latest/seeding.html#executing-seed-classes but still it is not very convenient, as an option to make a master file in which you can specify a list of files and they will be carried out in an orderly fashion, like in laravel5

@jasonherndon
Copy link

@visavi Something like the L5 way to do it would be nice... or even to improve on L5, the ability to create not just one super class that loads a single list of seeders, but a super class that loads a list of seeders based on arrays (a structure similar to the L5 middleware class)... I guess I was just wondering between #719 #737 and #790 it seems like work has been done, even some without any merge conflicts, though I don't know if testing has succedded...

Does @robmorgan have any thoughts on whether this is an issue that needs someone else to take a stab at it or if the proposed PRs satisfy the initial proposal he outlined.

@pwoszczyk
Copy link

+1 from me

@alejoluc
Copy link

+1 for this

@parfumix
Copy link

parfumix commented Feb 7, 2017

+1

1 similar comment
@githubnando
Copy link

+1

@pedrozan
Copy link

pedrozan commented Feb 7, 2017

That is a really useful feature, when we will be able to see it merged?

@mosiyash
Copy link

+100

@Lewiatan
Copy link

Lewiatan commented May 8, 2017

+1

simpliest way to "solve" this issue is to prefix classes with letters. Let's say you want to seed Post and User table and Post are related to Users so you want Users to be seeded first. Call your seed classes as AUserSeeder and BPostSeeder and you'll get them in correct order.

Maybe instead of some "Master seeder" that would run "child seeders" in correct order, simpy add order method that would return an integer so you could put seeders in correct order?

@norkus256
Copy link

Hey, I created pull request for seeds ordering feature:
#1244

Please review my pull request and comment if you like it.

@dereuromark
Copy link
Member

PR open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests