|
1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
-
- use common\helpers\Password;
- use domain\Producer\Producer\ProducerBuilder;
- use domain\Producer\Producer\ProducerRepository;
- use yii\db\Migration;
- use yii\db\Schema;
-
- /**
- * Class m240613_070747_add_columns_producer_sponsorship
- */
- class m240613_070747_add_columns_producer_sponsorship extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $this->addColumn('producer', 'sponsorship_code', Schema::TYPE_STRING);
- $this->addColumn('producer', 'sponsored_by', Schema::TYPE_INTEGER);
- $this->addColumn('producer', 'sponsorship_sponsor_reward', Schema::TYPE_BOOLEAN);
- $this->addColumn('producer', 'sponsorship_godson_reward', Schema::TYPE_BOOLEAN);
-
- $producersArray = ProducerRepository::getInstance()->findAll();
- foreach($producersArray as $producer) {
- ProducerBuilder::getInstance()->initSponsorshipCode($producer);
- $producer->save();
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- $this->dropColumn('producer', 'sponsorship_code');
- $this->dropColumn('producer', 'sponsored_by');
- $this->dropColumn('producer', 'sponsorship_sponsor_reward');
- $this->dropColumn('producer', 'sponsorship_godson_reward');
- }
- }
|