m160721_151110_create_i18n_table.php 964 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. use yii\db\Schema;
  3. use yii\db\Migration;
  4. class m160721_151110_create_i18n_table extends Migration
  5. {
  6. public function up()
  7. {
  8. $tableOptions = null;
  9. if ($this->db->driverName === 'mysql') {
  10. $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
  11. }
  12. $this->createTable('{{%i18n_source_message}}', [
  13. 'id'=>$this->primaryKey(),
  14. 'category'=>$this->string(32),
  15. 'message'=>$this->text()
  16. ], $tableOptions);
  17. $this->createTable('{{%i18n_message}}', [
  18. 'id'=>$this->integer(),
  19. 'language'=>$this->string(16),
  20. 'translation'=>$this->text()
  21. ], $tableOptions);
  22. $this->addPrimaryKey('i18n_message_pk', '{{%i18n_message}}', ['id', 'language']);
  23. }
  24. public function down()
  25. {
  26. $this->dropTable('{{%i18n_message}}');
  27. $this->dropTable('{{%i18n_source_message}}');
  28. }
  29. }