1 | <?php |
||
10 | class Migration |
||
11 | { |
||
12 | /** |
||
13 | * @var Uri |
||
14 | */ |
||
15 | protected $uri; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $_folder; |
||
21 | |||
22 | /** |
||
23 | * @var DbDriverInterface |
||
24 | */ |
||
25 | protected $dbDriver; |
||
26 | |||
27 | /** |
||
28 | * @var CommandInterface |
||
29 | */ |
||
30 | protected $_dbCommand; |
||
31 | |||
32 | /** |
||
33 | * @var Callable |
||
34 | */ |
||
35 | protected $_callableProgress; |
||
36 | |||
37 | /** |
||
38 | * Migration constructor. |
||
39 | * |
||
40 | * @param Uri $uri |
||
41 | * @param string $_folder |
||
42 | */ |
||
43 | public function __construct(Uri $uri, $_folder) |
||
52 | |||
53 | /** |
||
54 | * @return DbDriverInterface |
||
55 | */ |
||
56 | public function getDbDriver() |
||
63 | |||
64 | /** |
||
65 | * @return CommandInterface |
||
66 | */ |
||
67 | public function getDbCommand() |
||
75 | |||
76 | protected function getCommandClassName() |
||
80 | |||
81 | /** |
||
82 | * Get the full path and name of the "base.sql" script |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getBaseSql() |
||
90 | |||
91 | /** |
||
92 | * Get the full path script based on the version |
||
93 | * |
||
94 | * @param $version |
||
95 | * @param $increment |
||
96 | * @return string |
||
97 | */ |
||
98 | public function getMigrationSql($version, $increment) |
||
113 | |||
114 | /** |
||
115 | * Create the database it it does not exists. Does not use this methos in a production environment; |
||
116 | */ |
||
117 | public function prepareEnvironment() |
||
122 | |||
123 | /** |
||
124 | * Restore the database using the "base.sql" script and run all migration scripts |
||
125 | * Note: the database must exists. If dont exist run the method prepareEnvironment. |
||
126 | * |
||
127 | * @param int $upVersion |
||
128 | */ |
||
129 | public function reset($upVersion = null) |
||
140 | |||
141 | /** |
||
142 | * Get the current database version |
||
143 | * |
||
144 | * @return int |
||
145 | */ |
||
146 | public function getCurrentVersion() |
||
150 | |||
151 | /** |
||
152 | * @param $currentVersion |
||
153 | * @param $upVersion |
||
154 | * @param $increment |
||
155 | * @return bool |
||
156 | */ |
||
157 | protected function canContinue($currentVersion, $upVersion, $increment) |
||
167 | |||
168 | /** |
||
169 | * Method for execute the migration. |
||
170 | * |
||
171 | * @param int $upVersion |
||
172 | * @param int $increment Can accept 1 for UP or -1 for down |
||
173 | */ |
||
174 | protected function migrate($upVersion, $increment) |
||
190 | |||
191 | /** |
||
192 | * Run all scripts to up the database version from current up to latest version or the specified version. |
||
193 | * |
||
194 | * @param int $upVersion |
||
195 | */ |
||
196 | public function up($upVersion = null) |
||
200 | |||
201 | /** |
||
202 | * Run all scripts to down the database version from current version up to the specified version. |
||
203 | * |
||
204 | * @param int $upVersion |
||
205 | */ |
||
206 | public function down($upVersion) |
||
210 | |||
211 | public function addCallbackProgress(Callable $callable) |
||
215 | } |
||
216 |