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

support a task for db:seed #42

Closed
dei79 opened this issue Dec 23, 2013 · 13 comments
Closed

support a task for db:seed #42

dei79 opened this issue Dec 23, 2013 · 13 comments

Comments

@dei79
Copy link

dei79 commented Dec 23, 2013

Hi,

I would like to see the following task as part of the gem

task :seed do
    on primary fetch(:migration_role) do
      within release_path do
        with rails_env: fetch(:rails_env)  do
          execute :rake, 'db:seed'
        end
      end
    end
  end

It would allow me to seed databases out of the box via capistrano

@kirs
Copy link
Member

kirs commented Dec 23, 2013

That won't be included in capistrano because seeding is done only in development.

@kirs kirs closed this as completed Dec 23, 2013
@Kriechi
Copy link
Contributor

Kriechi commented Dec 23, 2013

I thought about that myself too.
@kirs is right in the way that one does not seed production-servers. But what about staging?
I for myself do have such tasks in my capistrano setup: db:seed, db:reset

But maybe it would be better suited to create a different gem, like a collection of the most common tasks.
(rails/rake stuff, etc.)

@dei79
Copy link
Author

dei79 commented Dec 25, 2013

@Kriechi good idea, I started capistrano-rails-collection: https://github.com/dei79/capistrano-rails-collection

Happy to get more tasks which are useful in a rails environment

@gabu
Copy link

gabu commented Jun 9, 2014

+1

@kirs
Copy link
Member

kirs commented Jun 9, 2014

But what about staging?

You can easily run it manually. It's not everyday task that Capistrano needs to automate.

@mattbrictson
Copy link
Member

I run seeds in all environments. I don't think that is all that uncommon. If you need to pre-populate a production database with a list of valid countries, states, provinces, etc., wouldn't that be done with seeds?

Perhaps the seed task could be added to capistrano/rails and developers could decide if and for which environment(s) to make use of it.

@ghost
Copy link

ghost commented Jul 29, 2014

Another situation is where one sets up new environments for testing, development, new production regions, etc. Instead of db:create, db:schema:load, db:migrate, etc., cap ENV deploy:db:reset would be nice :)

@Kriechi
Copy link
Contributor

Kriechi commented Jul 30, 2014

If the maintainer of the capistrano-gems do not want it in here, we are lucky, because you can easily extend the functionality of the rake-based application. Just use https://github.com/dei79/capistrano-rails-collection.

@kirs
Copy link
Member

kirs commented Jul 31, 2014

You're welcome :)

@jeffshantz
Copy link

@kirs I'd be interested to know how you create initial accounts (e.g. admin accounts) in production if "seeding is done only in development."

@vesan
Copy link

vesan commented Dec 18, 2014

I think seed should be run on all environments. Seed should only add data that is needed for the application to run. Like add locales, countries or something like that to the database.

Data used for testing the application is not seed data and should not go to the seed file.

But the use cases of seed file seem to differentiate between people and Rails documentation doesn't really have an opinion on it so I understand the Capistrano core team's opinion of not adding it. I can easily copy the rake task running code to all my apps.

@tymat
Copy link

tymat commented Nov 14, 2015

"Seeding is only done in deployment" is a presumptuous thing to say. How would you expect to populate a production/staging databases with things like zip codes, products, user roles, country lists, area codes, and all sorts of things that many web applications need?

Generally testing is done through test fixtures not seed data. There is a very big difference between the two.

@alexventuraio
Copy link

I also seed an Admin user managed by Devise which then uses Devise Invitable to create any other, since I don't have an Admin registrations form. So, I need rake db:seed in Capistrano for production ENV.

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

No branches or pull requests

9 participants