-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repair the
production_entities_enabled
feature
Prior to this change, the production_entities_enabled field could be deleted from the services table. This change cleans up after the migration got retracted. Also add the required param to the tests.
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Surfnet\ServiceProviderDashboard\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Drops the `production_entities_enabled` column from the `service` entity | ||
*/ | ||
final class Version20240514071702 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'This migration is preserved to keep the migration history intact. This migration was used to drop the `production_entities_enabled` field in the services table. However, the feature removal got dropped and we don\'t want to cause data loss.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Surfnet\ServiceProviderDashboard\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20241031120000 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Restores the `production_entities_enabled` column to the `service` table if got removed by retracted migration Version20240514071702'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// Check if the column exists | ||
$columns = $this->connection->createSchemaManager()->listTableColumns('service'); | ||
$columnExists = false; | ||
foreach ($columns as $column) { | ||
if ($column->getName() === 'production_entities_enabled') { | ||
$columnExists = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!$columnExists) { | ||
$this->addSql('ALTER TABLE service ADD production_entities_enabled TINYINT(1) NOT NULL DEFAULT 0'); | ||
} | ||
} | ||
} |
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