Commit 2b7ad1f 1 parent e7ec27c commit 2b7ad1f Copy full SHA for 2b7ad1f
File tree 1 file changed +30
-0
lines changed
webfiori/database/migration
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,36 @@ public function hasMigration(string $name) : bool {
118
118
}
119
119
return false ;
120
120
}
121
+ /**
122
+ * Apply one single migration at a time.
123
+ *
124
+ * @return AbstractMigration|null If a migration was applied, the method will
125
+ * return its information in an object of type 'AbstractMigration'. Other than that, null
126
+ * is returned.
127
+ */
128
+ public function applyOne () : ?AbstractMigration {
129
+ $ applied = null ;
130
+ foreach ($ this ->migrations as $ m ) {
131
+ if ($ this ->isApplied ($ m ->getName ())) {
132
+ continue ;
133
+ }
134
+ $ m ->up ($ this );
135
+ $ this ->table ('migrations ' )
136
+ ->insert ([
137
+ 'name ' => $ m ->getName (),
138
+ 'applied-on ' => date ('Y-m-d H:i:s ' )
139
+ ])->execute ();
140
+ $ applied = $ m ;
141
+ break ;
142
+ }
143
+ return $ applied ;
144
+ }
145
+ /**
146
+ * Apply all detected migrations.
147
+ *
148
+ * @return array The method will return an array that holds all applied migrations
149
+ * as objects of type 'AbstractMigration'.
150
+ */
121
151
public function apply () : array {
122
152
$ applied = [];
123
153
foreach ($ this ->migrations as $ m ) {
You can’t perform that action at this time.
0 commit comments