<?php

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

class m160129_072601_add__tables__detsta_message extends Migration
{

     public function up()
    {
    
    	$this->addMessage();
    	$this->addMessageFej();
     	$this->addMessageLab();
     	$this->addMessageTetel();
    	
    }
    
    protected function addMessage(){
    	$tableOptions = null;
    	if ($this->db->driverName === 'mysql') {
    		// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
    		$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
    	}
    	 
    	$this->createTable('{{%message_detsta}}', [
    			'id_message' => $this->primaryKey(),
    			'path' => $this->string(255),
    			'id_user' => $this->integer(11),
    			'created_at' => $this->dateTime()->notNull(),
    			'updated_at' => $this->dateTime()->notNull(),
    	], $tableOptions);
    }
    protected function addMessageFej(){
    	$tableOptions = null;
    	if ($this->db->driverName === 'mysql') {
    		// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
    		$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
    	}
    	 
    	$this->createTable('{{%message_detsta_fej}}', [
    			'id_message_detsta_fej' => $this->primaryKey(),
    			'id_message' => $this->integer(11),
    			'record_tipus' => $this->string(10),
    			'uzenet_tipus' => $this->string(10),
    			'jelentes_jelzo' => $this->string(10),
    			'kezdemenyezo_azonosito' => $this->string(20),
    			'csoportos_uzenet_sorszam' => $this->integer(11),
    			'csoportos_uzenet_datum' => $this->dateTime(),
    			'detsta_uzenet_sorszam' => $this->integer(11),
    			'detsta_uzenet_datum' => $this->dateTime(),
    			'ido' => $this->string(10),
    	], $tableOptions);
    }
    protected function addMessageLab(){
    	$tableOptions = null;
    	if ($this->db->driverName === 'mysql') {
    		// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
    		$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
    	}
    	 
    	$this->createTable('{{%message_detsta_lab}}', [
    			'id_message_detsta_lab' => $this->primaryKey(),
    			'id_message' => $this->integer(11),
    			'record_tipus' => $this->string(10),
    			'teljesitett_tetelek_szama' => $this->integer(11),
    			'teljesitett_tetelek_osszerteke' => $this->integer(11),
    			'visszautasitott_tetelek_szama' => $this->integer(11),
    			'visszautasitott_tetelek_osszerteke' => $this->integer(11),
    			'megnemvalaszolt_tetelek_szama' => $this->integer(11),
    			'megnemvalaszolt_tetelek_osszerteke' => $this->integer(11),
    	], $tableOptions);
    }
    protected function addMessageTetel(){
    	$tableOptions = null;
    	if ($this->db->driverName === 'mysql') {
    		// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
    		$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
    	}
    	 
    	$this->createTable('{{%message_detsta_tetel}}', [
    			'id_message_detsta_tetel' => $this->primaryKey(),
    			'id_message' => $this->integer(11),
    			'id_ticket_installment_request' => $this->integer(11),
    			'record_tipus' => $this->string(10),
    			'tetel_sorszam' => $this->integer(11),
    			'osszeg' => $this->integer(11),
    			'eredeti_tetel_elszamolasi_datuma' => $this->dateTime(),
    			'visszajelzes_informacio' => $this->string(10),
    			'feldolgozas_datum' => $this->dateTime(),
    			'terhelesi_datum' => $this->dateTime(),
    			'valasz_hivatkozasi_kod' => $this->string(50),
    			'eredeti_hivatkozasi_kod' => $this->string(50),
    			'ugyfel_azonosito' => $this->string(50),
    	], $tableOptions);
    }
    

    public function down()
    {
    }

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

    public function safeDown()
    {
    }
    */
}
