addColumnIfNotExists( 'qimall_goods_extra', 'is_member_alone_buy_limit', Schema::TYPE_TINYINT . ' DEFAULT 0 COMMENT "是否会员指定等级每月限购数量"' ); $this->addColumnIfNotExists( 'qimall_goods_extra', 'member_alone_buy_limit_setting', Schema::TYPE_TEXT . ' COMMENT "会员指定等级每月限购数量设置"' ); } protected function addColumnIfNotExists($table, $column, $type) { $transaction = $this->db->beginTransaction(); try { $tableSchema = $this->db->getSchema()->getTableSchema($table); if ($tableSchema && !isset($tableSchema->columns[$column])) { $this->addColumn($table, $column, $type); $transaction->commit(); return true; } } catch (\Exception $e) { $transaction->rollback(); throw $e; } return false; } /** * {@inheritdoc} */ public function safeDown() { echo "M250822175613AlterQimalGoodsExtra.php cannot be reverted.\n"; return false; } /* // Use up()/down() to run migration code without a transaction. public function up() { } public function down() { echo "M250729084413AlterQimallAddonsStoreGoodsExtra cannot be reverted.\n"; return false; } */ }