In a large ceramic bowl, combine the green tomatoes, ginger, lemon zest, juice, and red pepper flakes, if using, and stir to mix. Add the sugar and stir well. Cover with plastic wrap and refrigerate overnight, 12 to 24 hours.
Transfer the tomato mixture to a large nonreactive pot and bring to a boil over medium-high heat. Reduce the heat to medium-low and simmer, stirring occasionally,