1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
5
|
|
|
* |
6
|
|
|
* @package MyArtJaub\Webtrees |
7
|
|
|
* @subpackage AdminTasks |
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2020-2022, Jonathan Jaubart |
10
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace MyArtJaub\Webtrees\Module\AdminTasks\Schema; |
16
|
|
|
|
17
|
|
|
use Carbon\Carbon; |
18
|
|
|
use Fisharebest\Webtrees\Schema\MigrationInterface; |
19
|
|
|
use Illuminate\Database\Capsule\Manager as DB; |
20
|
|
|
use Illuminate\Database\Schema\Blueprint; |
21
|
|
|
use Fisharebest\Webtrees\Registry; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Upgrade the database schema from version 1 (webtrees 1.0) to version 2 (webtrees 2.0). |
25
|
|
|
*/ |
26
|
|
|
class Migration1 implements MigrationInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* {@inheritDoc} |
30
|
|
|
* @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
31
|
|
|
*/ |
32
|
|
|
public function upgrade(): void |
33
|
|
|
{ |
34
|
|
|
$in_transaction = DB::connection()->getPdo()->inTransaction(); |
35
|
|
|
|
36
|
|
|
// Clean up previous admin tasks table if it exists |
37
|
|
|
DB::schema()->dropIfExists('maj_admintasks'); |
38
|
|
|
|
39
|
|
|
DB::schema()->create('maj_admintasks', static function (Blueprint $table): void { |
40
|
|
|
|
41
|
|
|
$table->increments('majat_id'); |
42
|
|
|
$table->string('majat_task_id', 32)->unique(); |
43
|
|
|
$table->enum('majat_status', ['enabled', 'disabled'])->default('disabled'); |
44
|
|
|
$table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0)); |
45
|
|
|
$table->boolean('majat_last_result')->default(true); |
46
|
|
|
$table->integer('majat_frequency')->default(10080); |
47
|
|
|
$table->smallInteger('majat_nb_occur')->default(0); |
48
|
|
|
$table->boolean('majat_running')->default(false); |
49
|
|
|
}); |
50
|
|
|
|
51
|
|
|
if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) { |
52
|
|
|
DB::connection()->beginTransaction(); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|