Seeding your database
How to add seed data to your database(s)
Seed script
Simply add a bash script to your repository that contains the script for seeding your database.
This could be a custom script, a custom rake command, or the default Rails rake db:seed command
depending on your requirements/implementation.
In our example, we will use the default Rails rake db:seed command.
Create the file /.cloud66/dbseed.sh
as below:
Deploy hook
Add a deploy hook to execute the above script during the first deploy (on the first server only).
Create the file .cloud66/deploy_hooks.yml
as below (replacing production with your target environment).
Note
The deploy hook example above will only execute during the build for a new application. If you want to seed an existing application you could either
- Execute the seed command manually, or
- Change the apply_during specification of the deploy hook (could be used for DB data resets during subsequent testing deploys for instance)