Skip to content

Commit

Permalink
FOIA-426: Drush command for resetting all of the migrate statuses.
Browse files Browse the repository at this point in the history
  • Loading branch information
brockfanning committed Feb 27, 2024
1 parent aa9338d commit 5cbd18e
Showing 1 changed file with 108 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Drupal\foia_upload_xml\FoiaUploadXmlMigrationsProcessor;
use Drupal\foia_upload_xml\FoiaUploadXmlReportParser;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drush\Commands\DrushCommands;

/**
Expand Down Expand Up @@ -403,4 +404,111 @@ public function clean() {
}
}

/**
* Reset the status of all of the XML-upload-related migrations.
*
* @usage foia-upload-xml:reset
* Reset the status of all of these migrations.
*
* @command foia-upload-xml:reset
* @aliases fuxml-reset
* @bootstrap full
*/
public function reset() {
$migrations = [
'component_requests_va',
'foia_agency_report',
'foia_requests_va',
'component_iv_statutes',
'component_ix_personnel',
'component_va_requests',
'component_vb1_requests',
'component_vb2_requests',
'component_vb3_requests',
'component_via_disposition',
'component_vib_disposition',
'component_vic1_applied_exemptions',
'component_vic2_nonexemption_denial',
'component_vic3_other_denial',
'component_vic4_response_time',
'component_vic5_oldest_pending',
'component_viia_processed_requests',
'component_viib_processed_requests',
'component_viic1_simple_response',
'component_viic2_complex_response',
'component_viic3_expedited_response',
'component_viid_pending_requests',
'component_viie_oldest_pending',
'component_viiia_expedited_processing',
'component_viiib_fee_waiver',
'component_xia_subsection_c',
'component_xib_subsection_a2',
'component_xiia',
'component_xiib',
'component_xiic',
'component_xiid1',
'component_xiid2',
'component_xiie1',
'component_xiie2',
'component_x_fees',
'foia_iv_details',
'foia_vb2_other',
'foia_vic3_other',
'foia_iv_statute',
'foia_va_requests',
'foia_vb1_requests',
'foia_vb2',
'foia_vb3_requests',
'foia_via_disposition',
'foia_vib_disposition',
'foia_vic1_applied_exemptions',
'foia_vic2_nonexemption_denial',
'foia_vic3',
'foia_vic4_response_time',
'foia_viia_processed_requests',
'foia_viib_processed_requests',
'foia_viic1_simple_response',
'foia_viic2_complex_response',
'foia_viic3_expedited_response',
'foia_viid_pending_requests',
'foia_vic5_oldest_pending',
'foia_viie_oldest_pending',
'foia_viiia_expedited_processing',
'foia_viiib_fee_waiver',
'foia_ix_personnel',
'foia_x_fees',
'foia_xia_subsection_c',
'foia_xib_subsection_a2',
'foia_xiia',
'foia_xiib',
'foia_xiic',
'foia_xiid1',
'foia_xiid2',
'foia_xiie1',
'foia_xiie2',
];
foreach ($migrations as $mig_id) {
$migration = \Drupal::service('plugin.manager.migration')->createInstance($mig_id);
if ($migration) {
$status = $migration->getStatus();
if ($status == MigrationInterface::STATUS_IDLE) {
$this->logger()->warning(
\dt('Migration @id is already Idle', ['@id' => $mig_id])
);
}
else {
$migration->setStatus(MigrationInterface::STATUS_IDLE);
$this->logger()->notice(
\dt('Migration @id reset to Idle', ['@id' => $mig_id])
);
}
}
else {
$error = \dt('Migration @id does not exist', ['@id' => $mig_id]);
$this->logger()->error($error);
throw new \Exception($error);
}
}
}

}

0 comments on commit 5cbd18e

Please sign in to comment.