<?php

namespace Signteer\Core\Database;

use Plainwork\Database\Database;

class SheetTable
{
    public const NAME = '__sheet';
    public const COL_ID = 'id';
    public const COL_DATE = 'start_date';
    public const COL_TITLE = 'title';
    public const COL_DESCRIPTION = 'description';

    public function up1($db)
    {
        $cols = [
            self::COL_ID => ['type' => 'INTEGER', 'null' => false, 'autoIncrement' => true, 'primaryKey' => true],
            self::COL_DATE => ['type' => 'DATETIME', 'null' => false],
            self::COL_TITLE => ['type' => 'VARCHAR(255)', 'null' => false],
            self::COL_DESCRIPTION => ['type' => 'TEXT', 'null' => false],
        ];
        $db->createTable(self::NAME, $cols);

        $indexes = [self::COL_DATE];
        foreach ($indexes as $idx) {
            $db->addIndex(self::NAME, $idx);
        }
    }

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