您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

m231110_084013_create_tables_feature_flag.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Class m231110_084013_create_tables_feature_flag
  6. */
  7. class m231110_084013_create_tables_feature_flag extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $this->createTable('feature', [
  15. 'id' => 'pk',
  16. 'alias' => Schema::TYPE_STRING.' NOT NULL',
  17. 'name' => Schema::TYPE_STRING.' NOT NULL',
  18. 'description' => Schema::TYPE_TEXT,
  19. 'is_paid_feature' => Schema::TYPE_BOOLEAN,
  20. 'price' => Schema::TYPE_FLOAT,
  21. 'only_for_selected_producers' => Schema::TYPE_BOOLEAN,
  22. 'status' => Schema::TYPE_BOOLEAN.' DEFAULT 1',
  23. ]);
  24. $this->createTable('feature_producer', [
  25. 'id' => 'pk',
  26. 'id_producer' => Schema::TYPE_INTEGER.' NOT NULL',
  27. 'id_feature' => Schema::TYPE_INTEGER.' NOT NULL',
  28. 'status' => Schema::TYPE_BOOLEAN.' DEFAULT 1',
  29. ]);
  30. $this->addForeignKey('producer_fk', 'feature_producer', 'id_producer', 'producer', 'id');
  31. $this->addForeignKey('feature_fk', 'feature_producer', 'id_feature', 'feature', 'id');
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function safeDown()
  37. {
  38. $this->dropTable('feature');
  39. $this->dropTable('feature_producer');
  40. }
  41. }