芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal-back/vendor/yiisoft/yii2/log/migrations/m141106_185632_log_init.php
* @since 2.0.1 */ class m141106_185632_log_init extends Migration { /** * @var DbTarget[] Targets to create log table for */ private $dbTargets = []; /** * @throws InvalidConfigException * @return DbTarget[] */ protected function getDbTargets() { if ($this->dbTargets === []) { $log = Yii::$app->getLog(); $usedTargets = []; foreach ($log->targets as $target) { if ($target instanceof DbTarget) { $currentTarget = [ $target->db, $target->logTable, ]; if (!in_array($currentTarget, $usedTargets, true)) { // do not create same table twice $usedTargets[] = $currentTarget; $this->dbTargets[] = $target; } } } if ($this->dbTargets === []) { throw new InvalidConfigException('You should configure "log" component to use one or more database targets before executing this migration.'); } } return $this->dbTargets; } public function up() { foreach ($this->getDbTargets() as $target) { $this->db = $target->db; $tableOptions = null; if ($this->db->driverName === 'mysql') { // https://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($target->logTable, [ 'id' => $this->bigPrimaryKey(), 'level' => $this->integer(), 'category' => $this->string(), 'log_time' => $this->double(), 'prefix' => $this->text(), 'message' => $this->text(), ], $tableOptions); $this->createIndex('idx_log_level', $target->logTable, 'level'); $this->createIndex('idx_log_category', $target->logTable, 'category'); } } public function down() { foreach ($this->getDbTargets() as $target) { $this->db = $target->db; $this->dropTable($target->logTable); } } }