1 | <?php |
||
11 | class Migration |
||
12 | { |
||
13 | /** |
||
14 | * @var Uri |
||
15 | */ |
||
16 | protected $uri; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $_folder; |
||
22 | |||
23 | /** |
||
24 | * @var DbDriverInterface |
||
25 | */ |
||
26 | protected $dbDriver; |
||
27 | |||
28 | /** |
||
29 | * @var DatabaseInterface |
||
30 | */ |
||
31 | protected $_dbCommand; |
||
32 | |||
33 | /** |
||
34 | * @var Callable |
||
35 | */ |
||
36 | protected $_callableProgress; |
||
37 | |||
38 | /** |
||
39 | * Migration constructor. |
||
40 | * |
||
41 | * @param Uri $uri |
||
42 | * @param string $_folder |
||
43 | */ |
||
44 | public function __construct(Uri $uri, $_folder) |
||
53 | |||
54 | /** |
||
55 | * @return DbDriverInterface |
||
56 | */ |
||
57 | public function getDbDriver() |
||
64 | |||
65 | /** |
||
66 | * @return DatabaseInterface |
||
67 | */ |
||
68 | public function getDbCommand() |
||
76 | |||
77 | protected function getDatabaseClassName() |
||
81 | |||
82 | /** |
||
83 | * Get the full path and name of the "base.sql" script |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getBaseSql() |
||
91 | |||
92 | /** |
||
93 | * Get the full path script based on the version |
||
94 | * |
||
95 | * @param $version |
||
96 | * @param $increment |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getMigrationSql($version, $increment) |
||
131 | |||
132 | /** |
||
133 | * Create the database it it does not exists. Does not use this methos in a production environment; |
||
134 | */ |
||
135 | public function prepareEnvironment() |
||
140 | |||
141 | /** |
||
142 | * Restore the database using the "base.sql" script and run all migration scripts |
||
143 | * Note: the database must exists. If dont exist run the method prepareEnvironment. |
||
144 | * |
||
145 | * @param int $upVersion |
||
146 | */ |
||
147 | public function reset($upVersion = null) |
||
159 | |||
160 | public function createVersion() |
||
164 | |||
165 | public function updateTableVersion() |
||
169 | |||
170 | /** |
||
171 | * Get the current database version |
||
172 | * |
||
173 | * @return int |
||
174 | */ |
||
175 | public function getCurrentVersion() |
||
179 | |||
180 | /** |
||
181 | * @param $currentVersion |
||
182 | * @param $upVersion |
||
183 | * @param $increment |
||
184 | * @return bool |
||
185 | */ |
||
186 | protected function canContinue($currentVersion, $upVersion, $increment) |
||
200 | |||
201 | /** |
||
202 | * Method for execute the migration. |
||
203 | * |
||
204 | * @param int $upVersion |
||
205 | * @param int $increment Can accept 1 for UP or -1 for down |
||
206 | * @param bool $force |
||
207 | * @throws \ByJG\DbMigration\Exception\DatabaseIsIncompleteException |
||
208 | */ |
||
209 | protected function migrate($upVersion, $increment, $force) |
||
231 | |||
232 | /** |
||
233 | * Run all scripts to up the database version from current up to latest version or the specified version. |
||
234 | * |
||
235 | * @param int $upVersion |
||
236 | * @param bool $force |
||
237 | */ |
||
238 | public function up($upVersion = null, $force = false) |
||
242 | |||
243 | /** |
||
244 | * Run all scripts to up or down the database version from current up to latest version or the specified version. |
||
245 | * |
||
246 | * @param int $upVersion |
||
247 | * @param bool $force |
||
248 | */ |
||
249 | public function update($upVersion = null, $force = false) |
||
259 | |||
260 | /** |
||
261 | * Run all scripts to down the database version from current version up to the specified version. |
||
262 | * |
||
263 | * @param int $upVersion |
||
264 | * @param bool $force |
||
265 | */ |
||
266 | public function down($upVersion, $force = false) |
||
270 | |||
271 | public function addCallbackProgress(Callable $callable) |
||
275 | } |
||
276 |