فهرست منبع

add files status update to the upgrade command

Olivier Massot 3 سال پیش
والد
کامیت
e676c63c64
1فایلهای تغییر یافته به همراه25 افزوده شده و 4 حذف شده
  1. 25 4
      src/Commands/PostUpgrade/V0_2/PostUpgradeCommand.php

+ 25 - 4
src/Commands/PostUpgrade/V0_2/PostUpgradeCommand.php

@@ -33,6 +33,7 @@ class PostUpgradeCommand extends Command
 
         $this->populateSubdomains();
         $this->genEventsUuid();
+        $this->updateFilesStatuses();
 
         $output->writeln("Post-upgrade operations successfully executed");
         return Command::SUCCESS;
@@ -148,8 +149,8 @@ class PostUpgradeCommand extends Command
             $this->logger->info('Subdomain table was successfully populated');
         } catch (\Exception $e) {
             $opentalentCnn->rollBack();
-            $this->logger->critical('Error while running the post-upgrade script, abort and rollback');
-            throw $e;
+            $this->logger->error($e);
+            $this->logger->critical('Error while populating the subdomains, abort and rollback');
         }
     }
 
@@ -172,8 +173,28 @@ class PostUpgradeCommand extends Command
             $this->logger->info('Events uuid were successfully generated');
         } catch (\Exception $e) {
             $opentalentCnn->rollBack();
-            $this->logger->critical('Error while running the post-upgrade script, abort and rollback');
-            throw $e;
+            $this->logger->error($e);
+            $this->logger->critical('Error while generating events uuids, abort and rollback');
+        }
+    }
+
+    private function updateFilesStatuses() {
+        $opentalentCnn = $this->getOpentalentConnexion();
+
+        $opentalentCnn->beginTransaction();
+
+        try {
+            $this->logger->info('Update file statuses');
+
+            $sql = "update opentalent.File set status='READY', host='api';";
+            $opentalentCnn->query($sql);
+
+            $opentalentCnn->commit();
+            $this->logger->info('Files statuses were successfully updated');
+        } catch (\Exception $e) {
+            $opentalentCnn->rollBack();
+            $this->logger->error($e);
+            $this->logger->critical('Error while updating file statuses, abort and rollback');
         }
     }
 }