-
Notifications
You must be signed in to change notification settings - Fork 116
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
Data seeding shell #19
Comments
Couldn't you make the data seeding a migration? |
Yes.. I know about this feature. But i have found this process too repetitive.
acceptable for 99% data seeding processes. |
How could it be made less repetitive? |
@lorenzo for example when my migration contain more than 5 tables. |
I understand that it can be repetitive, but I'm just asking what would be a good way for you to lessen the repetitive stuff |
I can write shell and sample plugin to demonstrate what i mean. And after this you with your teammates will take decision accept this idea as pull request or not. ok? |
Croogo already has something like this: https://github.com/croogo/croogo/blob/master/Extensions/Lib/Utility/DataMigration.php Bulk load datafiles from a directory: https://github.com/croogo/croogo/blob/master/Install/Model/Install.php#L69-L82 |
@rchavik So why shouldn't to make this logic as default for migrtaions plugin? |
@TamiasSibiricus Sure, it's up to the migrations plugin maintainer. I'm just pointing those files out should you want to reuse the code as a base for the PR. |
@TamiasSibiricus sure, I'd like to see your idea |
Why not? I'd like to see a PR, too. |
Closing as there is a PR open. |
Ok. So my vision for seeding shell:
|
Honestly I think this should be a plugin on it's own that could extend or make use of migrations. Either migrations gets events fired on before / after / up / down or extend the migrations plugin in another plugin to get this done. |
@burzum I think about seeding as separate plugin. But here is ine problem. Callbacks runs only after whole migration process. So there is impossile relate seeding process to selected migration. Phing currently does not return any info about applied migrations. Also if we realize seeding process as callback it would run every migration and try overwrite existing data after each migration process(i think). Currently there is no mechanism to prevent run seeding twice or more. |
@TamiasSibiricus Like I said before, this is easy to resolve with events: new Event('Migration.beforeMigration', $this, ['direction' => 'up']);
new Event('Migration.beforeMigration', $this, ['direction' => 'down']);
new Event('Migration.afterMigration', $this, ['direction' => 'up']);
new Event('Migration.afterMigration', $this, ['direction' => 'down']); Listen to the event(s) and put your logic in the event listener that deals with it. Identify the migration by class name and you get the direction from the event data and act accordingly. I think it should be possible to know what was done (or is going to be done) as well and to pass it to the event. @lorenzo can I add them? 😄 |
@burzum someone did that already |
@burzum Events for migration actions migrate and rollback already exists but without subject and options arguments. Just take a look at code for this actions. I think in current version options does not needed. |
Everyone's situation is going to be different obviously, but my team and I ended up writing a Cake plugin to do data seeding. It still isn't tied to specific migrations, but there's no reason it couldn't be (just have your migration's Anyway, here's another alternative in case it's useful to anyone that finds this thread: |
Would love to see this implemented, would be a whole lot easier! |
@beporter I'd love to somehow have the following feature implemented for the CakePHP ORM: data-seeding from a production database. Maybe something you guys at Loadsys can investigate ;) |
You can still use the built in Phinx data seeding classes in your change() or up() methods. It would be nice though if we could bake separate Seeding files.
|
What would be the initial seed data? Just empty? |
I've been using the TableRegistry in the up() method with a migration file prefixed like 'SeedRoles'. Honestly the only complaint I have with this method is that it marks the migration as migrated. If I could toggle that behavior I'd be set. |
With the support of seeders added to phinx and the migrations plugin enhancements following this, I think this can be closed. |
Just another idea.
How about to implement data seeding shell for this plugin.
Data can be stored in /config/Data in app or plugin folder.
I think all data must be in actual state for last migration.
Data seeding process cna't start if migration is not complete.
What do you think?
The text was updated successfully, but these errors were encountered: