M230531082246QimallCommonSyncLogs.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230531082246QimallGoodsServiceSyncLogs
  6. */
  7. class M230531082246QimallCommonSyncLogs extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_common_sync_logs';
  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_common_sync_logs` (
  20. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  21. `type` varchar(255) NOT NULL DEFAULT '' COMMENT '类型',
  22. `self_mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '自身商城ID',
  23. `source_mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '源商城ID',
  24. `type_id` int(11) NOT NULL DEFAULT '0' COMMENT '自身商城的类型id',
  25. `source_type_id` int(11) NOT NULL DEFAULT '0' COMMENT '源商城的的类型id',
  26. `created_at` bigint(20) NOT NULL DEFAULT '0',
  27. `updated_at` bigint(20) NOT NULL DEFAULT '0',
  28. PRIMARY KEY (`id`),
  29. KEY `idx_index` (`type`,`self_mall_id`,`source_mall_id`,`source_type_id`) USING BTREE
  30. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商城公共信息同步日志表';";
  31. $this->execute($sql);
  32. } catch (\Exception $e) {
  33. }
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function safeDown()
  39. {
  40. echo "M230531082246QimallGoodsServiceSyncLogs cannot be reverted.\n";
  41. return false;
  42. }
  43. /*
  44. // Use up()/down() to run migration code without a transaction.
  45. public function up()
  46. {
  47. }
  48. public function down()
  49. {
  50. echo "M230531082246QimallGoodsServiceSyncLogs cannot be reverted.\n";
  51. return false;
  52. }
  53. */
  54. }