Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
systems:yii2:migrations [2018/04/19 09:50]
smayr [Update]
systems:yii2:migrations [2018/04/19 10:07] (current)
smayr [New Notation]
Line 267: Line 267:
 class m160601_220000_skeleton extends Migration class m160601_220000_skeleton extends Migration
 { {
 +    private $useExtendedUserProfile = false;  // set it to your needs
 +    
     public function up()     public function up()
     {     {
         // Create tables with foreign keys last         // Create tables with foreign keys last
-        $this->alter_user_table(); 
         $this->create_table_entry();         $this->create_table_entry();
         $this->create_table_product_hash();         $this->create_table_product_hash();
 +
 +        if ($this->useExtendedUserProfile) {
 +            $this->alter_user_table();
 +        }
     }     }
  
Line 312: Line 317:
             }             }
                          
-            // Restore any original table changes +            if ($this->useExtendedUserProfile) { 
-            $this->restore_user_table();+                // Restore any original table changes 
 +                $this->restore_user_table(); 
 +            }
         }         }
     }     }
Line 327: Line 334:
         // $this->addColumn('{{%user}}', 'company_name', $this->string());         // $this->addColumn('{{%user}}', 'company_name', $this->string());
         // $this->addColumn('{{%user}}', 'organization_name', $this->string());         // $this->addColumn('{{%user}}', 'organization_name', $this->string());
-        $this->addColumn('{{%user}}', 'school_name', $this->string());+        // $this->addColumn('{{%user}}', 'school_name', $this->string());
         // $this->addColumn('{{%user}}', 'job_title', $this->string());         // $this->addColumn('{{%user}}', 'job_title', $this->string());
-        $this->addColumn('{{%user}}', 'receive_newsletter', $this->tinyInteger()->notNull()->defaultValue(1);+        $this->addColumn('{{%user}}', 'receive_newsletter', $this->tinyInteger()->notNull()->defaultValue(1));
     }     }
          
Line 592: Line 599:
 foreach((new Query)->from('price')->each() as $price) { foreach((new Query)->from('price')->each() as $price) {
   // DELETE price WHERE reference_code = 'partUnknown', id = :price_id   // DELETE price WHERE reference_code = 'partUnknown', id = :price_id
-  $this->delete('price', ['reference_code' => 'partUnknown', 'id' => $price->id]);+  $this->delete('{{%price}}', ['reference_code' => 'partUnknown', 'id' => $price->id]);
 } }
 </code> </code>