<?php

namespace Signteer\Core\Database;

use Plainwork\Database\Database;

class SignupTable
{
    public const NAME = '__signup';
    public const COL_ID = 'id';
    public const COL_TASK_ID = 'task_id';
    public const COL_VOLUNTEER_ID = 'volunteer_id';

    public function up1($db)
    {
        $cols = [
            self::COL_ID => ['type' => 'INTEGER', 'null' => false, 'autoIncrement' => true, 'primaryKey' => true],
            self::COL_TASK_ID => ['type' => 'INTEGER', 'null' => false],
            self::COL_VOLUNTEER_ID => ['type' => 'INTEGER', 'null' => false],
        ];
        $db->createTable(self::NAME, $cols);

        $db->addUnique(self::NAME, self::COL_TASK_ID, self::COL_VOLUNTEER_ID);
    }

    public function down1($db)
    {
        $db->dropTable(self::NAME);
    }
}
