Skip to content

Commit

Permalink
Fix production database diff
Browse files Browse the repository at this point in the history
  • Loading branch information
pablothedude committed Nov 28, 2024
1 parent 911f385 commit 9d834af
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 24 deletions.
5 changes: 0 additions & 5 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2450,11 +2450,6 @@ parameters:
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php

-
message: "#^Parameter \\#1 \\$raLocationName of class Surfnet\\\\Stepup\\\\Configuration\\\\Value\\\\RaLocationName constructor expects string, mixed given\\.$#"
count: 1
Expand Down
2 changes: 2 additions & 0 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ doctrine:
dir: "%kernel.project_dir%/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration"
prefix: Surfnet\StepupMiddleware\ManagementBundle\Configuration
is_bundle: false
schema_ignore_classes:
- Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaCandidate
gateway:
connection: gateway
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
Expand Down
55 changes: 55 additions & 0 deletions src/Surfnet/Migrations/Version20241128131107.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* Copyright 2024 SURFnet bv
*
* 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\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241128131107 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE institution_with_ra_locations');
$this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option INT DEFAULT 0 NOT NULL');
$this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT NULL');
$this->addSql('CREATE INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor (vetting_type)');
$this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints JSON NOT NULL COMMENT \'(DC2Type:stepup_vetting_type_hints)\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE institution_with_ra_locations (institution VARCHAR(255) CHARACTER SET utf8mb3 NOT NULL COLLATE `utf8mb3_unicode_ci`, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option TINYINT(1) DEFAULT 0 NOT NULL');
$this->addSql('DROP INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor');
$this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT \'unknown\'');
$this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints LONGTEXT NOT NULL');
}
}
55 changes: 55 additions & 0 deletions src/Surfnet/Migrations/Version20241128131108.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* Copyright 2024 SURFnet bv
*
* 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\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationInterface;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationTrait;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241128122650 extends AbstractMigration implements ConfigurationAwareMigrationInterface
{
use ConfigurationAwareMigrationTrait;

public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$gatewaySchema = $this->getGatewaySchema();

// this up() migration is auto-generated, please modify it to your needs
$this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1 NOT NULL', $gatewaySchema));
}

public function down(Schema $schema): void
{
$gatewaySchema = $this->getGatewaySchema();

// this down() migration is auto-generated, please modify it to your needs
$this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1', $gatewaySchema));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
use Surfnet\Stepup\Exception\InvalidArgumentException;

/**
* Custom Type for the NumberOfTokensPerIdentityOption Value Object
*/
class NumberOfTokensPerIdentityType extends Type
class NumberOfTokensPerIdentityType extends IntegerType
{
public const NAME = 'stepup_number_of_tokens_per_identity_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use phpseclib3\Math\PrimeField\Integer;
use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption;
use TypeError;

/**
* Custom Type for the SelfAssertedTokens options Value Object
*/
class SelfAssertedTokensOptionType extends Type
class SelfAssertedTokensOptionType extends IntegerType
{
public const NAME = 'stepup_self_asserted_tokens_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
use TypeError;

/**
* Custom Type for the SelfVetOption Value Object
*/
class SelfVetOptionType extends Type
class SelfVetOptionType extends IntegerType
{
public const NAME = 'stepup_self_vet_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
use TypeError;

/**
* Custom Type for the SsoOn2faOption Value Object
*/
class SsoOn2faOptionType extends Type
class SsoOn2faOptionType extends IntegerType
{
public const NAME = 'stepup_sso_on_2fa_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BooleanType;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
Expand All @@ -27,7 +28,7 @@
/**
* Custom Type for the VerifyEmailOption Value Object
*/
class VerifyEmailOptionType extends Type
class VerifyEmailOptionType extends BooleanType
{
public const NAME = 'stepup_verify_email_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\JsonType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Collection\VettingTypeHintCollection;

/**
* Custom Type for the vetting type hints Value Object
*/
class VettingTypeHintsType extends Type
class VettingTypeHintsType extends JsonType
{
public const NAME = 'stepup_vetting_type_hints';

Expand All @@ -36,11 +37,6 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return $platform->getJsonTypeDeclarationSQL($column);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
return $value;
}

public function convertToPHPValue($value, AbstractPlatform $platform): ?VettingTypeHintCollection
{
if (is_null($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@
/**
* Be aware that this entity is used for the RA Candidate presentation only. This entity shouldn't be used to store any RA candidates.
*/
#[ORM\Table]
#[ORM\Entity(repositoryClass: RaCandidateRepository::class, readOnly: true)]
#[ORM\Index(name: "idx_ra_candidate_institution", columns: ["institution"])]
#[ORM\Index(name: "idx_ra_candidate_name_id", columns: ["name_id"])]
#[ORM\Index(name: "idxft_ra_candidate_email", columns: ["email"], flags: ['FULLTEXT'])]
#[ORM\Index(name: "idxft_ra_candidate_commonname", columns: ["common_name"], flags: ['FULLTEXT'])]
#[ORM\Index(name: "idx_ra_institution", columns: ["ra_institution"])]
#[ORM\UniqueConstraint(name: "idx_ra_candidate_unique_identity_institution", columns: ["identity_id", "ra_institution"])]
class RaCandidate implements JsonSerializable
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function setUp(): void

$this->databaseTool->setObjectManagerName('middleware');
// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function setUp(): void
$this->databaseTool = $databaseTool->get();

// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures([]);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InstitutionConfiguration
{
public function __construct(
#[ORM\Id]
#[ORM\Column(length: 200)]
#[ORM\Column(length: 255)]
public string $institution,
/**
* @var bool is the SSO on 2FA feature enabled?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function setUp(): void
}
$this->databaseTool = $databaseTool->get();
// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures([]);

$managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function setUp(): void
}
$this->databaseTool = $databaseTool->get();
// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures([]);

$managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password');
Expand Down

0 comments on commit 9d834af

Please sign in to comment.