-
Notifications
You must be signed in to change notification settings - Fork 121
Seed command docs #944
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
base: 5.x
Are you sure you want to change the base?
Seed command docs #944
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ Migrations includes a command to easily generate a new seed class: | |
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ bin/cake bake seed MyNewSeed | ||
| bin/cake bake seed MyNewSeed | ||
|
|
||
| By default, it generates a traditional seed class with a named class: | ||
|
|
||
|
|
@@ -75,7 +75,7 @@ To generate an anonymous seed class, use the ``--style anonymous`` option: | |
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ bin/cake bake seed MyNewSeed --style anonymous | ||
| bin/cake bake seed MyNewSeed --style anonymous | ||
|
|
||
| This generates a seed file using an anonymous class: | ||
|
|
||
|
|
@@ -114,10 +114,11 @@ You can set the default seed style globally in your application configuration: | |
| 'style' => 'anonymous', // or 'traditional' | ||
| ], | ||
|
|
||
| Seed Options | ||
| ------------ | ||
| Additional option | ||
| ----------------- | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| # You specify the name of the table the seed files will alter by using the ``--table`` option | ||
| bin/cake bake seed Articles --table my_articles_table | ||
|
|
||
|
|
@@ -155,7 +156,7 @@ include as a comma separated value string: | |
| .. _custom-seed-migration-templates: | ||
|
|
||
| Customizing Seed and Migration templates | ||
| ---------------------------------------- | ||
| ======================================== | ||
|
|
||
| Because migrations uses `bake <https://book.cakephp.org/bake>`__ under the hood | ||
| you can customize the templates that migrations uses for creating seeds and | ||
|
|
@@ -178,7 +179,7 @@ It provides the necessary support to create your seed classes. Seed | |
| classes are primarily used to insert test data. | ||
|
|
||
| The Run Method | ||
| ============== | ||
| -------------- | ||
|
|
||
| The run method is automatically invoked by Migrations when you execute the | ||
| ``cake migration seed`` command. You should use this method to insert your test | ||
|
|
@@ -191,21 +192,21 @@ data. | |
| mind when developing them. | ||
|
|
||
| The Init Method | ||
| =============== | ||
| --------------- | ||
|
|
||
| The ``init()`` method is run by Migrations before the run method if it exists. This | ||
| can be used to initialize properties of the Seed class before using run. | ||
|
|
||
| The Should Execute Method | ||
| ========================= | ||
| ------------------------- | ||
|
|
||
| The ``shouldExecute()`` method is run by Migrations before executing the seed. | ||
| This can be used to prevent the seed from being executed at this time. It always | ||
| returns true by default. You can override it in your custom ``BaseSeed`` | ||
| implementation. | ||
|
|
||
| Foreign Key Dependencies | ||
| ======================== | ||
| ------------------------ | ||
|
|
||
| Often you'll find that seeds need to run in a particular order, so they don't | ||
| violate foreign key constraints. To define this order, you can implement the | ||
|
|
@@ -375,33 +376,37 @@ This is the easy part. To seed your database, simply use the ``migrations seed`` | |
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ bin/cake migrations seed | ||
| bin/cake migrations seed | ||
|
|
||
| By default, Migrations will execute all available seed classes. If you would like to | ||
| run a specific class, simply pass in the name of it using the ``--seed`` parameter. | ||
| You can use either the short name (without the ``Seed`` suffix) or the full name: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ bin/cake migrations seed --seed User | ||
| # or | ||
| $ bin/cake migrations seed --seed UserSeed | ||
| # One of | ||
| bin/cake migrations seed --seed User | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should IMO remove the option part for the major, it become superfluous and will only bloat docs and maybe confuse people in the long run.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, afaik I did that already ( https://github.com/cakephp/migrations/pull/935/files )
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should be breaking compatibility just for fun.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thats not for fun |
||
| bin/cake migrations seed --seed UserSeed | ||
| bin/cake migrations seed User | ||
|
|
||
| Both commands work identically. | ||
|
|
||
| You can also run multiple seeds: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ bin/cake migrations seed --seed User --seed Permission --seed Log | ||
| # or with full names | ||
| $ bin/cake migrations seed --seed UserSeed --seed PermissionSeed --seed LogSeed | ||
| # Multiple --seed options | ||
| bin/cake migrations seed --seed User --seed Permission --seed Log | ||
| # or with full names | ||
| bin/cake migrations seed --seed UserSeed --seed PermissionSeed --seed LogSeed | ||
| # Or an interactive prompt for all | ||
|
|
||
|
|
||
| You can also use the `-v` parameter for more output verbosity: | ||
| You can also use the ``-v`` parameter for more output verbosity: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ bin/cake migrations seed -v | ||
| bin/cake migrations seed -v | ||
|
|
||
| The Migrations seed functionality provides a simple mechanism to easily and repeatably | ||
| insert test data into your database, this is great for development environment | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe