portal.mkgtu.ru/common/migrations/db/m140709_173333_widget_text.php

33 lines
995 B
PHP
Raw Permalink Normal View History

2024-03-28 09:51:45 +03:00
<?php
use common\components\Migration\MigrationWithDefaultOptions;
class m140709_173333_widget_text extends MigrationWithDefaultOptions
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%widget_text}}', [
'id' => $this->primaryKey(),
'key' => $this->string()->notNull(),
'title' => $this->string()->notNull(),
'body' => $this->text()->notNull(),
'status' => $this->smallInteger(),
'created_at' => $this->integer(),
'updated_at' => $this->integer(),
], $tableOptions);
$this->createIndex('idx_widget_text_key', '{{%widget_text}}', 'key');
}
public function down()
{
$this->dropIndex('idx_widget_text_key', '{{%widget_text}}');
$this->dropTable('{{%widget_text}}');
}
}