2
2
3
3
namespace LaravelDoctrine \Migrations ;
4
4
5
- use Doctrine \DBAL \Migrations \Version ;
5
+ use Doctrine \Migrations \Exception \MigrationException ;
6
+ use Doctrine \Migrations \MigratorConfiguration ;
7
+ use Doctrine \Migrations \Version \Version ;
6
8
7
9
class Migrator
8
10
{
@@ -11,20 +13,20 @@ class Migrator
11
13
*/
12
14
protected $ notes = [];
13
15
14
- /**
15
- * @param Migration $migration
16
- * @param bool|false $dryRun
17
- * @param bool|false $timeQueries
18
- * @param bool|false $allowNoMigration
19
- */
16
+ /**
17
+ * @param Migration $migration
18
+ * @param bool|false $dryRun
19
+ * @param bool|false $timeQueries
20
+ * @param bool|false $allowNoMigration
21
+ * @throws MigrationException
22
+ */
20
23
public function migrate (Migration $ migration , $ dryRun = false , $ timeQueries = false , bool $ allowNoMigration = false )
21
24
{
22
- $ migration -> getMigration ()-> setNoMigrationException ( $ allowNoMigration );
25
+ $ configuration = $ this -> setConfiguration ( $ dryRun , $ timeQueries , $ allowNoMigration );
23
26
24
27
$ sql = $ migration ->getMigration ()->migrate (
25
28
$ migration ->getVersion (),
26
- $ dryRun ,
27
- $ timeQueries
29
+ $ configuration
28
30
);
29
31
30
32
$ this ->writeNotes ($ migration , $ timeQueries , $ sql );
@@ -38,7 +40,8 @@ public function migrate(Migration $migration, $dryRun = false, $timeQueries = fa
38
40
*/
39
41
public function execute (Version $ version , $ direction , $ dryRun = false , $ timeQueries = false )
40
42
{
41
- $ version ->execute ($ direction , $ dryRun , $ timeQueries );
43
+ $ configuration = $ this ->setConfiguration ($ dryRun , $ timeQueries );
44
+ $ version ->execute ($ direction , $ configuration );
42
45
43
46
$ verb = $ direction === 'down ' ? 'Rolled back ' : 'Migrated ' ;
44
47
@@ -119,4 +122,19 @@ protected function note($versionName, Version $version, $timeQueries = false, $v
119
122
120
123
$ this ->notes [] = $ msg ;
121
124
}
125
+
126
+ /**
127
+ * @param bool $dryRun
128
+ * @param bool $timeQueries
129
+ * @param bool $allowNoMigrations
130
+ * @return MigratorConfiguration
131
+ */
132
+ private function setConfiguration (bool $ dryRun = false , bool $ timeQueries = false , bool $ allowNoMigrations = false )
133
+ {
134
+ $ configuration = new MigratorConfiguration ();
135
+ $ configuration ->setDryRun ($ dryRun );
136
+ $ configuration ->setTimeAllQueries ($ timeQueries );
137
+ $ configuration ->setNoMigrationException ($ allowNoMigrations );
138
+ return $ configuration ;
139
+ }
122
140
}
0 commit comments