Fix installer error when the task is run a second time

Fix task idempotency. Check if a table exists before running the schema
patch.

Bug: T352113
Change-Id: If6f0930ea327df35fe118d4a08993c6383f9d579
This commit is contained in:
Tim Starling 2024-11-28 14:54:42 +11:00
parent 441ca70fbf
commit 105f2a3845

View file

@ -33,10 +33,11 @@ class InstallSchemaTask extends Task {
} }
public function execute(): Status { public function execute(): Status {
$status = Status::newGood();
$cluster = $this->getConfigVar( 'EchoCluster' ); $cluster = $this->getConfigVar( 'EchoCluster' );
if ( !$cluster ) { if ( !$cluster ) {
// This case is adequately handled by LoadExtensionSchemaUpdates // This case is adequately handled by LoadExtensionSchemaUpdates
return Status::newGood(); return $status;
} }
// Get the load balancer // Get the load balancer
@ -54,7 +55,10 @@ class InstallSchemaTask extends Task {
// Create tables // Create tables
$dbw = $echoLB->getMaintenanceConnectionRef( DB_PRIMARY ); $dbw = $echoLB->getMaintenanceConnectionRef( DB_PRIMARY );
$dbw->setSchemaVars( $this->getContext()->getSchemaVars() ); $dbw->setSchemaVars( $this->getContext()->getSchemaVars() );
return $this->applySourceFile( $dbw, 'tables-generated.sql' ); if ( !$dbw->tableExists( 'echo_event' ) ) {
$status = $this->applySourceFile( $dbw, 'tables-generated.sql' );
}
return $status;
} }
} }