Files
krow_backend/migrations/000008_knowledge.down.sql
2026-08-28 12:21:44 +05:30

22 lines
971 B
SQL

-- Reverses 000008.
--
-- Drops the two tables and the similarity function. Chunks go with their
-- documents by CASCADE, and both tables' indexes go with them.
--
-- Rolling this back destroys the index, not the sources. Documents were
-- ingested FROM somewhere — a policy store, an upload, a file — and this table
-- is a derived copy, so the cost of reversing is a re-ingest and a re-embed
-- rather than lost content. The re-embed is the expensive half, and it is worth
-- saying out loud before anyone runs this in an environment where embedding
-- costs money.
--
-- Order matters: the function is dropped last because nothing depends on it,
-- and the tables are dropped before it only so that a partially-applied
-- rollback leaves no table referencing a missing function.
SET search_path = public;
DROP TABLE IF EXISTS public.knowledge_chunks;
DROP TABLE IF EXISTS public.knowledge_documents;
DROP FUNCTION IF EXISTS public.knowledge_dot(real[], real[]);