mirror of
https://github.com/StanGirard/quivr.git
synced 2024-09-11 13:15:41 +03:00
* 🗃️ update and add fields in brains table * ✨ update endpoints for more brain attribute * ✨ new set as default brain endpoint * 🔥 remove update brain with file * ✏️ fix wrong auto imports * 🐛 fix max tokens for model in front * 🚑 post instead of put to set default brain * 🚑 update brain creation endpoint with new fields
32 lines
963 B
PL/PgSQL
32 lines
963 B
PL/PgSQL
BEGIN;
|
|
|
|
-- Change max_tokens type to INT
|
|
ALTER TABLE brains ALTER COLUMN max_tokens TYPE INT USING max_tokens::INT;
|
|
|
|
-- Add or rename the api_key column to openai_api_key
|
|
DO $$
|
|
BEGIN
|
|
BEGIN
|
|
-- Check if the api_key column exists
|
|
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'brains' AND column_name = 'api_key') THEN
|
|
-- Rename the api_key column to openai_api_key
|
|
ALTER TABLE brains RENAME COLUMN api_key TO openai_api_key;
|
|
ELSE
|
|
-- Create the openai_api_key column if it doesn't exist
|
|
ALTER TABLE brains ADD COLUMN openai_api_key TEXT;
|
|
END IF;
|
|
END;
|
|
END $$;
|
|
|
|
-- Add description column
|
|
ALTER TABLE brains ADD COLUMN description TEXT;
|
|
|
|
-- Update migrations table
|
|
INSERT INTO migrations (name)
|
|
SELECT '202307241530031_add_fields_to_brain'
|
|
WHERE NOT EXISTS (
|
|
SELECT 1 FROM migrations WHERE name = '202307241530031_add_fields_to_brain'
|
|
);
|
|
|
|
COMMIT;
|