Example #1
0
 /**
  * Module database install
  *
  */
 public function dbInstall()
 {
     $db = Yii::$app->db;
     $tableOptions = null;
     if ($db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM';
     }
     $db->createCommand()->createTable(SeoMeta::tableName(), ['id' => Schema::TYPE_INTEGER . '(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', 'label' => Schema::TYPE_STRING . '(255) DEFAULT NULL', 'type' => Schema::TYPE_STRING . '(25) DEFAULT "page"', 'url' => Schema::TYPE_STRING . '(255) DEFAULT NULL', 'params' => Schema::TYPE_STRING . '(255) DEFAULT NULL', 'route' => Schema::TYPE_STRING . '(255) DEFAULT NULL', 'tags' => Schema::TYPE_TEXT . ' DEFAULT NULL', 'robots' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'status' => 'TINYINT(1) UNSIGNED NOT NULL', 'updated_at' => Schema::TYPE_INTEGER . '(11) UNSIGNED DEFAULT NULL ', 'created_at' => Schema::TYPE_INTEGER . '(11) UNSIGNED DEFAULT NULL'], $tableOptions)->execute();
     $db->createCommand()->createIndex('idx_route', SeoMeta::tableName(), 'route', true)->execute();
     $db->createCommand()->createTable(SeoRedirects::tableName(), ['id' => Schema::TYPE_INTEGER . '(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', 'old_url' => Schema::TYPE_STRING . '(255) NOT NULL', 'new_url' => Schema::TYPE_STRING . '(255) NOT NULL DEFAULT "/"', 'updated_at' => Schema::TYPE_INTEGER . '(11) UNSIGNED DEFAULT NULL ', 'created_at' => Schema::TYPE_INTEGER . '(11) UNSIGNED DEFAULT NULL', 'status' => 'ENUM("301","302") NOT NULL DEFAULT "301"'], $tableOptions)->execute();
     $db->createCommand()->createIndex('idx_old_url', SeoRedirects::tableName(), 'old_url', true)->execute();
 }