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.

42 satır
1.3KB

  1. <?php
  2. use common\helpers\Password;
  3. use domain\Producer\Producer\ProducerBuilder;
  4. use domain\Producer\Producer\ProducerRepository;
  5. use yii\db\Migration;
  6. use yii\db\Schema;
  7. /**
  8. * Class m240613_070747_add_columns_producer_sponsorship
  9. */
  10. class m240613_070747_add_columns_producer_sponsorship extends Migration
  11. {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function safeUp()
  16. {
  17. $this->addColumn('producer', 'sponsorship_code', Schema::TYPE_STRING);
  18. $this->addColumn('producer', 'sponsored_by', Schema::TYPE_INTEGER);
  19. $this->addColumn('producer', 'sponsorship_sponsor_reward', Schema::TYPE_BOOLEAN);
  20. $this->addColumn('producer', 'sponsorship_godson_reward', Schema::TYPE_BOOLEAN);
  21. $producersArray = ProducerRepository::getInstance()->findAll();
  22. foreach($producersArray as $producer) {
  23. ProducerBuilder::getInstance()->initSponsorshipCode($producer);
  24. $producer->save();
  25. }
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function safeDown()
  31. {
  32. $this->dropColumn('producer', 'sponsorship_code');
  33. $this->dropColumn('producer', 'sponsored_by');
  34. $this->dropColumn('producer', 'sponsorship_sponsor_reward');
  35. $this->dropColumn('producer', 'sponsorship_godson_reward');
  36. }
  37. }