Passed
Branch main (f9aaf7)
by Jonathan
14:43
created

Migration1::upgrade()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * webtrees-lib: MyArtJaub library for webtrees
5
 *
6
 * @package MyArtJaub\Webtrees
7
 * @subpackage Hooks
8
 * @author Jonathan Jaubart <[email protected]>
9
 * @copyright Copyright (c) 2011-2021, 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\Hooks\Schema;
16
17
use Fisharebest\Webtrees\Schema\MigrationInterface;
18
use Illuminate\Database\Capsule\Manager as DB;
19
use Illuminate\Database\Schema\Blueprint;
20
21
/**
22
 * Upgrade the database schema from version 1 to version 2.
23
 */
24
class Migration1 implements MigrationInterface
25
{
26
27
    /**
28
     * {@inheritDoc}
29
     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
30
     */
31
    public function upgrade(): void
32
    {
33
        if (DB::schema()->hasTable('maj_hooks')) {
34
            DB::schema()->drop('maj_hooks');
35
        }
36
37
        DB::schema()->create('maj_hook_order', static function (Blueprint $table): void {
38
            $table->string('majho_module_name', 32);
39
            $table->string('majho_hook_name', 64);
40
            $table->integer('majho_hook_order')->nullable();
41
42
            $table->primary(['majho_module_name', 'majho_hook_name']);
43
        });
44
    }
45
}
46