feat(db): migration 007 — conversations.space_id + seed companion agent
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
14
lib/db/migrations/007_companion.sql
Normal file
14
lib/db/migrations/007_companion.sql
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- lib/db/migrations/007_companion.sql
|
||||||
|
-- Plan 5: per-Space ambient companion conversation + default companion agent.
|
||||||
|
|
||||||
|
ALTER TABLE conversations
|
||||||
|
ADD COLUMN space_id uuid REFERENCES spaces(id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
CREATE INDEX idx_conversations_space ON conversations(space_id, started_at DESC);
|
||||||
|
|
||||||
|
INSERT INTO agents (slug, name, kind, model, capabilities)
|
||||||
|
VALUES (
|
||||||
|
'companion', 'Companion', 'claude', NULL,
|
||||||
|
'{"read":true,"suggest":true,"write":false}'::jsonb
|
||||||
|
)
|
||||||
|
ON CONFLICT (slug) DO NOTHING;
|
||||||
23
tests/db/migration_007.test.js
Normal file
23
tests/db/migration_007.test.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { describe, it, expect, beforeAll } from 'vitest';
|
||||||
|
import { pool } from '../../lib/db/pool.js';
|
||||||
|
import { resetDb } from '../helpers/db.js';
|
||||||
|
import { migrateUp } from '../../lib/db/migrate.js';
|
||||||
|
|
||||||
|
beforeAll(async () => { await resetDb(); await migrateUp(); });
|
||||||
|
|
||||||
|
describe('migration 007', () => {
|
||||||
|
it('adds conversations.space_id column', async () => {
|
||||||
|
const { rows } = await pool.query(
|
||||||
|
`SELECT column_name FROM information_schema.columns
|
||||||
|
WHERE table_name='conversations' AND column_name='space_id'`
|
||||||
|
);
|
||||||
|
expect(rows).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('seeds a default companion agent', async () => {
|
||||||
|
const { rows } = await pool.query(`SELECT slug, kind, capabilities FROM agents WHERE slug='companion'`);
|
||||||
|
expect(rows).toHaveLength(1);
|
||||||
|
expect(rows[0].kind).toBe('claude');
|
||||||
|
expect(rows[0].capabilities).toMatchObject({ read: true, suggest: true, write: false });
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user