feat: add routing profile scheduling policies

This commit is contained in:
fawney19
2026-05-18 11:03:49 +08:00
parent a2f91b4108
commit 92813e6122
124 changed files with 11681 additions and 578 deletions

View File

@@ -383,3 +383,45 @@ CREATE TABLE IF NOT EXISTS global_models (
UNIQUE KEY global_models_name_key (`name`)
);
CREATE TABLE IF NOT EXISTS routing_groups (
`id` VARCHAR(64) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`description` LONGTEXT,
`enabled` TINYINT(1) NOT NULL DEFAULT 1,
`is_system_default` TINYINT(1) NOT NULL DEFAULT 0,
`config_json` JSON NOT NULL,
`version` BIGINT NOT NULL DEFAULT 1,
`created_at` BIGINT NOT NULL,
`updated_at` BIGINT NOT NULL,
`published_at` BIGINT,
PRIMARY KEY (`id`),
UNIQUE KEY routing_groups_name_key (`name`),
KEY routing_groups_system_default_idx (`is_system_default`, `enabled`)
);
CREATE TABLE IF NOT EXISTS routing_group_bindings (
`id` VARCHAR(64) NOT NULL,
`group_id` VARCHAR(64) NOT NULL,
`subject_type` VARCHAR(32) NOT NULL,
`subject_id` VARCHAR(64) NOT NULL,
`is_default` TINYINT(1) NOT NULL DEFAULT 0,
`allow_explicit_select` TINYINT(1) NOT NULL DEFAULT 1,
`created_at` BIGINT NOT NULL,
`updated_at` BIGINT NOT NULL,
PRIMARY KEY (`id`),
KEY routing_group_bindings_group_id_idx (`group_id`),
KEY routing_group_bindings_subject_idx (`subject_type`, `subject_id`)
);
CREATE TABLE IF NOT EXISTS routing_group_versions (
`id` VARCHAR(64) NOT NULL,
`group_id` VARCHAR(64) NOT NULL,
`version` BIGINT NOT NULL,
`config_json` JSON NOT NULL,
`created_at` BIGINT NOT NULL,
`created_by` VARCHAR(64),
PRIMARY KEY (`id`),
UNIQUE KEY routing_group_versions_group_version_key (`group_id`, `version`),
KEY routing_group_versions_group_id_idx (`group_id`)
);

View File

@@ -396,3 +396,48 @@ CREATE TABLE IF NOT EXISTS public.global_models (
ALTER TABLE ONLY public.global_models ADD CONSTRAINT global_models_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.global_models ADD CONSTRAINT global_models_name_key UNIQUE (name);
CREATE TABLE IF NOT EXISTS public.routing_groups (
id character varying(64) NOT NULL,
name character varying(255) NOT NULL,
description text,
enabled boolean DEFAULT true NOT NULL,
is_system_default boolean DEFAULT false NOT NULL,
config_json jsonb NOT NULL,
version bigint DEFAULT 1 NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
published_at bigint
);
ALTER TABLE ONLY public.routing_groups ADD CONSTRAINT routing_groups_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.routing_groups ADD CONSTRAINT routing_groups_name_key UNIQUE (name);
CREATE INDEX IF NOT EXISTS routing_groups_system_default_idx ON public.routing_groups USING btree (is_system_default, enabled);
CREATE TABLE IF NOT EXISTS public.routing_group_bindings (
id character varying(64) NOT NULL,
group_id character varying(64) NOT NULL,
subject_type character varying(32) NOT NULL,
subject_id character varying(64) NOT NULL,
is_default boolean DEFAULT false NOT NULL,
allow_explicit_select boolean DEFAULT true NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
ALTER TABLE ONLY public.routing_group_bindings ADD CONSTRAINT routing_group_bindings_pkey PRIMARY KEY (id);
CREATE INDEX IF NOT EXISTS routing_group_bindings_group_id_idx ON public.routing_group_bindings USING btree (group_id);
CREATE INDEX IF NOT EXISTS routing_group_bindings_subject_idx ON public.routing_group_bindings USING btree (subject_type, subject_id);
CREATE TABLE IF NOT EXISTS public.routing_group_versions (
id character varying(64) NOT NULL,
group_id character varying(64) NOT NULL,
version bigint NOT NULL,
config_json jsonb NOT NULL,
created_at bigint NOT NULL,
created_by character varying(64)
);
ALTER TABLE ONLY public.routing_group_versions ADD CONSTRAINT routing_group_versions_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.routing_group_versions ADD CONSTRAINT routing_group_versions_group_version_key UNIQUE (group_id, version);
CREATE INDEX IF NOT EXISTS routing_group_versions_group_id_idx ON public.routing_group_versions USING btree (group_id);

View File

@@ -370,3 +370,42 @@ CREATE TABLE IF NOT EXISTS global_models (
UNIQUE (name)
);
CREATE TABLE IF NOT EXISTS routing_groups (
id TEXT PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
description TEXT,
enabled INTEGER NOT NULL DEFAULT 1,
is_system_default INTEGER NOT NULL DEFAULT 0,
config_json TEXT NOT NULL,
version INTEGER NOT NULL DEFAULT 1,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
published_at INTEGER,
UNIQUE (name)
);
CREATE INDEX IF NOT EXISTS routing_groups_system_default_idx ON routing_groups (is_system_default, enabled);
CREATE TABLE IF NOT EXISTS routing_group_bindings (
id TEXT PRIMARY KEY NOT NULL,
group_id TEXT NOT NULL,
subject_type TEXT NOT NULL,
subject_id TEXT NOT NULL,
is_default INTEGER NOT NULL DEFAULT 0,
allow_explicit_select INTEGER NOT NULL DEFAULT 1,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS routing_group_bindings_group_id_idx ON routing_group_bindings (group_id);
CREATE INDEX IF NOT EXISTS routing_group_bindings_subject_idx ON routing_group_bindings (subject_type, subject_id);
CREATE TABLE IF NOT EXISTS routing_group_versions (
id TEXT PRIMARY KEY NOT NULL,
group_id TEXT NOT NULL,
version INTEGER NOT NULL,
config_json TEXT NOT NULL,
created_at INTEGER NOT NULL,
created_by TEXT,
UNIQUE (group_id, version)
);
CREATE INDEX IF NOT EXISTS routing_group_versions_group_id_idx ON routing_group_versions (group_id);

View File

@@ -1694,3 +1694,155 @@ type = "unix_seconds"
[[table.global_models.uniques]]
name = "global_models_name_key"
columns = ["name"]
[table.routing_groups]
domain = "provider_catalog"
order = 110
primary_key = ["id"]
[[table.routing_groups.columns]]
name = "id"
type = "text_id"
length = 64
[[table.routing_groups.columns]]
name = "name"
type = "text"
length = 255
[[table.routing_groups.columns]]
name = "description"
type = "long_text"
nullable = true
[[table.routing_groups.columns]]
name = "enabled"
type = "bool"
default = true
[[table.routing_groups.columns]]
name = "is_system_default"
type = "bool"
default = false
[[table.routing_groups.columns]]
name = "config_json"
type = "json"
[[table.routing_groups.columns]]
name = "version"
type = "int64"
default = 1
[[table.routing_groups.columns]]
name = "created_at"
type = "unix_seconds"
[[table.routing_groups.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.routing_groups.columns]]
name = "published_at"
type = "unix_seconds"
nullable = true
[[table.routing_groups.uniques]]
name = "routing_groups_name_key"
columns = ["name"]
[[table.routing_groups.indexes]]
name = "routing_groups_system_default_idx"
columns = ["is_system_default", "enabled"]
[table.routing_group_bindings]
domain = "provider_catalog"
order = 111
primary_key = ["id"]
[[table.routing_group_bindings.columns]]
name = "id"
type = "text_id"
length = 64
[[table.routing_group_bindings.columns]]
name = "group_id"
type = "text_id"
length = 64
[[table.routing_group_bindings.columns]]
name = "subject_type"
type = "text"
length = 32
[[table.routing_group_bindings.columns]]
name = "subject_id"
type = "text_id"
length = 64
[[table.routing_group_bindings.columns]]
name = "is_default"
type = "bool"
default = false
[[table.routing_group_bindings.columns]]
name = "allow_explicit_select"
type = "bool"
default = true
[[table.routing_group_bindings.columns]]
name = "created_at"
type = "unix_seconds"
[[table.routing_group_bindings.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.routing_group_bindings.indexes]]
name = "routing_group_bindings_group_id_idx"
columns = ["group_id"]
[[table.routing_group_bindings.indexes]]
name = "routing_group_bindings_subject_idx"
columns = ["subject_type", "subject_id"]
[table.routing_group_versions]
domain = "provider_catalog"
order = 112
primary_key = ["id"]
[[table.routing_group_versions.columns]]
name = "id"
type = "text_id"
length = 64
[[table.routing_group_versions.columns]]
name = "group_id"
type = "text_id"
length = 64
[[table.routing_group_versions.columns]]
name = "version"
type = "int64"
[[table.routing_group_versions.columns]]
name = "config_json"
type = "json"
[[table.routing_group_versions.columns]]
name = "created_at"
type = "unix_seconds"
[[table.routing_group_versions.columns]]
name = "created_by"
type = "text_id"
length = 64
nullable = true
[[table.routing_group_versions.uniques]]
name = "routing_group_versions_group_version_key"
columns = ["group_id", "version"]
[[table.routing_group_versions.indexes]]
name = "routing_group_versions_group_id_idx"
columns = ["group_id"]