Browse Source

Migration : ajout du produit "Don"

dev
Guillaume Bourgeois 5 years ago
parent
commit
9ef8eb2236
2 changed files with 50 additions and 0 deletions
  1. +33
    -0
      console/migrations/m190205_160337_produit_don_distrib.php
  2. +17
    -0
      console/migrations/m190205_164612_ajout_produit_don_aux_distributions_existantes.php

+ 33
- 0
console/migrations/m190205_160337_produit_don_distrib.php View File

@@ -0,0 +1,33 @@
<?php

use yii\db\Migration;

class m190205_160337_produit_don_distrib extends Migration {

public function up() {
$this->insert('product', [
'name' => 'Don',
'description' => 'Don à la plateforme distrib',
'recipe' => '',
'active' => 1,
'photo' => null,
'price' => 1,
'weight' => null,
'monday' => 1,
'tuesday' => 1,
'wednesday' => 1,
'thursday' => 1,
'friday' => 1,
'saturday' => 1,
'sunday' => 1,
'quantity_max' => null,
'id_producer' => 0,
'sale_mode' => 'unit',
'order' => 1000,
]) ;
}

public function down() {
$this->delete('product', 'name = \'Don\' AND id_producer = 0') ;
}
}

+ 17
- 0
console/migrations/m190205_164612_ajout_produit_don_aux_distributions_existantes.php View File

@@ -0,0 +1,17 @@
<?php

use yii\db\Migration;

class m190205_164612_ajout_produit_don_aux_distributions_existantes extends Migration {

public function up() {
$distributionsArray = common\models\Distribution::find()->all() ;
foreach($distributionsArray as $distribution) {
$distribution->linkProductGift() ;
}
}

public function down() {
}
}

Loading…
Cancel
Save