Files
x-server-mobile/backend/migrations/20250226_create_feishu_login_session_table.php
T

31 lines
1.3 KiB
PHP
Raw Normal View History

2026-02-26 09:58:19 +08:00
<?php
use support\Db;
return new class
{
public function up(): void
{
Db::statement('
CREATE TABLE IF NOT EXISTS `feishu_login_session` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`company_id` bigint unsigned NOT NULL COMMENT '公司ID',
`tenant_key` varchar(64) NOT NULL COMMENT '租户密钥',
`status` varchar(20) NOT NULL DEFAULT \'pending\' COMMENT \'pending: 待扫码, scanning: 已扫码待授权, success: 登录成功, expired: 已过期\'',
`user_id` bigint unsigned DEFAULT NULL COMMENT \'用户ID(登录成功后填充)\'',
`expires_at` datetime NOT NULL COMMENT \'过期时间\'',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_company_status` (`company_id`, `status`),
KEY `idx_expires_at` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT=\'飞书扫码登录会话表\'
');
}
public function down(): void
{
Db::statement('DROP TABLE IF EXISTS `feishu_login_session`');
}
};