Skip to content

Add a db:check task #31

@WengerK

Description

@WengerK

To ensure the Database is reachable before some commands (such as setuping a new Drupal instance).

  namespace :db do
    desc "Ensure the Database is reachable"
    task :check do
      on roles(:app) do
        within release_path.join(fetch(:app_path)) do
          output = capture(:drush, "status")
          dbstatus = false

          output.each_line do |line|
            if line.include?("Database") && line.include?("Connected")
              dbstatus = true
            end
          end

          if dbstatus == false
            sqlconnect = capture(:drush, "sql:connect")
            raise "The Database seems not reachable. Be sure the following SQL connection is valid '#{sqlconnect}'."
          end
        end
      end
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions