| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M230525061728QimallGoodsAssociation
- */
- class M230525061728QimallGoodsAssociation extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- $table = 'qimall_goods_association';
- $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if(!empty($res)) return '';
- $sql="
- CREATE TABLE `qimall_goods_association` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
- `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品id',
- `extra1_goods_id` longtext COMMENT '关联配件商品id',
- `extra2_goods_id` longtext COMMENT '推荐商品商品id',
- `extra3_goods_id` longtext COMMENT '预留',
- `extra4_goods_id` longtext COMMENT '预留',
- `extra5_goods_id` longtext COMMENT '预留',
- `extra6_goods_id` longtext COMMENT '预留',
- `extra7_goods_id` longtext COMMENT '预留',
- `extra8_goods_id` longtext COMMENT '预留',
- `extra9_goods_id` longtext COMMENT '预留',
- `extra10_goods_id` longtext COMMENT '预留',
- `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` bigint(20) NOT NULL DEFAULT '0',
- `updated_at` bigint(20) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_goods_id` (`goods_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='关联商品';
- ";
- $this->execute($sql);
- }catch (\Exception $e){
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230525061728QimallGoodsAssociation cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230525061728QimallGoodsAssociation cannot be reverted.\n";
- return false;
- }
- */
- }
|