Skip to content

Commit

Permalink
Merge pull request #34 from whitedigital-eu/0.7.x
Browse files Browse the repository at this point in the history
Change audit entity schema to whitedigital, provide migration
  • Loading branch information
acirulis authored May 15, 2024
2 parents d7de031 + 6dd6192 commit 1c9903d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions migrations/Version20240514134035.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Whitedigital\Audit\Migrations;

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

final class Version20240514134035 extends AbstractMigration
{
public function getDescription(): string
{
return 'Alter audit table schema to use whitedigital schema';
}

public function up(Schema $schema): void
{
$this->addSql('CREATE SCHEMA IF NOT EXISTS whitedigital');
$this->addSql('ALTER TABLE audit SET SCHEMA whitedigital');
$this->addSql('ALTER INDEX whitedigital.idx_9218ff7964c19c1 RENAME TO IDX_1E4A63C64C19C1');
$this->addSql('ALTER INDEX whitedigital.idx_9218ff79b6bd307f RENAME TO IDX_1E4A63CB6BD307F');
$this->addSql('ALTER INDEX whitedigital.idx_9218ff7922ffd58c RENAME TO IDX_1E4A63C22FFD58C');
$this->addSql('ALTER INDEX whitedigital.idx_9218ff79d0494586 RENAME TO IDX_1E4A63CD0494586');
$this->addSql('ALTER INDEX whitedigital.idx_9218ff798b8e8428 RENAME TO IDX_1E4A63C8B8E8428');
$this->addSql('ALTER INDEX whitedigital.idx_9218ff7943625d9f RENAME TO IDX_1E4A63C43625D9F');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE audit SET SCHEMA public');
$this->addSql('ALTER INDEX whitedigital.idx_1e4a63c43625d9f RENAME TO idx_9218ff7943625d9f');
$this->addSql('ALTER INDEX whitedigital.idx_1e4a63c8b8e8428 RENAME TO idx_9218ff798b8e8428');
$this->addSql('ALTER INDEX whitedigital.idx_1e4a63cd0494586 RENAME TO idx_9218ff79d0494586');
$this->addSql('ALTER INDEX whitedigital.idx_1e4a63c22ffd58c RENAME TO idx_9218ff7922ffd58c');
$this->addSql('ALTER INDEX whitedigital.idx_1e4a63cb6bd307f RENAME TO idx_9218ff79b6bd307f');
$this->addSql('ALTER INDEX whitedigital.idx_1e4a63c64c19c1 RENAME TO idx_9218ff7964c19c1');
}
}
8 changes: 8 additions & 0 deletions src/AuditBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ public function prependExtension(ContainerConfigurator $container, ContainerBuil
$this->addDoctrineConfig($container, $extensionConfig['default_entity_manager'] ?? 'default', 'Audit', self::MAPPINGS);
}

if ($builder->hasExtension('doctrine_migrations')) {
$container->extension('doctrine_migrations', [
'migrations_paths' => [
'Whitedigital\Audit\Migrations' => '%kernel.project_dir%/vendor/whitedigital-eu/audit-service/migrations',
],
]);
}

$this->configureApiPlatformExtension($container, $extensionConfig);
}

Expand Down
1 change: 1 addition & 0 deletions src/Entity/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use WhiteDigital\EntityResourceMapper\Entity\BaseEntity;

#[ORM\Entity]
#[ORM\Table(schema: 'whitedigital')]
#[ORM\MappedSuperclass]
#[ORM\Index(fields: ['category'])]
#[ORM\Index(fields: ['message'])]
Expand Down

0 comments on commit 1c9903d

Please sign in to comment.