M221110032022AddQimallAddonsStoreMiniCode.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M221110032022AddQimallAddonsStoreMiniCode
  6. */
  7. class M221110032022AddQimallAddonsStoreMiniCode extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_addons_store_mini_code';
  16. $sql = "select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. $res = $this->db->createCommand($sql)->execute();
  18. if (!empty($res)) return '';
  19. $sql = "CREATE TABLE `qimall_addons_store_mini_code` (
  20. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  21. `mall_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
  22. `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店id',
  23. `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1:推广码;2:收银台二维码',
  24. `code` varchar(255) NOT NULL DEFAULT '' COMMENT '分享码',
  25. `content` varchar(255) NOT NULL DEFAULT '' COMMENT '二维码参数',
  26. `applet_code` varchar(255) DEFAULT '' COMMENT '小程序二维码图片地址',
  27. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态【1启用 0禁用 -1删除】',
  28. `created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
  29. `updated_at` int(10) NOT NULL DEFAULT '0' COMMENT '上次更新数据时间',
  30. PRIMARY KEY (`id`) USING BTREE
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='门店小程序码生成表';";
  32. $this->execute($sql);
  33. } catch (\Exception $e) {
  34. }
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M221110032022AddQimallAddonsStoreMiniCode cannot be reverted.\n";
  42. return false;
  43. }
  44. /*
  45. // Use up()/down() to run migration code without a transaction.
  46. public function up()
  47. {
  48. }
  49. public function down()
  50. {
  51. echo "M221110032022AddQimallAddonsStoreMiniCode cannot be reverted.\n";
  52. return false;
  53. }
  54. */
  55. }