Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private $tableName = '{{%full_pcs}}';
- private $Processors = '{{%component_processors}}';
- private $Motherboards = '{{%component_motherboards}}';
- private $VideoCards = '{{%component_video_cards}}';
- private $RamModules = '{{%component_ram_modules}}';
- private $Coolers = '{{%component_coolers}}';
- private $PowerSupplies = '{{%component_power_supplies}}';
- private $Cases = '{{%component_cases}}';
- private $HDDs = '{{%component_hdds}}';
- private $SSDs = '{{%component_ssds}}';
- private $AudioCards = '{{%component_audio_cards}}';
- public function safeUp()
- {
- $tableOptions = null;
- if ($this->db->driverName === 'mysql') {
- // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
- $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
- }
- $this->createTable($this->tableName, [
- 'id' => $this->primaryKey(),
- 'processor_id' => $this->integer()->notNull(),
- 'motherboard_id' => $this->integer()->notNull(),
- 'video_cards' => $this->integer()->notNull(),
- 'ram_modules' => $this->integer()->notNull(),
- 'case_id' => $this->integer()->notNull(),
- 'hdds' => $this->integer(),
- 'ssds' => $this->integer(),
- 'audio_card_id' => $this->integer(),
- 'accessories' => $this->integer(),
- 'created_at' => $this->integer(),
- 'updated_at' => $this->integer(),
- ], $tableOptions);
- $fkName = 'fk-full_pcs-processor_id-processors-id';
- $this->addForeignKey($fkName, $this->tableName, 'processor_id', $this->Processors, 'id', 'CASCADE', 'CASCADE');
- $fkName = 'fk-full_pcs-motherboard_id-motherboards-id';
- $this->addForeignKey($fkName, $this->tableName, 'motherboard_id', $this->Motherboards, 'id', 'CASCADE', 'CASCADE');
- $fkName = 'fk-full_pcs-case_id-cases-id';
- $this->addForeignKey($fkName, $this->tableName, 'case_id', $this->Cases, 'id', 'CASCADE', 'CASCADE');
- $this->addPrimaryKey('pk-video_cards_id', $this->tableName, ['']);
- }
- public function safeDown()
- {
- $this->dropTable($this->tableName);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement