File: /home/safarimaris/home/safarimaris/console/migrations/m161114_123308_country_descr.php
<?php
use yii\db\Migration;
class m161114_123308_country_descr extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%setting}}', [
'idx' => $this->primaryKey(),
'value' => $this->string()->notNull()
], $tableOptions);
$this->alterColumn('{{%setting}}', 'idx', $this->string());
$this->batchInsert('{{%setting}}', ['idx', 'value'], [
['rateEuro', '0,9210'],
['rateUah', '25,6350'],
['indexTitle1', 'Опытная команда и проверенные партнеры'],
['indexText1', 'За 9 лет нашей работы наши клиенты объездили весь мир. На основании большого потока свежих отзывов и собственных знаний мы тщательно отбираем принимающие стороны, анализируем и запоминаем все детали и нюансы путешествий.'],
['indexTitle2', 'Лучшая цена'],
['indexText2', 'Мы гарантируем лучшую цену на представленные туры как для дайверов, так и для организаторов групповых поездок: клубов и инструкторов'],
['indexTitle3', 'Сопровождении в туре 24/7'],
['indexText3', 'Мы всегда на связи с вами, и с принимающей стороной. Одна из самых важных сторон нашей работы - поддержка клиентов во время тура и помощь в решении любых сложных ситуациях.'],
['indexTitle4', 'Бесплатная медицинская поддержка DAN'],
['indexText4', 'Все клиенты Сафари Марис, которые отправляются на дайвинг-сафари, обеспечены бесплатной дайвинг-страховкой с медицинской поддержкой DAN']
]);
$this->addColumn('{{%country}}', 'descr', $this->string());
$this->addColumn('{{%tag}}', 'ordinal', $this->string());
$this->addColumn('{{%entity}}', 'price', $this->decimal(10, 2));
$this->createIndex('IDX_tag_ordinal', '{{%tag}}', 'ordinal, name');
$this->createIndex('IDX_country_ordinal', '{{%country}}', 'ordinal, name');
$this->createIndex('IDX_entity_ordinal', '{{%entity}}', 'ordinal, name');
$this->createIndex('IDX_region_ordinal', '{{%region}}', 'ordinal, name');
$this->createIndex('IDX_special_ordinal', '{{%special}}', 'ordinal, title');
}
public function down()
{
$this->dropTable('{{%setting}}');
$this->dropColumn('{{%country}}', 'descr');
$this->dropColumn('{{%tag}}', 'ordinal');
$this->dropColumn('{{%entity}}', 'price');
$this->dropIndex('IDX_tag_ordinal', '{{%tag}}');
$this->dropIndex('IDX_country_ordinal', '{{%country}}');
$this->dropIndex('IDX_entity_ordinal', '{{%entity}}');
$this->dropIndex('IDX_region_ordinal', '{{%region}}');
$this->dropIndex('IDX_special_ordinal', '{{%special}}');
}
}