M240206104540AddTableUserReport.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240206104540AddTableUserReport
  6. */
  7. class M240206104540AddTableUserReport extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $sql = "
  16. CREATE TABLE `qimall_user_report` (
  17. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  18. `mall_id` int(10) NOT NULL COMMENT 'Mall Id',
  19. `user_id` int(10) NOT NULL COMMENT '会员ID',
  20. `title` varchar(255) NOT NULL COMMENT '举报标题',
  21. `content` longtext COMMENT '举报内容',
  22. `created_at` int(10) DEFAULT '0',
  23. `updated_at` int(10) DEFAULT '0',
  24. PRIMARY KEY (`id`),
  25. KEY `mall_id` (`mall_id`),
  26. KEY `user_id` (`user_id`)
  27. ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='用户举报表'";
  28. $this->execute($sql);
  29. } catch (\Exception $e) {
  30. }
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function safeDown()
  36. {
  37. echo "M240206104540AddTableUserReport 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 "M240206104540AddTableUserReport cannot be reverted.\n";
  48. return false;
  49. }
  50. */
  51. }