Passed
Branch feature/2.0 (ef99fd)
by Jonathan
11:25
created

Migration1::upgrade()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9332
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, 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 Fisharebest\Webtrees\Schema\MigrationInterface;
18
use Illuminate\Database\Capsule\Manager as DB;
19
use Illuminate\Database\Schema\Blueprint;
20
use Fisharebest\Webtrees\Carbon;
21
22
/**
23
 * Upgrade the database schema from version 1 (webtrees 1.0) to version 2 (webtrees 2.0).
24
 */
25
class Migration1 implements MigrationInterface
26
{
27
    
28
    /**
29
     * {@inheritDoc}
30
     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
     */
32
    public function upgrade(): void
33
    {
34
        // Clean up previous admin tasks table if it exists
35
        DB::schema()->dropIfExists('maj_admintasks');
36
        
37
        DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
38
39
            $table->increments('majat_id');
40
            $table->string('majat_task_id', 32)->unique()->nullable(false);
41
            $table->enum('majat_status', ['enabled', 'disabled'])->nullable(false)->default('disabled');
42
            $table->dateTime('majat_last_run')->nullable(false)->default(Carbon::createFromTimestampUTC(0));
43
            $table->boolean('majat_last_result')->nullable(false)->default(true);
44
            $table->integer('majat_frequency')->nullable(false)->default(10080);
45
            $table->smallInteger('majat_nb_occur')->nullable(false)->default(0);
46
            $table->boolean('majat_running')->nullable(false)->default(false);
47
        });
48
    }
49
}
50