mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-28 13:42:41 +03:00
24 lines
633 B
MySQL
24 lines
633 B
MySQL
|
-- Add creation_time column to 'onboardings' table if it doesn't exist
|
||
|
DO $$
|
||
|
BEGIN
|
||
|
IF NOT EXISTS (
|
||
|
SELECT 1
|
||
|
FROM information_schema.columns
|
||
|
WHERE table_name = 'onboardings'
|
||
|
AND column_name = 'creation_time'
|
||
|
) THEN
|
||
|
ALTER TABLE onboardings ADD COLUMN creation_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
|
||
|
END IF;
|
||
|
END
|
||
|
$$;
|
||
|
|
||
|
-- Insert migration record if it doesn't exist
|
||
|
INSERT INTO migrations (name)
|
||
|
SELECT '20231012150000_add_creation_time_to_onboardings_table'
|
||
|
WHERE NOT EXISTS (
|
||
|
SELECT 1 FROM migrations WHERE name = '20231012150000_add_creation_time_to_onboardings_table'
|
||
|
);
|
||
|
|
||
|
-- Commit the changes
|
||
|
COMMIT;
|