fix(migrations): add 0004 for search_providers table

Add incremental migration for existing databases to create the
search_providers table and bots.search_provider_id column introduced
in the search provider feature.
This commit is contained in:
BBQ
2026-02-16 02:37:25 +08:00
parent 75904022c0
commit d268483d81
2 changed files with 18 additions and 0 deletions
@@ -0,0 +1,3 @@
-- 0005_search_providers (down)
ALTER TABLE bots DROP COLUMN IF EXISTS search_provider_id;
DROP TABLE IF EXISTS search_providers;
@@ -0,0 +1,15 @@
-- 0005_search_providers
-- Add search_providers table and link to bots for web search integration.
CREATE TABLE IF NOT EXISTS search_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 search_providers_name_unique UNIQUE (name),
CONSTRAINT search_providers_provider_check CHECK (provider IN ('brave'))
);
ALTER TABLE bots ADD COLUMN IF NOT EXISTS search_provider_id UUID REFERENCES search_providers(id) ON DELETE SET NULL;