M240824024304QimallUserDelLog.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240824024304QimallUserDelLog
  6. */
  7. class M240824024304QimallUserDelLog extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_user_del_log';
  15. $sql = "select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  16. $res = $this->db->createCommand($sql)->execute();
  17. if (!empty($res)) return '';
  18. $sql = "
  19. CREATE TABLE `qimall_user_del_log` (
  20. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(11) NOT NULL,
  22. `user_id` int(11) NOT NULL,
  23. `new_mobile` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  24. `old_mobile` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  25. `status` int(11) NOT NULL DEFAULT '1',
  26. `created_at` bigint(20) DEFAULT '0' COMMENT '添加时间戳',
  27. `updated_at` bigint(20) DEFAULT '0' COMMENT '更新时间戳',
  28. PRIMARY KEY (`id`),
  29. KEY `index_mall_id` (`mall_id`),
  30. KEY `index_user_id` (`user_id`)
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户删除记录';
  32. ";
  33. $this->execute($sql);
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function safeDown()
  39. {
  40. echo "M240824024304QimallUserDelLog 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 "M240824024304QimallUserDelLog cannot be reverted.\n";
  51. return false;
  52. }
  53. */
  54. }