| 1 | <?php |
||
| 20 | abstract class AbstractMigration |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var Db; |
||
| 24 | */ |
||
| 25 | protected $db; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param Db $db |
||
| 29 | */ |
||
| 30 | 13 | final public function __construct(Db $db) |
|
| 31 | { |
||
| 32 | 13 | $this->db = $db; |
|
| 33 | 13 | } |
|
| 34 | |||
| 35 | /** |
||
| 36 | * @return int |
||
| 37 | */ |
||
| 38 | 10 | public function getNumber() |
|
| 39 | { |
||
| 40 | 10 | if (!preg_match('/\d+/', get_class($this), $matches) || !($number = (int) $matches[0])) { |
|
| 41 | 1 | throw new \LogicException("Invalid migration class name (must include a migration number)"); |
|
| 42 | } |
||
| 43 | |||
| 44 | 9 | return $number; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Actions to be performed when migrating up to this version (e.g. 6.1.0 -> 6.2.0) |
||
| 49 | */ |
||
| 50 | abstract public function up(); |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Actions to be performed when migrating down from this version (e.g. 6.2.0 -> 6.0.0) |
||
| 54 | */ |
||
| 55 | 1 | public function down() |
|
| 58 | } |
||
| 59 |