Skip to content

Instantly share code, notes, and snippets.

@martins-giberts
Last active May 19, 2017 09:19
Show Gist options
  • Save martins-giberts/ec5c194c99de488a43945208ce03ad5d to your computer and use it in GitHub Desktop.
Save martins-giberts/ec5c194c99de488a43945208ce03ad5d to your computer and use it in GitHub Desktop.
Migration file for SeoText localization
<?php
use yii\db\Migration;
use yii\db\Schema;
use app\modules\admin\models\SeoText;
class add_seo_localization extends Migration
{
public $engine = 'ENGINE=MyISAM DEFAULT CHARSET=utf8';
public $table_name = 'easyii_seotext_lang';
public function up() {
$this->createTable($this->table_name, [
'id' => 'pk',
'parent_id' => Schema::TYPE_INTEGER,
'language' => Schema::TYPE_STRING . '(6) NOT NULL',
'h1' => Schema::TYPE_STRING . '(255) NOT NULL',
'title' => Schema::TYPE_STRING . '(255) NOT NULL',
'keywords' => Schema::TYPE_STRING . '(255) NOT NULL',
'description' => Schema::TYPE_TEXT . ' DEFAULT NULL',
], $this->engine);
$this->createIndex('parent_id', $this->table_name, 'parent_id');
$this->createIndex('language', $this->table_name, 'language');
$this->dropColumn(SeoText::tableName(), 'h1');
$this->dropColumn(SeoText::tableName(), 'title');
$this->dropColumn(SeoText::tableName(), 'keywords');
$this->dropColumn(SeoText::tableName(), 'description');
}
public function down() {
$this->dropTable($this->table_name);
$this->addColumn(SeoText::tableName(), 'h1', Schema::TYPE_STRING . '(255) NOT NULL');
$this->addColumn(SeoText::tableName(), 'title', Schema::TYPE_STRING . '(255) NOT NULL');
$this->addColumn(SeoText::tableName(), 'keywords', Schema::TYPE_STRING . '(255) NOT NULL');
$this->addColumn(SeoText::tableName(), 'description', Schema::TYPE_TEXT . ' DEFAULT NULL');
}
}
@martins-giberts
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment