| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace addons\Store\console\migrations;
- use yii\db\Migration;
- /**
- * Class M250909101813AlterQimallStoreSettings.php
- */
- class M250909101813AlterQimallStoreSettings extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- if(!$this->columnExists('qimall_addons_store_settings', 'store_service_fee_settle_type')) {
- $sql = "ALTER TABLE `qimall_addons_store_settings` ADD COLUMN `store_service_fee_settle_type` tinyint(2) NOT NULL DEFAULT 1 COMMENT '服务费计算方式 1按订单实付金额 2按商品售价计算 3按商品成本价计算';";
- $this->execute($sql);
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M250909101813AlterQimallStoreSettings.php cannot be reverted.\n";
- return false;
- }
- protected function columnExists($tableName, $columnName)
- {
- $tableSchema = \Yii::$app->db->getTableSchema($tableName, true);
- return $tableSchema && in_array($columnName, $tableSchema->columnNames);
- }
- }
|