2023071000-drop_temp_tables.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. declare(strict_types=1);
  3. use App\Interfaces\MigrationInterface;
  4. use App\Services\DB;
  5. return new class() implements MigrationInterface {
  6. public function up(): int
  7. {
  8. DB::getPdo()->exec('
  9. DROP TABLE IF EXISTS `email_verify`;
  10. DROP TABLE IF EXISTS `user_password_reset`;
  11. DROP TABLE IF EXISTS `telegram_session`;
  12. ');
  13. return 2023071000;
  14. }
  15. public function down(): int
  16. {
  17. DB::getPdo()->exec(
  18. "CREATE TABLE IF NOT EXISTS `email_verify` (
  19. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  20. `email` varchar(255) NOT NULL DEFAULT '' COMMENT '邮箱',
  21. `ip` varchar(255) NOT NULL DEFAULT '' COMMENT 'IP',
  22. `code` varchar(255) NOT NULL DEFAULT '' COMMENT '验证码',
  23. `expire_in` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '过期时间',
  24. PRIMARY KEY (`id`)
  25. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  26. CREATE TABLE IF NOT EXISTS `telegram_session` (
  27. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  28. `user_id` bigint(20) DEFAULT NULL,
  29. `type` int(11) DEFAULT NULL,
  30. `session_content` varchar(255) DEFAULT NULL,
  31. `datetime` bigint(20) DEFAULT NULL,
  32. PRIMARY KEY (`id`)
  33. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  34. CREATE TABLE IF NOT EXISTS `user_password_reset` (
  35. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  36. `email` varchar(255) NOT NULL DEFAULT '' COMMENT '用户邮箱',
  37. `token` varchar(255) NOT NULL DEFAULT '' COMMENT '重置密码的 token',
  38. `init_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  39. `expire_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '过期时间',
  40. PRIMARY KEY (`id`),
  41. KEY `email` (`email`),
  42. KEY `token` (`token`)
  43. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
  44. );
  45. return 2023063000;
  46. }
  47. };