Migration.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\Migrations\Contracts; |
| 4 | |
| 5 | use RuntimeException; |
| 6 | |
| 7 | /** |
| 8 | * Class Migration |
| 9 | * |
| 10 | * Extend this class when create database migration. up and timestamp are required member functions |
| 11 | * |
| 12 | * @since 2.9.0 |
| 13 | */ |
| 14 | abstract class Migration { |
| 15 | /** |
| 16 | * Bootstrap migration logic. |
| 17 | * |
| 18 | * @since 2.9.0 |
| 19 | */ |
| 20 | abstract public function run(); |
| 21 | |
| 22 | /** |
| 23 | * Return a unique identifier for the migration |
| 24 | * |
| 25 | * @return string |
| 26 | */ |
| 27 | public static function id() { |
| 28 | throw new RuntimeException( 'A unique ID must be provided for the migration' ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Return a Unix Timestamp for when the migration was created |
| 33 | * |
| 34 | * Example: strtotime( '2020-09-16 ') |
| 35 | * |
| 36 | * @since 2.9.0 |
| 37 | * |
| 38 | * @return int Unix timestamp for when the migration was created |
| 39 | */ |
| 40 | public static function timestamp() { |
| 41 | throw new RuntimeException( 'This method must be overridden to return a valid unix timestamp' ); |
| 42 | } |
| 43 | } |
| 44 |