ahoyapi: v2
commands:
  pull:
    cmd: |
      download db main
      drush @default.dev cr
      SPLIT=$(drush pm-list --format=json --status=enabled --filter=name=config_split)
      if [[ "$SPLIT" != "[]" ]]; then
        drush -y @default.dev config-split:deactivate live --force
        drush -y @default.dev config-split:deactivate test --force
        drush -y @default.dev config-split:import develop
      fi
      download files main
      chmod -R ugo+w files/default/files
      chmod -R ugo+w files/default/private
    usage: Pull files and DB from live site
  pull-sql:
    cmd: |
      download db main
      drush @default.dev cr
      SPLIT=$(drush pm-list --format=json --status=enabled --filter=name=config_split)
      if [[ "$SPLIT" != "[]" ]]; then
        drush -y @default.dev config-split:deactivate live --force
        drush -y @default.dev config-split:deactivate test --force
        drush -y @default.dev config-split:import develop
      fi
    usage: Pull DB from live site
  pull-files:
    cmd: |
      download files main
      chmod -R ugo+w files/default/files
      chmod -R ugo+w files/default/private
    usage: Pull files from live site
  convert2mariadb:
    cmd: |
      drush @default.live ssh "drush eval \"print(\Drupal::database()->getConnectionOptions()['database'])\" | xargs -I % mysql --defaults-file=~/.my.cnf --execute 'select concat(\"alter table \",TABLE_SCHEMA,\".\",TABLE_NAME,\" CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;\") from information_schema.TABLES where TABLE_SCHEMA=\"%\" and TABLE_COLLATION=\"utf8mb4_0900_ai_ci\"' | grep ^alter | mysql --defaults-file=~/.my.cnf"
