chore(db): squash chat migrations into single 000414 migration

This commit is contained in:
Kyle Carberry
2026-02-24 11:34:04 -05:00
parent bee184b455
commit 1df173c454
34 changed files with 235 additions and 384 deletions
@@ -1,3 +1,7 @@
DROP TABLE IF EXISTS chat_queued_messages;
DROP TABLE IF EXISTS chat_diff_statuses;
DROP TABLE IF EXISTS chat_messages;
DROP TABLE IF EXISTS chat_model_configs;
DROP TABLE IF EXISTS chat_providers;
DROP TABLE IF EXISTS chats;
DROP TYPE IF EXISTS chat_status;
+119 -18
View File
@@ -1,10 +1,10 @@
CREATE TYPE chat_status AS ENUM (
'waiting', -- Waiting for user input or workspace
'pending', -- Queued, waiting for a coderd replica to pick up
'running', -- Being processed by a coderd replica
'paused', -- Manually paused by user
'completed', -- Finished (no pending work)
'error' -- Failed, needs user intervention
'waiting',
'pending',
'running',
'paused',
'completed',
'error'
);
CREATE TABLE chats (
@@ -14,29 +14,130 @@ CREATE TABLE chats (
workspace_agent_id UUID REFERENCES workspace_agents(id) ON DELETE SET NULL,
title TEXT NOT NULL DEFAULT 'New Chat',
status chat_status NOT NULL DEFAULT 'waiting',
model_config JSONB NOT NULL DEFAULT '{}',
-- Locking fields for multi-replica safety
model_config JSONB NOT NULL DEFAULT '{}'::jsonb,
worker_id UUID,
started_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
parent_chat_id UUID REFERENCES chats(id) ON DELETE SET NULL,
root_chat_id UUID REFERENCES chats(id) ON DELETE SET NULL
);
CREATE INDEX idx_chats_owner ON chats(owner_id);
CREATE INDEX idx_chats_workspace ON chats(workspace_id);
CREATE INDEX idx_chats_pending ON chats(status) WHERE status = 'pending';
CREATE INDEX idx_chats_parent_chat_id ON chats(parent_chat_id);
CREATE INDEX idx_chats_root_chat_id ON chats(root_chat_id);
CREATE TABLE chat_messages (
id BIGSERIAL PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
role TEXT NOT NULL, -- 'user', 'assistant', 'system', 'tool'
content JSONB, -- Text content or structured data
tool_calls JSONB, -- For assistant messages with tool calls
tool_call_id TEXT, -- For tool result messages
thinking TEXT, -- Extended thinking content (if any)
hidden BOOLEAN NOT NULL DEFAULT FALSE -- For system/hidden messages
id BIGSERIAL PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
role TEXT NOT NULL,
content JSONB,
tool_call_id TEXT,
thinking TEXT,
hidden BOOLEAN NOT NULL DEFAULT FALSE,
subagent_request_id UUID,
subagent_event TEXT,
input_tokens BIGINT,
output_tokens BIGINT,
total_tokens BIGINT,
reasoning_tokens BIGINT,
cache_creation_tokens BIGINT,
cache_read_tokens BIGINT,
context_limit BIGINT,
compressed BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT chat_messages_subagent_event_check
CHECK (subagent_event IS NULL OR subagent_event IN ('request', 'response'))
);
CREATE INDEX idx_chat_messages_chat ON chat_messages(chat_id);
CREATE INDEX idx_chat_messages_chat_created ON chat_messages(chat_id, created_at);
CREATE INDEX idx_chat_messages_subagent_request
ON chat_messages(chat_id, subagent_request_id, created_at)
WHERE subagent_request_id IS NOT NULL;
CREATE INDEX idx_chat_messages_compressed_summary_boundary
ON chat_messages(chat_id, created_at DESC, id DESC)
WHERE compressed = TRUE
AND role = 'system'
AND hidden = TRUE;
CREATE TABLE chat_diff_statuses (
chat_id UUID PRIMARY KEY REFERENCES chats(id) ON DELETE CASCADE,
url TEXT,
pull_request_state TEXT,
changes_requested BOOLEAN NOT NULL DEFAULT FALSE,
additions INTEGER NOT NULL DEFAULT 0,
deletions INTEGER NOT NULL DEFAULT 0,
changed_files INTEGER NOT NULL DEFAULT 0,
refreshed_at TIMESTAMPTZ,
stale_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
git_branch TEXT NOT NULL DEFAULT '',
git_remote_origin TEXT NOT NULL DEFAULT ''
);
CREATE INDEX idx_chat_diff_statuses_stale_at ON chat_diff_statuses(stale_at);
CREATE TABLE chat_providers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
provider TEXT NOT NULL UNIQUE,
display_name TEXT NOT NULL DEFAULT '',
api_key TEXT NOT NULL DEFAULT '',
api_key_key_id TEXT REFERENCES dbcrypt_keys(active_key_digest),
enabled BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
base_url TEXT NOT NULL DEFAULT '',
CONSTRAINT chat_providers_provider_check CHECK (
provider = ANY (
ARRAY[
'anthropic'::text,
'azure'::text,
'bedrock'::text,
'google'::text,
'openai'::text,
'openai-compat'::text,
'openrouter'::text,
'vercel'::text
]
)
)
);
COMMENT ON COLUMN chat_providers.api_key_key_id IS 'The ID of the key used to encrypt the provider API key. If this is NULL, the API key is not encrypted';
CREATE INDEX idx_chat_providers_enabled ON chat_providers(enabled);
CREATE TABLE chat_model_configs (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
provider TEXT NOT NULL REFERENCES chat_providers(provider) ON DELETE CASCADE,
model TEXT NOT NULL,
display_name TEXT NOT NULL DEFAULT '',
enabled BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
context_limit BIGINT NOT NULL,
compression_threshold INTEGER NOT NULL,
model_config JSONB NOT NULL DEFAULT '{}'::jsonb,
CONSTRAINT chat_model_configs_context_limit_check
CHECK (context_limit > 0),
CONSTRAINT chat_model_configs_compression_threshold_check
CHECK (compression_threshold >= 0 AND compression_threshold <= 100)
);
CREATE INDEX idx_chat_model_configs_enabled ON chat_model_configs(enabled);
CREATE INDEX idx_chat_model_configs_provider ON chat_model_configs(provider);
CREATE INDEX idx_chat_model_configs_provider_model
ON chat_model_configs(provider, model);
CREATE TABLE chat_queued_messages (
id BIGSERIAL PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
content JSONB NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_chat_queued_messages_chat_id ON chat_queued_messages(chat_id);
@@ -1 +0,0 @@
DROP TABLE IF EXISTS chat_git_changes;
@@ -1,13 +0,0 @@
CREATE TABLE chat_git_changes (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
file_path TEXT NOT NULL,
change_type TEXT NOT NULL, -- 'added', 'modified', 'deleted', 'renamed'
old_path TEXT, -- For renames
diff_summary TEXT, -- Optional: lines added/removed summary
detected_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(chat_id, file_path)
);
CREATE INDEX idx_chat_git_changes_chat ON chat_git_changes(chat_id);
@@ -1,2 +0,0 @@
DROP TABLE IF EXISTS chat_model_configs;
DROP TABLE IF EXISTS chat_providers;
@@ -1,29 +0,0 @@
CREATE TABLE chat_providers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
provider TEXT NOT NULL UNIQUE CHECK (provider IN ('openai', 'anthropic')),
display_name TEXT NOT NULL DEFAULT '',
api_key TEXT NOT NULL DEFAULT '',
api_key_key_id TEXT REFERENCES dbcrypt_keys(active_key_digest),
enabled BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
COMMENT ON COLUMN chat_providers.api_key_key_id IS 'The ID of the key used to encrypt the provider API key. If this is NULL, the API key is not encrypted';
CREATE INDEX idx_chat_providers_enabled ON chat_providers(enabled);
CREATE TABLE chat_model_configs (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
provider TEXT NOT NULL REFERENCES chat_providers(provider) ON DELETE CASCADE,
model TEXT NOT NULL,
display_name TEXT NOT NULL DEFAULT '',
enabled BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(provider, model)
);
CREATE INDEX idx_chat_model_configs_enabled ON chat_model_configs(enabled);
CREATE INDEX idx_chat_model_configs_provider ON chat_model_configs(provider);
@@ -1,16 +0,0 @@
DROP TABLE IF EXISTS chat_messages;
CREATE TABLE chat_messages (
id BIGSERIAL PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
role TEXT NOT NULL, -- 'user', 'assistant', 'system', 'tool'
content JSONB, -- Text content or structured data
tool_calls JSONB, -- For assistant messages with tool calls
tool_call_id TEXT, -- For tool result messages
thinking TEXT, -- Extended thinking content (if any)
hidden BOOLEAN NOT NULL DEFAULT FALSE -- For system/hidden messages
);
CREATE INDEX idx_chat_messages_chat ON chat_messages(chat_id);
CREATE INDEX idx_chat_messages_chat_created ON chat_messages(chat_id, created_at);
@@ -1,16 +0,0 @@
-- This migration intentionally recreates chat_messages in the new shape.
DROP TABLE IF EXISTS chat_messages;
CREATE TABLE chat_messages (
id BIGSERIAL PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
role TEXT NOT NULL, -- 'user', 'assistant', 'system', 'tool'
content JSONB, -- Text content or structured data
tool_call_id TEXT, -- For tool result messages
thinking TEXT, -- Extended thinking content (if any)
hidden BOOLEAN NOT NULL DEFAULT FALSE -- For system/hidden messages
);
CREATE INDEX idx_chat_messages_chat ON chat_messages(chat_id);
CREATE INDEX idx_chat_messages_chat_created ON chat_messages(chat_id, created_at);
@@ -1 +0,0 @@
DROP TABLE IF EXISTS chat_diff_statuses;
@@ -1,16 +0,0 @@
CREATE TABLE chat_diff_statuses (
chat_id UUID PRIMARY KEY REFERENCES chats(id) ON DELETE CASCADE,
github_pr_url TEXT,
pull_request_state TEXT NOT NULL DEFAULT '',
pull_request_open BOOLEAN NOT NULL DEFAULT FALSE,
changes_requested BOOLEAN NOT NULL DEFAULT FALSE,
additions INTEGER NOT NULL DEFAULT 0,
deletions INTEGER NOT NULL DEFAULT 0,
changed_files INTEGER NOT NULL DEFAULT 0,
refreshed_at TIMESTAMPTZ,
stale_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_chat_diff_statuses_stale_at ON chat_diff_statuses(stale_at);
@@ -1,13 +0,0 @@
CREATE TABLE chat_git_changes (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
file_path TEXT NOT NULL,
change_type TEXT NOT NULL, -- 'added', 'modified', 'deleted', 'renamed'
old_path TEXT, -- For renames
diff_summary TEXT, -- Optional: lines added/removed summary
detected_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(chat_id, file_path)
);
CREATE INDEX idx_chat_git_changes_chat ON chat_git_changes(chat_id);
@@ -1 +0,0 @@
DROP TABLE IF EXISTS chat_git_changes;
@@ -1,11 +0,0 @@
ALTER TABLE chat_diff_statuses
ALTER COLUMN pull_request_state SET NOT NULL,
ALTER COLUMN pull_request_state SET DEFAULT '';
ALTER TABLE chat_diff_statuses
RENAME COLUMN url TO github_pr_url;
ALTER TABLE chat_diff_statuses
ADD COLUMN pull_request_open BOOLEAN NOT NULL DEFAULT FALSE,
DROP COLUMN IF EXISTS git_branch,
DROP COLUMN IF EXISTS git_remote_origin;
@@ -1,12 +0,0 @@
ALTER TABLE chat_diff_statuses
ADD COLUMN git_branch TEXT NOT NULL DEFAULT '',
ADD COLUMN git_remote_origin TEXT NOT NULL DEFAULT '',
DROP COLUMN pull_request_open;
ALTER TABLE chat_diff_statuses
RENAME COLUMN github_pr_url TO url;
ALTER TABLE chat_diff_statuses
ALTER COLUMN pull_request_state DROP NOT NULL,
ALTER COLUMN pull_request_state DROP DEFAULT,
ALTER COLUMN pull_request_state TYPE TEXT;
@@ -1,12 +0,0 @@
ALTER TABLE chat_providers
DROP CONSTRAINT IF EXISTS chat_providers_provider_check;
ALTER TABLE chat_providers
ADD CONSTRAINT chat_providers_provider_check CHECK (
provider = ANY (
ARRAY[
'openai'::text,
'anthropic'::text
]
)
);
@@ -1,18 +0,0 @@
ALTER TABLE chat_providers
DROP CONSTRAINT IF EXISTS chat_providers_provider_check;
ALTER TABLE chat_providers
ADD CONSTRAINT chat_providers_provider_check CHECK (
provider = ANY (
ARRAY[
'anthropic'::text,
'azure'::text,
'bedrock'::text,
'google'::text,
'openai'::text,
'openai-compat'::text,
'openrouter'::text,
'vercel'::text
]
)
);
@@ -1,6 +0,0 @@
DROP INDEX IF EXISTS idx_chats_root_chat_id;
DROP INDEX IF EXISTS idx_chats_parent_chat_id;
ALTER TABLE chats
DROP COLUMN IF EXISTS root_chat_id,
DROP COLUMN IF EXISTS parent_chat_id;
@@ -1,13 +0,0 @@
ALTER TABLE chats
ADD COLUMN parent_chat_id UUID REFERENCES chats(id) ON DELETE SET NULL,
ADD COLUMN root_chat_id UUID REFERENCES chats(id) ON DELETE SET NULL;
-- Existing chats are non-delegated; make them their own root.
UPDATE chats
SET
root_chat_id = id
WHERE
root_chat_id IS NULL;
CREATE INDEX idx_chats_parent_chat_id ON chats(parent_chat_id);
CREATE INDEX idx_chats_root_chat_id ON chats(root_chat_id);
@@ -1,8 +0,0 @@
DROP INDEX IF EXISTS idx_chat_messages_subagent_request;
ALTER TABLE chat_messages
DROP CONSTRAINT IF EXISTS chat_messages_subagent_event_check;
ALTER TABLE chat_messages
DROP COLUMN IF EXISTS subagent_event,
DROP COLUMN IF EXISTS subagent_request_id;
@@ -1,11 +0,0 @@
ALTER TABLE chat_messages
ADD COLUMN subagent_request_id UUID,
ADD COLUMN subagent_event TEXT;
ALTER TABLE chat_messages
ADD CONSTRAINT chat_messages_subagent_event_check
CHECK (subagent_event IS NULL OR subagent_event IN ('request', 'response'));
CREATE INDEX idx_chat_messages_subagent_request
ON chat_messages(chat_id, subagent_request_id, created_at)
WHERE subagent_request_id IS NOT NULL;
@@ -1,10 +0,0 @@
ALTER TABLE chat_messages
DROP COLUMN IF EXISTS context_limit,
DROP COLUMN IF EXISTS cache_read_tokens,
DROP COLUMN IF EXISTS cache_creation_tokens,
DROP COLUMN IF EXISTS reasoning_tokens,
DROP COLUMN IF EXISTS total_tokens,
DROP COLUMN IF EXISTS output_tokens,
DROP COLUMN IF EXISTS input_tokens,
DROP COLUMN IF EXISTS cached_output_tokens,
DROP COLUMN IF EXISTS cached_input_tokens;
@@ -1,39 +0,0 @@
ALTER TABLE chat_messages
ADD COLUMN IF NOT EXISTS input_tokens BIGINT,
ADD COLUMN IF NOT EXISTS output_tokens BIGINT,
ADD COLUMN IF NOT EXISTS total_tokens BIGINT,
ADD COLUMN IF NOT EXISTS reasoning_tokens BIGINT,
ADD COLUMN IF NOT EXISTS cache_creation_tokens BIGINT,
ADD COLUMN IF NOT EXISTS cache_read_tokens BIGINT,
ADD COLUMN IF NOT EXISTS context_limit BIGINT;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = current_schema()
AND table_name = 'chat_messages'
AND column_name = 'cached_output_tokens'
) THEN
UPDATE chat_messages
SET cache_creation_tokens = COALESCE(cache_creation_tokens, cached_output_tokens)
WHERE cached_output_tokens IS NOT NULL;
END IF;
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = current_schema()
AND table_name = 'chat_messages'
AND column_name = 'cached_input_tokens'
) THEN
UPDATE chat_messages
SET cache_read_tokens = COALESCE(cache_read_tokens, cached_input_tokens)
WHERE cached_input_tokens IS NOT NULL;
END IF;
END $$;
ALTER TABLE chat_messages
DROP COLUMN IF EXISTS cached_output_tokens,
DROP COLUMN IF EXISTS cached_input_tokens;
@@ -1,12 +0,0 @@
DROP INDEX IF EXISTS idx_chat_messages_compressed_summary_boundary;
ALTER TABLE chat_messages
DROP COLUMN IF EXISTS compressed;
ALTER TABLE chat_model_configs
DROP CONSTRAINT IF EXISTS chat_model_configs_compression_threshold_check,
DROP CONSTRAINT IF EXISTS chat_model_configs_context_limit_check;
ALTER TABLE chat_model_configs
DROP COLUMN IF EXISTS compression_threshold,
DROP COLUMN IF EXISTS context_limit;
@@ -1,28 +0,0 @@
ALTER TABLE chat_model_configs
ADD COLUMN IF NOT EXISTS context_limit BIGINT,
ADD COLUMN IF NOT EXISTS compression_threshold INTEGER;
-- Backfill existing rows so context compression can operate safely by default.
UPDATE chat_model_configs
SET
context_limit = COALESCE(context_limit, 200000),
compression_threshold = COALESCE(compression_threshold, 70);
ALTER TABLE chat_model_configs
ALTER COLUMN context_limit SET NOT NULL,
ALTER COLUMN compression_threshold SET NOT NULL;
ALTER TABLE chat_model_configs
ADD CONSTRAINT chat_model_configs_context_limit_check
CHECK (context_limit > 0),
ADD CONSTRAINT chat_model_configs_compression_threshold_check
CHECK (compression_threshold >= 0 AND compression_threshold <= 100);
ALTER TABLE chat_messages
ADD COLUMN IF NOT EXISTS compressed BOOLEAN NOT NULL DEFAULT FALSE;
CREATE INDEX IF NOT EXISTS idx_chat_messages_compressed_summary_boundary
ON chat_messages(chat_id, created_at DESC, id DESC)
WHERE compressed = TRUE
AND role = 'system'
AND hidden = TRUE;
@@ -1 +0,0 @@
DROP TABLE IF EXISTS chat_queued_messages;
@@ -1,8 +0,0 @@
CREATE TABLE chat_queued_messages (
id BIGSERIAL PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
content jsonb NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX idx_chat_queued_messages_chat_id ON chat_queued_messages(chat_id);
@@ -1,2 +0,0 @@
ALTER TABLE chat_providers
DROP COLUMN base_url;
@@ -1,2 +0,0 @@
ALTER TABLE chat_providers
ADD COLUMN base_url TEXT NOT NULL DEFAULT '';
@@ -1,2 +0,0 @@
ALTER TABLE chat_model_configs
DROP COLUMN IF EXISTS model_config;
@@ -1,2 +0,0 @@
ALTER TABLE chat_model_configs
ADD COLUMN IF NOT EXISTS model_config JSONB NOT NULL DEFAULT '{}'::jsonb;
@@ -1,19 +0,0 @@
DROP INDEX IF EXISTS idx_chat_model_configs_provider_model;
WITH ranked AS (
SELECT
id,
ROW_NUMBER() OVER (
PARTITION BY provider, model
ORDER BY updated_at DESC, created_at DESC, id DESC
) AS rownum
FROM chat_model_configs
)
DELETE FROM chat_model_configs AS cmc
USING ranked
WHERE
cmc.id = ranked.id
AND ranked.rownum > 1;
ALTER TABLE chat_model_configs
ADD CONSTRAINT chat_model_configs_provider_model_key UNIQUE (provider, model);
@@ -1,5 +0,0 @@
ALTER TABLE chat_model_configs
DROP CONSTRAINT IF EXISTS chat_model_configs_provider_model_key;
CREATE INDEX IF NOT EXISTS idx_chat_model_configs_provider_model
ON chat_model_configs(provider, model);
@@ -0,0 +1,112 @@
INSERT INTO chat_providers (
id,
provider,
display_name,
api_key,
api_key_key_id,
enabled,
created_at,
updated_at
) VALUES (
'0a8b2f84-b5a8-4c44-8c9f-e58c44a534a7',
'openai',
'OpenAI',
'',
NULL,
TRUE,
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00'
);
INSERT INTO chat_model_configs (
id,
provider,
model,
display_name,
enabled,
context_limit,
compression_threshold,
created_at,
updated_at
) VALUES (
'9af5f8d5-6a57-4505-8a69-3d6c787b95fd',
'openai',
'gpt-5.2',
'GPT 5.2',
TRUE,
200000,
70,
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00'
);
INSERT INTO chats (
id,
owner_id,
title,
status,
created_at,
updated_at
)
SELECT
'72c0438a-18eb-4688-ab80-e4c6a126ef96',
id,
'Fixture Chat',
'completed',
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00'
FROM users
ORDER BY created_at, id
LIMIT 1;
INSERT INTO chat_messages (
chat_id,
created_at,
role,
content
) VALUES (
'72c0438a-18eb-4688-ab80-e4c6a126ef96',
'2024-01-01 00:00:00+00',
'assistant',
'{"type":"text","text":"fixture"}'::jsonb
);
INSERT INTO chat_diff_statuses (
chat_id,
url,
pull_request_state,
changes_requested,
additions,
deletions,
changed_files,
refreshed_at,
stale_at,
created_at,
updated_at,
git_branch,
git_remote_origin
) VALUES (
'72c0438a-18eb-4688-ab80-e4c6a126ef96',
'https://example.com/pr/1',
'open',
FALSE,
1,
0,
1,
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00',
'main',
'origin'
);
INSERT INTO chat_queued_messages (
chat_id,
content,
created_at
) VALUES (
'72c0438a-18eb-4688-ab80-e4c6a126ef96',
'{"type":"text","text":"queued fixture"}'::jsonb,
'2024-01-01 00:00:00+00'
);
@@ -1,37 +0,0 @@
INSERT INTO chat_providers (
id,
provider,
display_name,
api_key,
api_key_key_id,
enabled,
created_at,
updated_at
) VALUES (
'0a8b2f84-b5a8-4c44-8c9f-e58c44a534a7',
'openai',
'OpenAI',
'',
NULL,
TRUE,
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00'
);
INSERT INTO chat_model_configs (
id,
provider,
model,
display_name,
enabled,
created_at,
updated_at
) VALUES (
'9af5f8d5-6a57-4505-8a69-3d6c787b95fd',
'openai',
'gpt-5.2',
'GPT 5.2',
TRUE,
'2024-01-01 00:00:00+00',
'2024-01-01 00:00:00+00'
);