mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
a04b8fd564
- Rename `llm_providers` → `providers`, `llm_provider_oauth_tokens` → `provider_oauth_tokens` - Remove `tts_providers` and `tts_models` tables; speech models now live in the unified `models` table with `type = 'speech'` - Replace top-level `api_key`/`base_url` columns with a JSONB `config` field on `providers` - Rename `llm_provider_id` → `provider_id` across all references - Add `edge-speech` client type and `conf/providers/edge.yaml` default provider - Create new read-only speech endpoints (`/speech-providers`, `/speech-models`) backed by filtered views of the unified tables - Remove old TTS CRUD handlers; simplify speech page to read-only + test - Update registry loader to skip malformed YAML files instead of failing entirely - Fix YAML quoting for model names containing colons in openrouter.yaml - Regenerate sqlc, swagger, and TypeScript SDK
55 lines
1.9 KiB
SQL
55 lines
1.9 KiB
SQL
-- 0029_tts_provider
|
|
-- Add TTS provider/model tables and bots.tts_model_id for existing databases.
|
|
-- NOTE: On fresh databases these tables are replaced by unified providers/models via 0061.
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'tts_providers') THEN
|
|
RETURN;
|
|
END IF;
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'providers') THEN
|
|
CREATE TABLE IF NOT EXISTS tts_providers (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
name TEXT NOT NULL,
|
|
provider TEXT NOT NULL,
|
|
config JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
CONSTRAINT tts_providers_name_unique UNIQUE (name)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS tts_models (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
model_id TEXT NOT NULL,
|
|
name TEXT,
|
|
tts_provider_id UUID NOT NULL REFERENCES tts_providers(id) ON DELETE CASCADE,
|
|
config JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
CONSTRAINT tts_models_provider_model_id_unique UNIQUE (tts_provider_id, model_id)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_tts_models_provider_id ON tts_models(tts_provider_id);
|
|
END IF;
|
|
END $$;
|
|
|
|
ALTER TABLE bots ADD COLUMN IF NOT EXISTS tts_model_id UUID;
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1 FROM pg_constraint WHERE conname = 'bots_tts_model_id_fkey'
|
|
) THEN
|
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'tts_models') THEN
|
|
ALTER TABLE bots
|
|
ADD CONSTRAINT bots_tts_model_id_fkey
|
|
FOREIGN KEY (tts_model_id) REFERENCES tts_models(id) ON DELETE SET NULL;
|
|
ELSE
|
|
ALTER TABLE bots
|
|
ADD CONSTRAINT bots_tts_model_id_fkey
|
|
FOREIGN KEY (tts_model_id) REFERENCES models(id) ON DELETE SET NULL;
|
|
END IF;
|
|
END IF;
|
|
END $$;
|