M240108112144AddReportTable.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240108112144AddReportTable
  6. */
  7. class M240108112144AddReportTable extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $sql="CREATE TABLE `qimall_report` (
  16. `id` int(10) NOT NULL AUTO_INCREMENT,
  17. `mall_id` int(10) NOT NULL,
  18. `from` varchar(64) NOT NULL COMMENT '举报来源',
  19. `report_id` int(10) NOT NULL COMMENT '举报ID',
  20. `type` int(10) NOT NULL COMMENT '举报类型',
  21. `content` varchar(255) NOT NULL COMMENT '额外内容',
  22. `updated_at` int(10) DEFAULT NULL,
  23. `created_at` int(10) DEFAULT NULL,
  24. PRIMARY KEY (`id`),
  25. KEY `mall_id` (`mall_id`),
  26. KEY `report_id` (`report_id`)
  27. ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4;";
  28. $this->execute($sql);
  29. }catch (\Exception $e){
  30. }
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function safeDown()
  36. {
  37. echo "M240108112144AddReportTable cannot be reverted.\n";
  38. return false;
  39. }
  40. /*
  41. // Use up()/down() to run migration code without a transaction.
  42. public function up()
  43. {
  44. }
  45. public function down()
  46. {
  47. echo "M240108112144AddReportTable cannot be reverted.\n";
  48. return false;
  49. }
  50. */
  51. }