mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-26 21:02:31 +03:00
18 lines
489 B
PL/PgSQL
18 lines
489 B
PL/PgSQL
BEGIN;
|
|
|
|
-- Add the file_sha1 column if it doesn't exist
|
|
ALTER TABLE IF EXISTS brains_vectors
|
|
ADD COLUMN IF NOT EXISTS file_sha1 TEXT;
|
|
|
|
-- Update the file_sha1 column with values from vectors.metadata
|
|
UPDATE brains_vectors
|
|
SET file_sha1 = subquery.file_sha1
|
|
FROM (
|
|
SELECT vectors.id, vectors.metadata->>'file_sha1' AS file_sha1
|
|
FROM vectors
|
|
) AS subquery
|
|
WHERE brains_vectors.vector_id = subquery.id
|
|
AND (brains_vectors.file_sha1 IS NULL OR brains_vectors.file_sha1 = '');
|
|
|
|
COMMIT;
|