1 | <?php |
||
9 | class Migration |
||
10 | { |
||
11 | /** |
||
12 | * @var ConnectionManagement |
||
13 | */ |
||
14 | protected $_connection; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $_folder; |
||
20 | |||
21 | /** |
||
22 | * @var DBDataset |
||
23 | */ |
||
24 | protected $_dbDataset; |
||
25 | |||
26 | /** |
||
27 | * @var CommandInterface |
||
28 | */ |
||
29 | protected $_dbCommand; |
||
30 | |||
31 | /** |
||
32 | * @var Callable |
||
33 | */ |
||
34 | protected $_callableProgress; |
||
35 | |||
36 | /** |
||
37 | * Migration constructor. |
||
38 | * |
||
39 | * @param ConnectionManagement $_connection |
||
40 | * @param string $_folder |
||
41 | */ |
||
42 | public function __construct(ConnectionManagement $_connection, $_folder) |
||
51 | |||
52 | /** |
||
53 | * @return DBDataset |
||
54 | */ |
||
55 | public function getDbDataset() |
||
62 | |||
63 | /** |
||
64 | * @return CommandInterface |
||
65 | */ |
||
66 | public function getDbCommand() |
||
74 | |||
75 | protected function getCommandClassName() |
||
79 | |||
80 | /** |
||
81 | * Get the full path and name of the "base.sql" script |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getBaseSql() |
||
89 | |||
90 | /** |
||
91 | * Get the full path script based on the version |
||
92 | * |
||
93 | * @param $version |
||
94 | * @param $increment |
||
95 | * @return string |
||
96 | */ |
||
97 | public function getMigrationSql($version, $increment) |
||
104 | |||
105 | /** |
||
106 | * Create the database it it does not exists. Does not use this methos in a production environment; |
||
107 | */ |
||
108 | public function prepareEnvironment() |
||
113 | |||
114 | /** |
||
115 | * Restore the database using the "base.sql" script and run all migration scripts |
||
116 | * Note: the database must exists. If dont exist run the method prepareEnvironment. |
||
117 | * |
||
118 | * @param int $upVersion |
||
119 | */ |
||
120 | public function reset($upVersion = null) |
||
131 | |||
132 | /** |
||
133 | * Get the current database version |
||
134 | * |
||
135 | * @return int |
||
136 | */ |
||
137 | public function getCurrentVersion() |
||
141 | |||
142 | /** |
||
143 | * @param $currentVersion |
||
144 | * @param $upVersion |
||
145 | * @param $increment |
||
146 | * @return bool |
||
147 | */ |
||
148 | protected function canContinue($currentVersion, $upVersion, $increment) |
||
158 | |||
159 | /** |
||
160 | * Method for execute the migration. |
||
161 | * |
||
162 | * @param int $upVersion |
||
163 | * @param int $increment Can accept 1 for UP or -1 for down |
||
164 | */ |
||
165 | protected function migrate($upVersion, $increment) |
||
181 | |||
182 | /** |
||
183 | * Run all scripts to up the database version from current up to latest version or the specified version. |
||
184 | * |
||
185 | * @param int $upVersion |
||
186 | */ |
||
187 | public function up($upVersion = null) |
||
191 | |||
192 | /** |
||
193 | * Run all scripts to down the database version from current version up to the specified version. |
||
194 | * |
||
195 | * @param int $upVersion |
||
196 | */ |
||
197 | public function down($upVersion) |
||
201 | |||
202 | public function addCallbackProgress(Callable $callable) |
||
206 | } |
||
207 |