M230204032343CreateImportLogTable.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230204032343CreateImportLogTable
  6. */
  7. class M230204032343CreateImportLogTable extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $log_sql = "CREATE TABLE `qimall_import_log` (
  15. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  16. `mall_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
  17. `source` varchar(255) NOT NULL DEFAULT '' COMMENT '来源',
  18. `upload_file` varchar(255) NOT NULL DEFAULT '' COMMENT '上传文件存在路径',
  19. `counts` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '导入数量',
  20. `success_counts` smallint(6) unsigned NOT NULL DEFAULT '6' COMMENT '导入成功数量',
  21. `fail_counts` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '导入失败数量',
  22. `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态:1:导入成功;2导入失败;3:导入中;4:导入中断',
  23. `created_at` int(11) unsigned NOT NULL DEFAULT '0',
  24. `updated_at` int(11) unsigned NOT NULL DEFAULT '0',
  25. PRIMARY KEY (`id`)
  26. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
  27. $this->execute($log_sql);
  28. $log_fail_sql = "CREATE TABLE `qimall_import_fail_log` (
  29. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  30. `mall_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
  31. `import_log_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '导入批次id',
  32. `data_row_id` varchar(60) NOT NULL DEFAULT '' COMMENT '数据行标识',
  33. `reason` mediumtext NOT NULL COMMENT '失败原因',
  34. `extra` text COMMENT '导入的内容',
  35. `created_at` int(11) unsigned NOT NULL DEFAULT '0',
  36. `updated_at` int(11) unsigned NOT NULL DEFAULT '0',
  37. PRIMARY KEY (`id`)
  38. ) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4;";
  39. $this->execute($log_fail_sql);
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function safeDown()
  45. {
  46. echo "M230204032343CreateImportLogTable cannot be reverted.\n";
  47. return false;
  48. }
  49. /*
  50. // Use up()/down() to run migration code without a transaction.
  51. public function up()
  52. {
  53. }
  54. public function down()
  55. {
  56. echo "M230204032343CreateImportLogTable cannot be reverted.\n";
  57. return false;
  58. }
  59. */
  60. }