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 | * Migration constructor. |
||
33 | * |
||
34 | * @param ConnectionManagement $_connection |
||
35 | * @param string $_folder |
||
36 | */ |
||
37 | public function __construct(ConnectionManagement $_connection, $_folder) |
||
46 | |||
47 | /** |
||
48 | * @return DBDataset |
||
49 | */ |
||
50 | public function getDbDataset() |
||
57 | |||
58 | /** |
||
59 | * @return CommandInterface |
||
60 | */ |
||
61 | public function getDbCommand() |
||
69 | |||
70 | protected function getCommandClassName() |
||
74 | |||
75 | /** |
||
76 | * Get the full path and name of the "base.sql" script |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getBaseSql() |
||
84 | |||
85 | /** |
||
86 | * Get the full path script based on the version |
||
87 | * |
||
88 | * @param $version |
||
89 | * @param $increment |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getMigrationSql($version, $increment) |
||
99 | |||
100 | /** |
||
101 | * Create the database it it does not exists. Does not use this methos in a production environment; |
||
102 | */ |
||
103 | public function prepareEnvironment() |
||
108 | |||
109 | /** |
||
110 | * Restore the database using the "base.sql" script and run all migration scripts |
||
111 | * Note: the database must exists. If dont exist run the method prepareEnvironment. |
||
112 | * |
||
113 | * @param int $upVersion |
||
114 | */ |
||
115 | public function reset($upVersion = null) |
||
123 | |||
124 | /** |
||
125 | * Get the current database version |
||
126 | * |
||
127 | * @return int |
||
128 | */ |
||
129 | public function getCurrentVersion() |
||
133 | |||
134 | /** |
||
135 | * @param $currentVersion |
||
136 | * @param $upVersion |
||
137 | * @param $increment |
||
138 | * @return bool |
||
139 | */ |
||
140 | protected function canContinue($currentVersion, $upVersion, $increment) |
||
150 | |||
151 | /** |
||
152 | * Method for execute the migration. |
||
153 | * |
||
154 | * @param int $upVersion |
||
155 | * @param int $increment Can accept 1 for UP or -1 for down |
||
156 | */ |
||
157 | protected function migrate($upVersion, $increment) |
||
168 | |||
169 | /** |
||
170 | * Run all scripts to up the database version from current up to latest version or the specified version. |
||
171 | * |
||
172 | * @param int $upVersion |
||
173 | */ |
||
174 | public function up($upVersion = null) |
||
178 | |||
179 | /** |
||
180 | * Run all scripts to down the database version from current version up to the specified version. |
||
181 | * |
||
182 | * @param int $upVersion |
||
183 | */ |
||
184 | public function down($upVersion) |
||
188 | } |
||
189 |