summaryrefslogtreecommitdiff
path: root/db/migrations/2019_09_07_000000_migrate_admin_schedule_permissions.php
blob: e39e22d85635b3718a1015cbef625a5392391c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

namespace Engelsystem\Migrations;

use Engelsystem\Database\Migration\Migration;

class MigrateAdminSchedulePermissions extends Migration
{
    /**
     * Run the migration
     */
    public function up()
    {
        if (!$this->schema->hasTable('Privileges')) {
            return;
        }

        $this->schema->getConnection()
            ->table('Privileges')
            ->where('name', 'admin_import')
            ->update(
                [
                    'name' => 'schedule.import',
                    'desc' => 'Import rooms and shifts from schedule.xml',
                ]
            );
    }

    /**
     * Reverse the migration
     */
    public function down()
    {
        if (!$this->schema->hasTable('Privileges')) {
            return;
        }

        $this->schema->getConnection()
            ->table('Privileges')
            ->where('name', 'schedule.import')
            ->update(
                [
                    'name' => 'admin_import',
                    'desc' => 'Import rooms and shifts from schedule.xcs/schedule.xcal',
                ]
            );
    }
}