Skip to content

Commit

Permalink
MigrationAnalyzer: minor adjustment (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal authored Dec 12, 2024
1 parent 51c3e59 commit 7ca3539
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ You can hook into migration execution by implementing `MigrationExecutor` interf
Implement `executeQuery()` to run checks or other code before/after each query.
Interface of this method mimics interface of `Doctrine\DBAL\Connection::executeQuery()`.

#### Alter generated migration SQLs:
You can implement custom `MigrationAnalyzer` and register it as a service.
This allows you to alter generated SQLs (e.g. add `ALGORITHM=INSTANT`) and assign them to proper phase.

#### Run all queries within transaction:

You can change your template (or a single migration) to extend; `TransactionalMigration`.
Expand Down
2 changes: 1 addition & 1 deletion src/MigrationsAnalyzer.php → src/MigrationAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* - drop statements
* - reorder statements
*/
interface MigrationsAnalyzer
interface MigrationAnalyzer
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MigrationDefaultAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ShipMonk\Doctrine\Migration;

class MigrationDefaultAnalyzer implements MigrationsAnalyzer
class MigrationDefaultAnalyzer implements MigrationAnalyzer
{

/**
Expand Down
4 changes: 2 additions & 2 deletions src/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ class MigrationService

private MigrationVersionProvider $versionProvider;

private MigrationsAnalyzer $migrationsAnalyzer;
private MigrationAnalyzer $migrationsAnalyzer;

public function __construct(
EntityManagerInterface $entityManager,
MigrationConfig $config,
?MigrationExecutor $executor = null,
?MigrationVersionProvider $versionProvider = null,
?MigrationsAnalyzer $migrationsAnalyzer = null
?MigrationAnalyzer $migrationsAnalyzer = null
)
{
$this->entityManager = $entityManager;
Expand Down
4 changes: 2 additions & 2 deletions tests/MigrationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function getNextVersion(): string
};
[$entityManager, $logger] = $this->createEntityManagerAndLogger();

$statementAnalyser = new class implements MigrationsAnalyzer
$statementAnalyser = new class implements MigrationAnalyzer
{

/**
Expand Down Expand Up @@ -295,7 +295,7 @@ private function createMigrationService(
array $excludedTables = [],
bool $transactional = false,
?MigrationVersionProvider $versionProvider = null,
?MigrationsAnalyzer $statementAnalyzer = null
?MigrationAnalyzer $statementAnalyzer = null
): MigrationService
{
$migrationsDir = $this->getMigrationsTestDir();
Expand Down

0 comments on commit 7ca3539

Please sign in to comment.