Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 KB | None | 0 0
  1.     private $tableName = '{{%full_pcs}}';
  2.  
  3.     private $Processors    = '{{%component_processors}}';
  4.     private $Motherboards  = '{{%component_motherboards}}';
  5.     private $VideoCards    = '{{%component_video_cards}}';
  6.     private $RamModules    = '{{%component_ram_modules}}';
  7.     private $Coolers       = '{{%component_coolers}}';
  8.     private $PowerSupplies = '{{%component_power_supplies}}';
  9.     private $Cases         = '{{%component_cases}}';
  10.     private $HDDs          = '{{%component_hdds}}';
  11.     private $SSDs          = '{{%component_ssds}}';
  12.     private $AudioCards    = '{{%component_audio_cards}}';
  13.  
  14.     public function safeUp()
  15.     {
  16.         $tableOptions = null;
  17.         if ($this->db->driverName === 'mysql') {
  18.             // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
  19.             $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
  20.         }
  21.  
  22.         $this->createTable($this->tableName, [
  23.             'id'             => $this->primaryKey(),
  24.             'processor_id'   => $this->integer()->notNull(),
  25.             'motherboard_id' => $this->integer()->notNull(),
  26.             'video_cards'    => $this->integer()->notNull(),
  27.             'ram_modules'    => $this->integer()->notNull(),
  28.             'case_id'        => $this->integer()->notNull(),
  29.             'hdds'           => $this->integer(),
  30.             'ssds'           => $this->integer(),
  31.             'audio_card_id'  => $this->integer(),
  32.             'accessories'    => $this->integer(),
  33.  
  34.             'created_at' => $this->integer(),
  35.             'updated_at' => $this->integer(),
  36.         ], $tableOptions);
  37.  
  38.         $fkName = 'fk-full_pcs-processor_id-processors-id';
  39.         $this->addForeignKey($fkName, $this->tableName, 'processor_id', $this->Processors, 'id', 'CASCADE', 'CASCADE');
  40.         $fkName = 'fk-full_pcs-motherboard_id-motherboards-id';
  41.         $this->addForeignKey($fkName, $this->tableName, 'motherboard_id', $this->Motherboards, 'id', 'CASCADE', 'CASCADE');
  42.         $fkName = 'fk-full_pcs-case_id-cases-id';
  43.         $this->addForeignKey($fkName, $this->tableName, 'case_id', $this->Cases, 'id', 'CASCADE', 'CASCADE');
  44.  
  45.         $this->addPrimaryKey('pk-video_cards_id', $this->tableName, ['']);
  46.     }
  47.  
  48.     public function safeDown()
  49.     {
  50.         $this->dropTable($this->tableName);
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement