| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M230329074638CreateQimallMemberLabel
- */
- class M230329074638CreateQimallMemberLabel extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- $table = 'qimall_member_label';
- $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if(!empty($res)) return '';
- $sql="CREATE TABLE `{$table}` (
- `id` int(10) NOT NULL AUTO_INCREMENT,
- `mall_id` int(10) NOT NULL DEFAULT '0' COMMENT '商城ID',
- `cate_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID',
- `name` varchar(45) NOT NULL DEFAULT '' COMMENT '名称',
- `label_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '标签类型:1:自动;2:手动',
- `user_num` int(10) NOT NULL DEFAULT '0' COMMENT '会员数量',
- `condition` text NOT NULL COMMENT '达标条件',
- `color` varchar(255) NOT NULL DEFAULT '' COMMENT '颜色',
- `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(10) NOT NULL DEFAULT '0',
- `updated_at` int(10) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `mall_id` (`mall_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员标签';";
- $this->execute($sql);
- } catch (\Exception $e) {
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230329074638CreateQimallMemberLabel cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230329074638CreateQimallMemberLabel cannot be reverted.\n";
- return false;
- }
- */
- }
|