<?php

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

class m150926_123638_add__table__city extends Migration
{
    public function up()
    {
    	$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('{{%city}}', [
    			'id_city' => $this->primaryKey(),
    			'zip' => $this->string(8)->notNull(),
    			'name' => $this->string(64)->notNull(),
    			'city_code' => $this->string(2)->notNull(),
    			'latitude' => $this->float(),
    			'longitude' => $this->float() ,
    			'cso_code' => $this->integer(11) ,
    			'rig_id' => $this->integer(11) ,
    			'range' => $this->float() ,
    			'population' =>$this->integer(11) ,
    			'homes' =>  $this->integer(11) ,
    	], $tableOptions);
    }

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

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    id_city
zip
name
city_code
latitude
longitude
cso_code
rig_id
cit_range
population
homes
    }

    public function safeDown()
    {
    }
    */
}
