<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateValueSetTable extends Migration {
  public function up() {
    
    $this->forge->addField([
      'VID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
      'SiteID' => ['type' => 'INT', 'null' => true],
      'VSetID' => ['type' => 'INT', 'null' => true],
      'VOrder' => ['type' => 'INT', 'null' => true],
      'VValue' => ['type' => 'varchar', 'constraint' => 10],
      'VDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
      'VCategory' => ['type' => 'int', 'null' => true],
      'CreateDate' => ['type' => 'Datetime', 'null' => true],
      'EndDate' => ['type' => 'DATETIME', 'null' => true]
    ]);
    $this->forge->addKey('VID', true);
    $this->forge->createTable('valueset');

    $this->forge->addField([
      'VSetID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
      'SiteID'  => ['type' => 'INT', 'null' => true],
      'VSName' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
      'VSDesc' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
      'CreateDate' => ['type' => 'Datetime', 'null' => true],
      'EndDate' => ['type' => 'DATETIME', 'null' => true]
    ]);
    $this->forge->addKey('VSetID', true);
    $this->forge->createTable('valuesetdef');
  }

  public function down() {
    $this->forge->dropTable('valueset');
    $this->forge->dropTable('valuesetdef');
  }

}