aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.211_tic7307_admission_rule_path.php
blob: 7892a2d66157c4f17852813233686c0520d25870 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
class TIC7307AdmissionRulePath extends Migration
{
    public function up()
    {
        DBManager::get()->exec("ALTER TABLE `admissionrules` ADD `path` VARCHAR(255) NOT NULL");

        $stmt = DBManager::get()->prepare("UPDATE `admissionrules` SET `path` = :path WHERE `id` = :id");

        foreach (DBManager::get()->fetchAll("SELECT `id`, `ruletype` FROM `admissionrules` ORDER BY `id`") as $rule) {
            $stmt->execute([
                'path' => 'lib/admissionrules/' . strtolower($rule['ruletype']),
                'id' => $rule['id']
            ]);
        }

    }

    public function down()
    {
        DBManager::get()->exec("ALTER TABLE `questionnaires` DROP `path`");
    }
}