CREATE TEMPORARY TABLE tmp_budgets (
	recc_id INT,
	year smallint,
	amount decimal(10, 2)
);

INSERT INTO tmp_budgets SELECT recc_id, year, SUM(amount) FROM budgets GROUP BY recc_id, year;

DROP TABLE budgets;

CREATE TABLE budgets (
	recc_id INT NOT NULL,
	year SMALLINT,
	amount DECIMAL(10, 2),
	INDEX idx_year (year),
	UNIQUE KEY idx_budget (recc_id, year),
	FOREIGN KEY idx_recc (recc_id) REFERENCES reccs (id)
) ENGINE=InnoDB;