Search code examples
ruby-on-railsdeploymenthookengineyard

Engineyard Deployment: How to detect in deployhooks that its the first attempt to execute 'rake db:seed'


I am having trouble to detect that this is the first attempt of deployment after a server instance is booted. I need to run the command rake db:seed only the first time to set the default users and other details in database. I have no idea if this is possible.

can anybody help me please


Solution

  • The best way to find out is by sending --extra-deploy-hook-options while running deployment command and check in the after_migrate.rb if config[:initial] is present or not. The command would look like

      ey deploy -e myapp_staging --config=initial:true
    

    after_migrate.rb hook will looks like:

    on_app_servers do
      if config[:initial] == 'true'
        $stderr.puts "Seeding the data"
        run "cd #{config.release_path}"
        run "bundle exec rake db:seed"
      else
        $stderr.puts "Skipping the Seeding process"
       end
    end
    

    For more information ey help deployenter image description here