USE vn;

ALTER TABLE vn2008.gastos_resumen MODIFY COLUMN Id_Gasto varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;

DELETE gr.*
    FROM vn2008.gastos_resumen gr LEFT JOIN vn.expense e ON gr.Id_Gasto = e.id
    WHERE e.id IS NULL;

ALTER TABLE vn2008.gastos_resumen
	ADD CONSTRAINT gastos_resumen_expense_FK
	FOREIGN KEY (Id_Gasto) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
