You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3KB

  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. }