能力表
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for abilities
-- ----------------------------
DROP TABLE IF EXISTS `abilities`;
CREATE TABLE `abilities` (
`group` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`model` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`channel_id` bigint NOT NULL,
`enabled` tinyint(1) DEFAULT NULL,
`priority` bigint DEFAULT '0',
`weight` bigint unsigned DEFAULT '0',
`tag` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`group`,`model`,`channel_id`),
KEY `idx_abilities_channel_id` (`channel_id`),
KEY `idx_abilities_priority` (`priority`),
KEY `idx_abilities_weight` (`weight`),
KEY `idx_abilities_tag` (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;渠道表
-- ----------------------------
-- Table structure for channels
-- ----------------------------
DROP TABLE IF EXISTS `channels`;
CREATE TABLE `channels` (
`id` bigint NOT NULL AUTO_INCREMENT,
`type` bigint DEFAULT '0',
`key` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`open_ai_organization` longtext COLLATE utf8mb4_unicode_ci,
`test_model` longtext COLLATE utf8mb4_unicode_ci,
`status` bigint DEFAULT '1',
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`weight` bigint unsigned DEFAULT '0',
`created_time` bigint DEFAULT NULL,
`test_time` bigint DEFAULT NULL,
`response_time` bigint DEFAULT NULL,
`base_url` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`other` longtext COLLATE utf8mb4_unicode_ci,
`balance` double DEFAULT NULL,
`balance_updated_time` bigint DEFAULT NULL,
`models` longtext COLLATE utf8mb4_unicode_ci,
`group` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT 'default',
`used_quota` bigint DEFAULT '0',
`model_mapping` text COLLATE utf8mb4_unicode_ci,
`status_code_mapping` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT '',
`priority` bigint DEFAULT '0',
`auto_ban` bigint DEFAULT '1',
`other_info` longtext COLLATE utf8mb4_unicode_ci,
`tag` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`setting` text COLLATE utf8mb4_unicode_ci,
`param_override` text COLLATE utf8mb4_unicode_ci,
`header_override` text COLLATE utf8mb4_unicode_ci,
`remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`channel_info` json DEFAULT NULL,
`settings` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
KEY `idx_channels_name` (`name`),
KEY `idx_channels_tag` (`tag`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
—
-- ----------------------------
-- Table structure for checkins
-- ----------------------------
DROP TABLE IF EXISTS `checkins`;
CREATE TABLE `checkins` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint NOT NULL,
`checkin_date` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`quota_awarded` bigint NOT NULL,
`created_at` bigint DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_user_checkin_date` (`user_id`,`checkin_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
OAuth提供商表
-- ----------------------------
-- Table structure for custom_oauth_providers
-- ----------------------------
DROP TABLE IF EXISTS `custom_oauth_providers`;
CREATE TABLE `custom_oauth_providers` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`slug` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`icon` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
`enabled` tinyint(1) DEFAULT '0',
`client_id` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`client_secret` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`authorization_endpoint` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`token_endpoint` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`user_info_endpoint` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`scopes` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT 'openid profile email',
`user_id_field` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT 'sub',
`username_field` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT 'preferred_username',
`display_name_field` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT 'name',
`email_field` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT 'email',
`well_known` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`auth_style` bigint DEFAULT '0',
`access_policy` text COLLATE utf8mb4_unicode_ci,
`access_denied_message` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`phone_field` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT 'phone',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_custom_oauth_providers_slug` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
日志表(使用量、充值记录、错误记录)
-- ----------------------------
-- Table structure for logs
-- ----------------------------
DROP TABLE IF EXISTS `logs`;
CREATE TABLE `logs` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`created_at` bigint DEFAULT NULL,
`type` bigint DEFAULT NULL,
`content` longtext COLLATE utf8mb4_unicode_ci,
`username` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`token_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`model_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`quota` bigint DEFAULT '0',
`prompt_tokens` bigint DEFAULT '0',
`completion_tokens` bigint DEFAULT '0',
`use_time` bigint DEFAULT '0',
`is_stream` tinyint(1) DEFAULT NULL,
`channel_id` bigint DEFAULT NULL,
`channel_name` longtext COLLATE utf8mb4_unicode_ci,
`token_id` bigint DEFAULT '0',
`group` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`ip` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`request_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '',
`other` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
KEY `index_username_model_name` (`model_name`,`username`),
KEY `idx_logs_token_name` (`token_name`),
KEY `idx_logs_model_name` (`model_name`),
KEY `idx_logs_token_id` (`token_id`),
KEY `idx_logs_group` (`group`),
KEY `idx_logs_ip` (`ip`),
KEY `idx_logs_request_id` (`request_id`),
KEY `idx_created_at_id` (`id`,`created_at`),
KEY `idx_user_id_id` (`user_id`,`id`),
KEY `idx_logs_user_id` (`user_id`),
KEY `idx_created_at_type` (`created_at`,`type`),
KEY `idx_logs_username` (`username`),
KEY `idx_logs_channel_id` (`channel_id`)
) ENGINE=InnoDB AUTO_INCREMENT=39880 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
绘图表
-- ----------------------------
-- Table structure for midjourneys
-- ----------------------------
DROP TABLE IF EXISTS `midjourneys`;
CREATE TABLE `midjourneys` (
`id` bigint NOT NULL AUTO_INCREMENT,
`code` bigint DEFAULT NULL,
`user_id` bigint DEFAULT NULL,
`action` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`mj_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`prompt` longtext COLLATE utf8mb4_unicode_ci,
`prompt_en` longtext COLLATE utf8mb4_unicode_ci,
`description` longtext COLLATE utf8mb4_unicode_ci,
`state` longtext COLLATE utf8mb4_unicode_ci,
`submit_time` bigint DEFAULT NULL,
`start_time` bigint DEFAULT NULL,
`finish_time` bigint DEFAULT NULL,
`image_url` longtext COLLATE utf8mb4_unicode_ci,
`video_url` longtext COLLATE utf8mb4_unicode_ci,
`video_urls` longtext COLLATE utf8mb4_unicode_ci,
`status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`progress` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`fail_reason` longtext COLLATE utf8mb4_unicode_ci,
`channel_id` bigint DEFAULT NULL,
`quota` bigint DEFAULT NULL,
`buttons` longtext COLLATE utf8mb4_unicode_ci,
`properties` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
KEY `idx_midjourneys_progress` (`progress`),
KEY `idx_midjourneys_user_id` (`user_id`),
KEY `idx_midjourneys_action` (`action`),
KEY `idx_midjourneys_mj_id` (`mj_id`),
KEY `idx_midjourneys_submit_time` (`submit_time`),
KEY `idx_midjourneys_start_time` (`start_time`),
KEY `idx_midjourneys_finish_time` (`finish_time`),
KEY `idx_midjourneys_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
模型表
-- ----------------------------
-- Table structure for models
-- ----------------------------
DROP TABLE IF EXISTS `models`;
CREATE TABLE `models` (
`id` bigint NOT NULL AUTO_INCREMENT,
`model_name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci,
`icon` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`vendor_id` bigint DEFAULT NULL,
`endpoints` text COLLATE utf8mb4_unicode_ci,
`status` bigint DEFAULT '1',
`sync_official` bigint DEFAULT '1',
`created_time` bigint DEFAULT NULL,
`updated_time` bigint DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`name_rule` bigint DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_model_name_delete_at` (`model_name`,`deleted_at`),
KEY `idx_models_vendor_id` (`vendor_id`),
KEY `idx_models_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
系统表
-- ----------------------------
-- Table structure for options
-- ----------------------------
DROP TABLE IF EXISTS `options`;
CREATE TABLE `options` (
`key` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`value` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
指纹表
-- ----------------------------
-- Table structure for passkey_credentials
-- ----------------------------
DROP TABLE IF EXISTS `passkey_credentials`;
CREATE TABLE `passkey_credentials` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint NOT NULL,
`credential_id` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
`public_key` text COLLATE utf8mb4_unicode_ci NOT NULL,
`attestation_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`aa_guid` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sign_count` int unsigned DEFAULT '0',
`clone_warning` tinyint(1) DEFAULT NULL,
`user_present` tinyint(1) DEFAULT NULL,
`user_verified` tinyint(1) DEFAULT NULL,
`backup_eligible` tinyint(1) DEFAULT NULL,
`backup_state` tinyint(1) DEFAULT NULL,
`transports` text COLLATE utf8mb4_unicode_ci,
`attachment` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`last_used_at` datetime(3) DEFAULT NULL,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_passkey_credentials_credential_id` (`credential_id`),
UNIQUE KEY `idx_passkey_credentials_user_id` (`user_id`),
KEY `idx_passkey_credentials_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
预填组表
-- ----------------------------
-- Table structure for prefill_groups
-- ----------------------------
DROP TABLE IF EXISTS `prefill_groups`;
CREATE TABLE `prefill_groups` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`items` json DEFAULT NULL,
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_time` bigint DEFAULT NULL,
`updated_time` bigint DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_prefill_name` (`name`),
KEY `idx_prefill_groups_type` (`type`),
KEY `idx_prefill_groups_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
限额表
-- ----------------------------
-- Table structure for quota_data
-- ----------------------------
DROP TABLE IF EXISTS `quota_data`;
CREATE TABLE `quota_data` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`username` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '',
`model_name` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '',
`created_at` bigint DEFAULT NULL,
`token_used` bigint DEFAULT '0',
`count` bigint DEFAULT '0',
`quota` bigint DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_quota_data_user_id` (`user_id`),
KEY `idx_qdt_model_user_name` (`model_name`,`username`),
KEY `idx_qdt_created_at` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=1410 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
兑换券表
-- ----------------------------
-- Table structure for redemptions
-- ----------------------------
DROP TABLE IF EXISTS `redemptions`;
CREATE TABLE `redemptions` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`key` char(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` bigint DEFAULT '1',
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`quota` bigint DEFAULT '100',
`created_time` bigint DEFAULT NULL,
`redeemed_time` bigint DEFAULT NULL,
`used_user_id` bigint DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`expired_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_redemptions_key` (`key`),
KEY `idx_redemptions_name` (`name`),
KEY `idx_redemptions_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
系统初始化安装表
-- ----------------------------
-- Table structure for setups
-- ----------------------------
DROP TABLE IF EXISTS `setups`;
CREATE TABLE `setups` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`version` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`initialized_at` bigint NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
订阅订单表表
-- ----------------------------
-- Table structure for subscription_orders
-- ----------------------------
DROP TABLE IF EXISTS `subscription_orders`;
CREATE TABLE `subscription_orders` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`plan_id` bigint DEFAULT NULL,
`money` double DEFAULT NULL,
`trade_no` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`payment_method` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` longtext COLLATE utf8mb4_unicode_ci,
`create_time` bigint DEFAULT NULL,
`complete_time` bigint DEFAULT NULL,
`provider_payload` text COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `trade_no` (`trade_no`),
KEY `idx_subscription_orders_user_id` (`user_id`),
KEY `idx_subscription_orders_plan_id` (`plan_id`),
KEY `idx_subscription_orders_trade_no` (`trade_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
订阅计划表
-- ----------------------------
-- Table structure for subscription_plans
-- ----------------------------
DROP TABLE IF EXISTS `subscription_plans`;
CREATE TABLE `subscription_plans` (
`id` bigint NOT NULL AUTO_INCREMENT,
`title` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
`subtitle` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
`price_amount` decimal(10,6) NOT NULL DEFAULT '0.000000',
`currency` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
`duration_unit` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'month',
`duration_value` bigint NOT NULL DEFAULT '1',
`custom_seconds` bigint NOT NULL DEFAULT '0',
`enabled` tinyint(1) DEFAULT '1',
`sort_order` bigint DEFAULT '0',
`stripe_price_id` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
`creem_product_id` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
`max_purchase_per_user` bigint DEFAULT '0',
`upgrade_group` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '',
`total_amount` bigint NOT NULL DEFAULT '0',
`quota_reset_period` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT 'never',
`quota_reset_custom_seconds` bigint DEFAULT '0',
`created_at` bigint DEFAULT NULL,
`updated_at` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
订阅预消费表
-- ----------------------------
-- Table structure for subscription_pre_consume_records
-- ----------------------------
DROP TABLE IF EXISTS `subscription_pre_consume_records`;
CREATE TABLE `subscription_pre_consume_records` (
`id` bigint NOT NULL AUTO_INCREMENT,
`request_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`user_id` bigint DEFAULT NULL,
`user_subscription_id` bigint DEFAULT NULL,
`pre_consumed` bigint NOT NULL DEFAULT '0',
`status` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` bigint DEFAULT NULL,
`updated_at` bigint DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_subscription_pre_consume_records_request_id` (`request_id`),
KEY `idx_subscription_pre_consume_records_status` (`status`),
KEY `idx_subscription_pre_consume_records_updated_at` (`updated_at`),
KEY `idx_subscription_pre_consume_records_user_id` (`user_id`),
KEY `idx_subscription_pre_consume_records_user_subscription_id` (`user_subscription_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
任务表(视频任务)
-- ----------------------------
-- Table structure for tasks
-- ----------------------------
DROP TABLE IF EXISTS `tasks`;
CREATE TABLE `tasks` (
`id` bigint NOT NULL AUTO_INCREMENT,
`created_at` bigint DEFAULT NULL,
`updated_at` bigint DEFAULT NULL,
`task_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`platform` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`user_id` bigint DEFAULT NULL,
`group` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`channel_id` bigint DEFAULT NULL,
`quota` bigint DEFAULT NULL,
`action` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`fail_reason` longtext COLLATE utf8mb4_unicode_ci,
`submit_time` bigint DEFAULT NULL,
`start_time` bigint DEFAULT NULL,
`finish_time` bigint DEFAULT NULL,
`progress` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`properties` json DEFAULT NULL,
`private_data` json DEFAULT NULL,
`data` json DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_tasks_user_id` (`user_id`),
KEY `idx_tasks_action` (`action`),
KEY `idx_tasks_submit_time` (`submit_time`),
KEY `idx_tasks_created_at` (`created_at`),
KEY `idx_tasks_platform` (`platform`),
KEY `idx_tasks_channel_id` (`channel_id`),
KEY `idx_tasks_status` (`status`),
KEY `idx_tasks_start_time` (`start_time`),
KEY `idx_tasks_finish_time` (`finish_time`),
KEY `idx_tasks_progress` (`progress`),
KEY `idx_tasks_task_id` (`task_id`)
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
令牌表
-- ----------------------------
-- Table structure for tokens
-- ----------------------------
DROP TABLE IF EXISTS `tokens`;
CREATE TABLE `tokens` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`key` char(48) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` bigint DEFAULT '1',
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_time` bigint DEFAULT NULL,
`accessed_time` bigint DEFAULT NULL,
`expired_time` bigint DEFAULT '-1',
`remain_quota` bigint DEFAULT '0',
`unlimited_quota` tinyint(1) DEFAULT NULL,
`model_limits_enabled` tinyint(1) DEFAULT NULL,
`model_limits` text COLLATE utf8mb4_unicode_ci,
`allow_ips` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`used_quota` bigint DEFAULT '0',
`group` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`cross_group_retry` tinyint(1) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_tokens_key` (`key`),
KEY `idx_tokens_user_id` (`user_id`),
KEY `idx_tokens_name` (`name`),
KEY `idx_tokens_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=218 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
充值记录表
-- ----------------------------
-- Table structure for top_ups
-- ----------------------------
DROP TABLE IF EXISTS `top_ups`;
CREATE TABLE `top_ups` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`amount` bigint DEFAULT NULL,
`money` double DEFAULT NULL,
`trade_no` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`payment_method` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`create_time` bigint DEFAULT NULL,
`complete_time` bigint DEFAULT NULL,
`status` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `trade_no` (`trade_no`),
KEY `idx_top_ups_user_id` (`user_id`),
KEY `idx_top_ups_trade_no` (`trade_no`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
—
-- ----------------------------
-- Table structure for two_fa_backup_codes
-- ----------------------------
DROP TABLE IF EXISTS `two_fa_backup_codes`;
CREATE TABLE `two_fa_backup_codes` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint NOT NULL,
`code_hash` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`is_used` tinyint(1) DEFAULT NULL,
`used_at` datetime(3) DEFAULT NULL,
`created_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_two_fa_backup_codes_user_id` (`user_id`),
KEY `idx_two_fa_backup_codes_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- ----------------------------
-- Table structure for two_fas
-- ----------------------------
DROP TABLE IF EXISTS `two_fas`;
CREATE TABLE `two_fas` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint NOT NULL,
`secret` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`is_enabled` tinyint(1) DEFAULT NULL,
`failed_attempts` bigint DEFAULT '0',
`locked_until` datetime(3) DEFAULT NULL,
`last_used_at` datetime(3) DEFAULT NULL,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`),
KEY `idx_two_fas_user_id` (`user_id`),
KEY `idx_two_fas_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
用户OAuth绑定表
-- ----------------------------
-- Table structure for user_oauth_bindings
-- ----------------------------
DROP TABLE IF EXISTS `user_oauth_bindings`;
CREATE TABLE `user_oauth_bindings` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint NOT NULL,
`provider_id` bigint NOT NULL,
`provider_user_id` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_user_provider` (`user_id`,`provider_id`),
UNIQUE KEY `ux_provider_userid` (`provider_id`,`provider_user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
用户订阅表
-- ----------------------------
-- Table structure for user_subscriptions
-- ----------------------------
DROP TABLE IF EXISTS `user_subscriptions`;
CREATE TABLE `user_subscriptions` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`plan_id` bigint DEFAULT NULL,
`amount_total` bigint NOT NULL DEFAULT '0',
`amount_used` bigint NOT NULL DEFAULT '0',
`start_time` bigint DEFAULT NULL,
`end_time` bigint DEFAULT NULL,
`status` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`source` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT 'order',
`last_reset_time` bigint DEFAULT '0',
`next_reset_time` bigint DEFAULT '0',
`upgrade_group` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '',
`prev_user_group` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '',
`created_at` bigint DEFAULT NULL,
`updated_at` bigint DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_user_subscriptions_plan_id` (`plan_id`),
KEY `idx_user_subscriptions_end_time` (`end_time`),
KEY `idx_user_subscriptions_status` (`status`),
KEY `idx_user_subscriptions_next_reset_time` (`next_reset_time`),
KEY `idx_user_subscriptions_user_id` (`user_id`),
KEY `idx_user_sub_active` (`user_id`,`status`,`end_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
用户表
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` bigint NOT NULL AUTO_INCREMENT,
`username` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`password` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`display_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`role` bigint DEFAULT '1',
`status` bigint DEFAULT '1',
`email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`github_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`discord_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`oidc_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`wechat_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`telegram_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`access_token` char(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`quota` bigint DEFAULT '0',
`used_quota` bigint DEFAULT '0',
`request_count` bigint DEFAULT '0',
`group` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT 'default',
`aff_code` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`aff_count` bigint DEFAULT '0',
`aff_quota` bigint DEFAULT '0',
`aff_history` bigint DEFAULT '0',
`inviter_id` bigint DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`linux_do_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`setting` text COLLATE utf8mb4_unicode_ci,
`remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`stripe_customer` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` bigint DEFAULT NULL,
`phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `idx_users_access_token` (`access_token`),
UNIQUE KEY `idx_users_aff_code` (`aff_code`),
KEY `idx_users_discord_id` (`discord_id`),
KEY `idx_users_oidc_id` (`oidc_id`),
KEY `idx_users_we_chat_id` (`wechat_id`),
KEY `idx_users_telegram_id` (`telegram_id`),
KEY `idx_users_display_name` (`display_name`),
KEY `idx_users_inviter_id` (`inviter_id`),
KEY `idx_users_deleted_at` (`deleted_at`),
KEY `idx_users_linux_do_id` (`linux_do_id`),
KEY `idx_users_stripe_customer` (`stripe_customer`),
KEY `idx_users_username` (`username`),
KEY `idx_users_email` (`email`),
KEY `idx_users_git_hub_id` (`github_id`),
KEY `idx_users_phone` (`phone`)
) ENGINE=InnoDB AUTO_INCREMENT=888888967 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
提供商表
-- ----------------------------
-- Table structure for vendors
-- ----------------------------
DROP TABLE IF EXISTS `vendors`;
CREATE TABLE `vendors` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci,
`icon` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` bigint DEFAULT '1',
`created_time` bigint DEFAULT NULL,
`updated_time` bigint DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_vendor_name_delete_at` (`name`,`deleted_at`),
KEY `idx_vendors_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SET FOREIGN_KEY_CHECKS = 1;
作者:吴升斌 创建时间:2026-04-21 17:12
最后编辑:吴升斌 更新时间:2026-04-22 15:49
最后编辑:吴升斌 更新时间:2026-04-22 15:49