Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

m240613_070747_add_columns_producer_sponsorship.php 1.3KB

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