aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.167_tic5661_setup_cronjob.php
blob: 14e3540fec6a33833365d34e8237e89cdb5a7aba (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
<?php
/**
 * Migration that registers the cronjob for TIC 5661 that removes
 * expired entries from the table "object_user_visits".
 *
 * Note: This migration only registers the task but does not set up
 * any schedule, thus leaving it optional.
 *
 * @author  Jan-Hendrik Willms <tleilax+studip@gmail.com>
 * @license GPL2 or any later version
 * @since   Stud.IP 3.3
 */

class Tic5661SetupCronjob extends Migration
{
    public function description()
    {
        return 'Registers the cronjob for TIC 5661 that removes expired '
             . 'entries from the table "object_user_visits".';
    }

    public function up()
    {
        CronjobScheduler::registerTask($this->getFilename(), false);
    }

    public function down()
    {
        $task_id = CronjobTask::findOneByFilename($this->getFilename())->task_id;
        CronjobScheduler::unregisterTask($task_id);
    }

    private function getFilename()
    {
        return 'lib/cronjobs/clean_object_user_visits.php';
    }
}