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

Add initial support for generating seed files #179

Merged
merged 2 commits into from
Jan 5, 2016

Conversation

josegonzalez
Copy link
Member

This is part one of the necessary work to add support for phinx seeds. Our next step is to add support to the migrations runners to actually apply seeds to a database.

Opening PR to continue discussion based on running code :)

Refs #19.

@HavokInspiration
Copy link
Member

Looks like a good start to me.

While baking a seed file, maybe it would a nice feature to ask if the current table data are to be exported as records ? Or with an option ?

@bravo-kernel
Copy link

Exporting table data to re-usable records/arrays would be a godsent by itself 👍

*
* @var string
*/
public $pathFragment = 'Seed/';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. DS? Screw PHP.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do that in a class attribute. Also, all other bake tasks use slashes, and php now correctly handles them afaik.

@ionas
Copy link

ionas commented Jan 4, 2016

I like it. It did always trouble me how to pre-populate some basic data like say admin account or genders table.

@josegonzalez
Copy link
Member Author

Semi-related, https://gist.github.com/josegonzalez/3863f341ede1b6273ba3

@bravo-kernel take a look, might be... interesting :)

@bravo-kernel
Copy link

Thanks for the pointer @josegonzalez. Exporting data so it can be re-entered cake-style (e.g. column order dependent) is what I think would complete my migrations workflow:

  1. Export table data before migration
  2. Alter tables using migrations
  3. Insert data from step 1 again

@lorenzo
Copy link
Member

lorenzo commented Jan 5, 2016

I think this is a good start, since you are an awesome writer @josegonzalez, do you mind adding a few lines in the book about using this feature?

lorenzo added a commit that referenced this pull request Jan 5, 2016
Add initial support for generating seed files
@lorenzo lorenzo merged commit c5960e3 into cakephp:master Jan 5, 2016
@josegonzalez
Copy link
Member Author

It's not done yet, in that there isn't a way to actually use the seed files. That still needs to be done. @HavokInspiration I think you are more familiar with futzing with phinx commands, mind taking care of that? I might have time this weekend otherwise.

@lorenzo
Copy link
Member

lorenzo commented Jan 5, 2016

Ah, I thought it was in a kind of usable state already :(

@josegonzalez
Copy link
Member Author

You definitely need to read the code/comments in my PRs, otherwise we're going to have issues where I break cake core :P

@lorenzo
Copy link
Member

lorenzo commented Jan 5, 2016

@josegonzalez I forgot that seeds where something different to migrations, so I thought just having the file generated would be enough :D

@HavokInspiration
Copy link
Member

@josegonzalez I'm not sure if I'll get the time before this weekend, but I can start looking into it.

@HavokInspiration
Copy link
Member

I gave this a spin.
I have the shell working and seeding with the same options as migrations (source, plugin, connection and I implemented the seed option to specify the file to seed).

I still have some tuning to do to the Bake task (and maybe some cleanup). And add tests.
I had to make it closer to the migrations baking process. For instance, Seed files can not be under a namespace, so I put them in the config dir.
I'll give more details when I'll open the PR.

@josegonzalez
Copy link
Member Author

Wait, we still can't put phinx files into namespaced directories?

@HavokInspiration
Copy link
Member

Nop.
It's being discussed however : cakephp/phinx#168

@josegonzalez
Copy link
Member Author

Gotcha. Welp thems the breaks.

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

Successfully merging this pull request may close these issues.

5 participants