|
|
@@ -24,16 +24,12 @@ class PostUpgradeCommand extends Command
|
|
|
protected function configure(): void
|
|
|
{}
|
|
|
|
|
|
+ /**
|
|
|
+ * @throws \Exception
|
|
|
+ */
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
{
|
|
|
- $version = $_ENV['VERSION'];
|
|
|
- if ($version !== self::TARGETED_VERSION) {
|
|
|
- throw new \RuntimeException(
|
|
|
- 'Targeted version (' . self::TARGETED_VERSION . ') is different from ' .
|
|
|
- 'current version (' . $version . ')'
|
|
|
- );
|
|
|
- }
|
|
|
- $this->logger->info('Run post-upgrade scripts for version ' . $version);
|
|
|
+ $this->logger->info('Run post-upgrade scripts for version ' . self::TARGETED_VERSION);
|
|
|
|
|
|
$this->populateSubdomains();
|
|
|
|
|
|
@@ -49,16 +45,12 @@ class PostUpgradeCommand extends Command
|
|
|
|
|
|
$dbUrl = $_ENV['DATABASE_URL'];
|
|
|
$matches = [];
|
|
|
- $match = preg_match(
|
|
|
+ preg_match(
|
|
|
"/^mysql:\/\/(\w+):([^\s@]+)@(\w+):(\d+)\/(\w+)/",
|
|
|
$dbUrl,
|
|
|
$matches
|
|
|
);
|
|
|
- $dbUser = $matches[1];
|
|
|
- $dbPwd = $matches[2];
|
|
|
- $dbHost = $matches[3];
|
|
|
- $dbPort = $matches[4];
|
|
|
- $dbName = $matches[5];
|
|
|
+ [$dbUser, $dbPwd, $dbHost, $dbPort, $dbName] = array_slice($matches, 1);
|
|
|
|
|
|
$cnn = new PDO(
|
|
|
"mysql:host=" . $dbHost . ";dbname=" . $dbName,
|
|
|
@@ -101,9 +93,19 @@ class PostUpgradeCommand extends Command
|
|
|
$cnn->query($sql);
|
|
|
|
|
|
$this->logger->info('Set the current subdomains');
|
|
|
- $sql = "update opentalent.Parameters p
|
|
|
- inner join opentalent.Subdomain s on s.parameters_id = p.id and s.subdomain = p.subDomain
|
|
|
- set p.activeSubdomain_id = s.id;";
|
|
|
+ $sql = "update opentalent.Subdomain s set s.active = false;";
|
|
|
+ $cnn->query($sql);
|
|
|
+
|
|
|
+ $sql = "update opentalent.Subdomain s
|
|
|
+ inner join opentalent.Parameters p
|
|
|
+ on s.parameters_id = p.id and s.subdomain = p.subDomain
|
|
|
+ set s.active = true;";
|
|
|
+ $cnn->query($sql);
|
|
|
+
|
|
|
+ $this->logger->info('Set the custom domains');
|
|
|
+ $sql = "update opentalent.Parameters
|
|
|
+ set customDomain = otherWebsite
|
|
|
+ where otherWebsite not like '%.opentalent.fr'";
|
|
|
$cnn->query($sql);
|
|
|
|
|
|
$cnn->commit();
|