Migration.php
3 years ago
Migration_1_0.php
3 years ago
Migration_1_6.php
3 years ago
Migration_1_8.php
3 years ago
Migration_1_9.php
3 years ago
Migration_2.php
3 years ago
Migration_3.php
3 years ago
Migration_4.php
3 years ago
Migration_5.php
3 years ago
Migration_6.php
3 years ago
Migration_7.php
3 years ago
Migration_8.php
3 years ago
Migration_Job.php
3 years ago
Migration_Job.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Migrations; |
| 4 | |
| 5 | use IAWP\WP_Async_Request; |
| 6 | |
| 7 | class Migration_Job extends WP_Async_Request |
| 8 | { |
| 9 | /** |
| 10 | * @var string |
| 11 | */ |
| 12 | protected $action = 'iawp_database_migration'; |
| 13 | |
| 14 | /** |
| 15 | * Handle |
| 16 | * |
| 17 | * Override this method to perform any actions required |
| 18 | * during the async request. |
| 19 | * |
| 20 | * @return void |
| 21 | */ |
| 22 | protected function handle(): void |
| 23 | { |
| 24 | Migration::create_or_migrate(); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Dispatch a migration job if the database is out of date and no migration is currently running |
| 29 | * |
| 30 | * @return void |
| 31 | */ |
| 32 | public static function maybe_dispatch(): void |
| 33 | { |
| 34 | if (Migration::should_migrate()) { |
| 35 | $migration_job = new self(); |
| 36 | $migration_job->dispatch(); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 |