| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace addons\GroupBuy\console\migrations;
- use Yii;
- use yii\db\Migration;
- /**
- * 添加拼团活动表-参团限制次数字段 restrict_rule_num
- * Class M250828144953AddGroupBuyActive
- */
- class M250828144953AddGroupBuyActive extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- if (!$this->columnExists('qimall_addons_group_buy_active', 'restrict_rule_num')) {
- $sql = <<<SQL
- ALTER TABLE `qimall_addons_group_buy_active` ADD COLUMN `restrict_rule_num` int(11) NOT NULL DEFAULT 0 COMMENT '参团限制次数';
- SQL;
- $this->execute($sql);
- }
- }catch (\Exception $e) {}
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- return false;
- }
- protected function columnExists($tableName, $columnName)
- {
- $tableSchema = Yii::$app->db->getTableSchema($tableName, true);
- return $tableSchema && in_array($columnName, $tableSchema->columnNames);
- }
- }
|