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

Add a db:check task #31

Open
WengerK opened this issue Jan 6, 2020 · 0 comments
Open

Add a db:check task #31

WengerK opened this issue Jan 6, 2020 · 0 comments
Labels
d8 Drupal 8 d9 Drupal 9 enhancement

Comments

@WengerK
Copy link
Member

WengerK commented Jan 6, 2020

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
@WengerK WengerK added the d9 Drupal 9 label Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
d8 Drupal 8 d9 Drupal 9 enhancement
Projects
None yet
Development

No branches or pull requests

1 participant