| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M230210075004AddComponentsToDiyComponents
- */
- class M230210075004AddComponentsToDiyComponents extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $list = $this->db->createCommand("select * from qimall_diy_components where id in (38,39,40,41) ")->queryAll();
- if($list && count($list) == 4) return true;
- $list = array_column($list,null,'id');
- if(!isset($list['38'])){
- $sql[] = 'INSERT INTO `qimall_diy_components` (`id`, `code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES (\'38\', \'goods-coupon\', \'领券信息\', \'goods\', \'\', \'1\', \'0\', \'{\"is_drag\":\"false\",\"is_up\":\"false\",\"id_down\":\"false\",\"is_copy\":\"false\"}\', \'999\', \'\', \'1\', \'1634538238\', \'1634538238\');
- ';
- }
- if(!isset($list['39'])) {
- $sql[] = 'INSERT INTO `qimall_diy_components` (`id`, `code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES (\'39\', \'goods-stock\', \'库存\', \'goods\', \'\', \'1\', \'0\', \'{\"is_drag\":\"false\",\"is_up\":\"false\",\"id_down\":\"false\",\"is_copy\":\"false\"}\', \'999\', \'\', \'1\', \'1634538238\', \'1634538238\');
- ';
- }
- if(!isset($list['40'])) {
- $sql[] = 'INSERT INTO `qimall_diy_components` (`id`, `code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES (\'40\', \'goods-service\', \'服务\', \'goods\', \'\', \'1\', \'0\', \'{\"is_drag\":\"false\",\"is_up\":\"false\",\"id_down\":\"false\",\"is_copy\":\"false\"}\', \'999\', \'\', \'1\', \'1634538238\', \'1634538238\');
- ';
- }
- if(!isset($list['41'])) {
- $sql[] = 'INSERT INTO `qimall_diy_components` (`id`, `code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES (\'41\', \'goods-attr\', \'规格\', \'goods\', \'\', \'1\', \'0\', \'{\"is_drag\":\"false\",\"is_up\":\"false\",\"id_down\":\"false\",\"is_copy\":\"false\"}\', \'999\', \'\', \'1\', \'1634538238\', \'1634538238\');
- ';
- }
- $sql = implode(' ',$sql);
- $this->execute($sql);
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230210075004AddComponentsToDiyComponents cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230210075004AddComponentsToDiyComponents cannot be reverted.\n";
- return false;
- }
- */
- }
|