Merge branch 'main' of https://github.com/mt21625457/aicodex2api
This commit is contained in:
19
backend/migrations/047_add_user_group_rate_multipliers.sql
Normal file
19
backend/migrations/047_add_user_group_rate_multipliers.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- 用户专属分组倍率表
|
||||
-- 允许管理员为特定用户设置分组的专属计费倍率,覆盖分组默认倍率
|
||||
CREATE TABLE IF NOT EXISTS user_group_rate_multipliers (
|
||||
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
group_id BIGINT NOT NULL REFERENCES groups(id) ON DELETE CASCADE,
|
||||
rate_multiplier DECIMAL(10,4) NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
PRIMARY KEY (user_id, group_id)
|
||||
);
|
||||
|
||||
-- 按 group_id 查询索引(删除分组时清理关联记录)
|
||||
CREATE INDEX IF NOT EXISTS idx_user_group_rate_multipliers_group_id
|
||||
ON user_group_rate_multipliers(group_id);
|
||||
|
||||
COMMENT ON TABLE user_group_rate_multipliers IS '用户专属分组倍率配置';
|
||||
COMMENT ON COLUMN user_group_rate_multipliers.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN user_group_rate_multipliers.group_id IS '分组ID';
|
||||
COMMENT ON COLUMN user_group_rate_multipliers.rate_multiplier IS '专属计费倍率(覆盖分组默认倍率)';
|
||||
24
backend/migrations/048_add_error_passthrough_rules.sql
Normal file
24
backend/migrations/048_add_error_passthrough_rules.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- Error Passthrough Rules table
|
||||
-- Allows administrators to configure how upstream errors are passed through to clients
|
||||
|
||||
CREATE TABLE IF NOT EXISTS error_passthrough_rules (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
enabled BOOLEAN NOT NULL DEFAULT true,
|
||||
priority INTEGER NOT NULL DEFAULT 0,
|
||||
error_codes JSONB DEFAULT '[]',
|
||||
keywords JSONB DEFAULT '[]',
|
||||
match_mode VARCHAR(10) NOT NULL DEFAULT 'any',
|
||||
platforms JSONB DEFAULT '[]',
|
||||
passthrough_code BOOLEAN NOT NULL DEFAULT true,
|
||||
response_code INTEGER,
|
||||
passthrough_body BOOLEAN NOT NULL DEFAULT true,
|
||||
custom_message TEXT,
|
||||
description TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Indexes for efficient queries
|
||||
CREATE INDEX IF NOT EXISTS idx_error_passthrough_rules_enabled ON error_passthrough_rules (enabled);
|
||||
CREATE INDEX IF NOT EXISTS idx_error_passthrough_rules_priority ON error_passthrough_rules (priority);
|
||||
Reference in New Issue
Block a user