<?php

namespace webuccino\install\migrations;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Capsule\Manager as Capsule;

class CreateScheduledTasksSendingLogTable
{
    public $table;
    public $prefix;
    public function __construct()
    {

        $this->prefix = config_native('srm_config.installer.table_prefix', 'srm_');

        $this->table = $this->prefix . 'scheduled_tasks_sending_log';
    }

    public function getTableName()
    {
        return $this->table;
    }

    public function run()
    {
        $prefix = $this->prefix;

        Capsule::schema()->create($this->table, function (Blueprint $table) use ($prefix) {
            $table->id('id');
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('ended_at')->nullable();
            $table->integer('scheduled_tasks_count')->nullable();
        });
    }
}
