wulf-pulse/migrations/007_remove_time_entries_foreign_keys.sql

17 lines
945 B
MySQL
Raw Normal View History

-- Remove all foreign key constraints from time_entries table
-- This allows syncing time entries without requiring related entities to exist first
-- Drop all foreign key constraints
ALTER TABLE time_entries DROP CONSTRAINT IF EXISTS time_entries_resource_id_fkey;
ALTER TABLE time_entries DROP CONSTRAINT IF EXISTS time_entries_ticket_id_fkey;
ALTER TABLE time_entries DROP CONSTRAINT IF EXISTS time_entries_task_id_fkey;
ALTER TABLE time_entries DROP CONSTRAINT IF EXISTS time_entries_project_id_fkey;
ALTER TABLE time_entries DROP CONSTRAINT IF EXISTS time_entries_company_id_fkey;
ALTER TABLE time_entries DROP CONSTRAINT IF EXISTS time_entries_approved_by_resource_id_fkey;
-- Also make resource_id nullable since we're removing constraints
ALTER TABLE time_entries ALTER COLUMN resource_id DROP NOT NULL;
-- Comments
COMMENT ON TABLE time_entries IS 'Autotask time entries - foreign key constraints removed to allow flexible syncing';