Skip to content

Commit 7ca3539

Browse files
authored
MigrationAnalyzer: minor adjustment (#109)
1 parent 51c3e59 commit 7ca3539

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ You can hook into migration execution by implementing `MigrationExecutor` interf
176176
Implement `executeQuery()` to run checks or other code before/after each query.
177177
Interface of this method mimics interface of `Doctrine\DBAL\Connection::executeQuery()`.
178178

179+
#### Alter generated migration SQLs:
180+
You can implement custom `MigrationAnalyzer` and register it as a service.
181+
This allows you to alter generated SQLs (e.g. add `ALGORITHM=INSTANT`) and assign them to proper phase.
182+
179183
#### Run all queries within transaction:
180184

181185
You can change your template (or a single migration) to extend; `TransactionalMigration`.

src/MigrationsAnalyzer.php renamed to src/MigrationAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* - drop statements
1313
* - reorder statements
1414
*/
15-
interface MigrationsAnalyzer
15+
interface MigrationAnalyzer
1616
{
1717

1818
/**

src/MigrationDefaultAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ShipMonk\Doctrine\Migration;
44

5-
class MigrationDefaultAnalyzer implements MigrationsAnalyzer
5+
class MigrationDefaultAnalyzer implements MigrationAnalyzer
66
{
77

88
/**

src/MigrationService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class MigrationService
3333

3434
private MigrationVersionProvider $versionProvider;
3535

36-
private MigrationsAnalyzer $migrationsAnalyzer;
36+
private MigrationAnalyzer $migrationsAnalyzer;
3737

3838
public function __construct(
3939
EntityManagerInterface $entityManager,
4040
MigrationConfig $config,
4141
?MigrationExecutor $executor = null,
4242
?MigrationVersionProvider $versionProvider = null,
43-
?MigrationsAnalyzer $migrationsAnalyzer = null
43+
?MigrationAnalyzer $migrationsAnalyzer = null
4444
)
4545
{
4646
$this->entityManager = $entityManager;

tests/MigrationServiceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function getNextVersion(): string
179179
};
180180
[$entityManager, $logger] = $this->createEntityManagerAndLogger();
181181

182-
$statementAnalyser = new class implements MigrationsAnalyzer
182+
$statementAnalyser = new class implements MigrationAnalyzer
183183
{
184184

185185
/**
@@ -295,7 +295,7 @@ private function createMigrationService(
295295
array $excludedTables = [],
296296
bool $transactional = false,
297297
?MigrationVersionProvider $versionProvider = null,
298-
?MigrationsAnalyzer $statementAnalyzer = null
298+
?MigrationAnalyzer $statementAnalyzer = null
299299
): MigrationService
300300
{
301301
$migrationsDir = $this->getMigrationsTestDir();

0 commit comments

Comments
 (0)