quivr/scripts/20230921160000_add_last_update_field_to_brain.sql
Mamadou DICKO 2c9a0c1ed2
feat: activate public brain subscription (#1241)
* feat: add public brain details modal

* feat(brain): add subscription route

* feat: activate subscription button

* feat: add last_update column to brain table

* feat: display last update on public brain details page

* feat: change RBAC rule for public brains

* feat: maintain brain last_update time
2023-09-22 11:44:09 +02:00

24 lines
596 B
SQL

-- Add last_update column to 'brains' table if it doesn't exist
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'brains'
AND column_name = 'last_update'
) THEN
ALTER TABLE brains ADD COLUMN last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
END IF;
END
$$;
-- Insert migration record if it doesn't exist
INSERT INTO migrations (name)
SELECT '20230921160000_add_last_update_field_to_brain'
WHERE NOT EXISTS (
SELECT 1 FROM migrations WHERE name = '20230921160000_add_last_update_field_to_brain'
);
-- Commit the changes
COMMIT;