35632-vm/db/migrations/016_fix_tasks_table_for_employees.sql
2025-12-17 04:34:30 +00:00

13 lines
532 B
SQL

-- Drop the old foreign key constraint that links tasks to candidates.
-- The name 'tasks_ibfk_1' is the default name generated by MySQL.
ALTER TABLE `tasks` DROP FOREIGN KEY `tasks_ibfk_1`;
-- Drop the old column linking to candidates.
ALTER TABLE `tasks` DROP COLUMN `candidate_id`;
-- Add the new column to link tasks to employees (users).
ALTER TABLE `tasks` ADD COLUMN `assignee_id` INT;
-- Add the new foreign key constraint.
ALTER TABLE `tasks` ADD FOREIGN KEY (`assignee_id`) REFERENCES `users`(`id`) ON DELETE SET NULL;