-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update migration logic to use a single file to avoid race conditions (#…
…81) * Update migration logic to use a single file to avoid race conditions * Delete the old config refresh migration * Bugfix/5.2.1/phpmyadmin and update note (#82) * Ensure initial phpmyadmin run is detached * Let the user know the update check is cached * Display cache last updated time * Replace bash only here-string when creating databases (#84) * Loop bootstrap validation until it passes (#83) * Loop bootstrap validation until it passes * Set test class to final
- Loading branch information
Showing
19 changed files
with
314 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php declare( strict_types=1 ); | ||
|
||
namespace App\Services\Migrations; | ||
|
||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* Manages the state of when migrations should run. | ||
*/ | ||
class MigrationChecker { | ||
|
||
public const MIGRATION_FILE = '.migrated'; | ||
|
||
/** | ||
* @var \Symfony\Component\Filesystem\Filesystem; | ||
*/ | ||
protected $filesystem; | ||
|
||
/** | ||
* The full path to the migration file. If this file does not exist, | ||
* we need to run a migration check. | ||
* | ||
* @var string | ||
*/ | ||
protected $migrationFile; | ||
|
||
/** | ||
* @param string $configDir The path to the SquareOne configuration directory. | ||
*/ | ||
public function __construct( Filesystem $filesystem, string $configDir ) { | ||
$this->filesystem = $filesystem; | ||
$this->migrationFile = sprintf( '%s/%s', $configDir, self::MIGRATION_FILE ); | ||
} | ||
|
||
/** | ||
* Whether a migration should take place. | ||
* | ||
* @return bool | ||
*/ | ||
public function shouldMigrate(): bool { | ||
return ! $this->filesystem->exists( $this->migrationFile ); | ||
} | ||
|
||
/** | ||
* Clear the migration file. | ||
*/ | ||
public function clear(): void { | ||
$this->filesystem->remove( $this->migrationFile ); | ||
} | ||
|
||
/** | ||
* Create the migration file. | ||
* | ||
* @throws \Symfony\Component\Filesystem\Exception\IOException | ||
*/ | ||
public function update(): void { | ||
$this->filesystem->touch( $this->migrationFile ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.