<?php

use yii\db\Schema;
use yii\db\Migration;

class m160215_063205_create__table__terminal__and__terminal_tipus extends Migration
{
    public function up()
    {
		$sql = "CREATE TABLE IF NOT EXISTS `terminal` (
		  `TerminalNumber` int(10) DEFAULT NULL,
		  `TerminalID` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `Type` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `WorkTime` bit(1) DEFAULT NULL,
		  `Name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `IP` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `LastConnection` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `LastEvent` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `LastEventTime` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `StatusTOCounter` int(10) DEFAULT '0',
		  `DirectionInName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `DirectionInZone` char(10) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `DirectionInColor` varchar(50) COLLATE utf8_unicode_ci DEFAULT 'vbGreen',
		  `DirectionOutName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `DirectionOutZone` char(10) COLLATE utf8_unicode_ci DEFAULT NULL,
		  `DirectionOutColor` varchar(50) COLLATE utf8_unicode_ci DEFAULT 'vbPink'
		) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
		
		$this->execute($sql);
		
		
		$sql = "DELETE FROM `terminal`;";
		$this->execute($sql);
		
		$sql = "INSERT INTO `terminal` (`TerminalNumber`, `TerminalID`, `Type`, `WorkTime`, `Name`, `IP`, `LastConnection`, `LastEvent`, `LastEventTime`, `StatusTOCounter`, `DirectionInName`, `DirectionInZone`, `DirectionInColor`, `DirectionOutName`, `DirectionOutZone`, `DirectionOutColor`) VALUES
			(1, '01', 'Forgóvilla', b'0', 'Bejárat', '', '', '', NULL, 0, 'Fitness', '1', 'vbGreen', 'Kint', '0', 'vbPink');";
		$this->execute($sql);
		
	
		$sql = "CREATE TABLE IF NOT EXISTS `term_tipus` (
			  `tipus` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL
			) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
		$this->execute($sql);
		
		$sql = "DELETE FROM `term_tipus`;";
		$this->execute($sql);
		
		$sql = "INSERT INTO `term_tipus` (`tipus`) VALUES ('Forgóvilla');";
		$this->execute($sql);
		
    }

    public function down()
    {
        echo "m160215_063205_create__table__terminal__and__terminal_tipus cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
