-- Step 1: Drop the foreign key constraint
ALTER TABLE project_finance_monthly_override DROP FOREIGN KEY project_finance_monthly_override_ibfk_1;

-- Step 2: Drop the old primary key
ALTER TABLE project_finance_monthly_override DROP PRIMARY KEY;

-- Step 3: Add the new month column
ALTER TABLE project_finance_monthly_override ADD COLUMN month VARCHAR(7) NOT NULL;

-- Step 4: Add the new composite primary key
ALTER TABLE project_finance_monthly_override ADD PRIMARY KEY (project_id, month);

-- Step 5: Re-add the foreign key constraint with a more descriptive name
ALTER TABLE project_finance_monthly_override ADD CONSTRAINT fk_override_project_id FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
