M230911020254QimallWechatSendMessageLog.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230911020254QimallWechatSendMessageLog
  6. */
  7. class M230911020254QimallWechatSendMessageLog extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_wechat_send_message_log';
  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="
  20. CREATE TABLE `qimall_wechat_send_message_log` (
  21. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  22. `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
  23. `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
  24. `openid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'openid',
  25. `send_data` text COMMENT '发送参数',
  26. `result_data` text COMMENT '返回参数',
  27. `updated_at` int(11) NOT NULL DEFAULT '0',
  28. `created_at` int(11) NOT NULL DEFAULT '0',
  29. PRIMARY KEY (`id`) USING BTREE
  30. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='公众号发送模板消息日志';
  31. ";
  32. $this->execute($sql);
  33. }catch (\Exception $e){
  34. }
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M230911020254QimallWechatSendMessageLog 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 "M230911020254QimallWechatSendMessageLog cannot be reverted.\n";
  52. return false;
  53. }
  54. */
  55. }