HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/timetracker.panomity.com/tm.old/Migrations/Version20191207120554.php
<?php

declare(strict_types=1);

/*
 * This file is part of the TaskManagementBundle for Kimai 2.
 * All rights reserved by Kevin Papst (www.kevinpapst.de).
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace TaskManagementBundle\Migrations;

use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
 * @version 1.0
 */
final class Version20191207120554 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Create the task management table';
    }

    public function up(Schema $schema): void
    {
        if (!$schema->hasTable('kimai2_tasks')) {
            $tasks = $schema->createTable('kimai2_tasks');
            $tasks->addColumn('id', 'integer', ['autoincrement' => true, 'notnull' => true]);
            $tasks->addColumn('title', 'string', ['notnull' => true, 'length' => 100]);
            $tasks->addColumn('description', 'text', ['notnull' => false]);
            $tasks->addColumn('status', 'string', ['notnull' => true, 'length' => 20]);
            $tasks->addColumn('start_time', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
            $tasks->addColumn('end_time', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
            $tasks->addColumn('timezone', 'string', ['notnull' => false, 'length' => 64]);
            $tasks->addColumn('activity_id', 'integer', ['notnull' => true]);
            $tasks->addColumn('project_id', 'integer', ['notnull' => true]);
            $tasks->addColumn('user_id', 'integer', ['notnull' => false]);
            $tasks->addColumn('team_id', 'integer', ['notnull' => false]);
            $tasks->setPrimaryKey(['id']);
            $tasks->addIndex(['user_id', 'status', 'start_time', 'end_time']);
            $tasks->addIndex(['team_id', 'status', 'start_time', 'end_time']);
            $tasks->addForeignKeyConstraint('kimai2_users', ['user_id'], ['id'], ['onDelete' => 'CASCADE']);
            $tasks->addForeignKeyConstraint('kimai2_activities', ['activity_id'], ['id'], ['onDelete' => 'CASCADE']);
            $tasks->addForeignKeyConstraint('kimai2_projects', ['project_id'], ['id'], ['onDelete' => 'CASCADE']);
            $tasks->addForeignKeyConstraint('kimai2_teams', ['team_id'], ['id'], ['onDelete' => 'CASCADE']);
        }

        if (!$schema->hasTable('kimai2_task_tags')) {
            $tags = $schema->createTable('kimai2_task_tags');

            $tags->addColumn('task_id', 'integer', ['length' => 11, 'notnull' => true]);
            $tags->addColumn('tag_id', 'integer', ['length' => 11, 'notnull' => true]);
            $tags->addIndex(['task_id']);
            $tags->addIndex(['tag_id']);
            $tags->setPrimaryKey(['task_id', 'tag_id']);

            $tags->addForeignKeyConstraint('kimai2_tasks', ['task_id'], ['id'], ['onDelete' => 'CASCADE']);
            $tags->addForeignKeyConstraint('kimai2_tags', ['tag_id'], ['id'], ['onDelete' => 'CASCADE']);
        }

        if (!$schema->hasTable('kimai2_task_timesheets')) {
            $timesheets = $schema->createTable('kimai2_task_timesheets');

            $timesheets->addColumn('task_id', 'integer', ['length' => 11, 'notnull' => true]);
            $timesheets->addColumn('timesheet_id', 'integer', ['length' => 11, 'notnull' => true]);
            $timesheets->addIndex(['task_id']);
            $timesheets->addUniqueIndex(['timesheet_id']);
            $timesheets->setPrimaryKey(['task_id', 'timesheet_id']);

            $timesheets->addForeignKeyConstraint('kimai2_tasks', ['task_id'], ['id'], ['onDelete' => 'CASCADE']);
            $timesheets->addForeignKeyConstraint('kimai2_timesheet', ['timesheet_id'], ['id'], ['onDelete' => 'CASCADE']);
        }
    }

    public function down(Schema $schema): void
    {
        if ($schema->hasTable('kimai2_task_tags')) {
            $schema->getTable('kimai2_task_tags')->removeForeignKey('FK_24CB2E388DB60186');
            $schema->dropTable('kimai2_task_tags');
        }
        if ($schema->hasTable('kimai2_task_timesheets')) {
            $schema->getTable('kimai2_task_timesheets')->removeForeignKey('FK_734BF4748DB60186');
            $schema->dropTable('kimai2_task_timesheets');
        }
        if ($schema->hasTable('kimai2_tasks')) {
            $schema->dropTable('kimai2_tasks');
        }
    }
}