feat(shopping): add generated_at column to shopping_list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-04 18:17:12 +02:00
parent e12fb72fc2
commit 2253c76287
2 changed files with 8 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package com.recipeapp.shopping.entity;
import com.recipeapp.household.entity.Household; import com.recipeapp.household.entity.Household;
import com.recipeapp.planning.entity.WeekPlan; import com.recipeapp.planning.entity.WeekPlan;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -23,6 +24,9 @@ public class ShoppingList {
@JoinColumn(name = "week_plan_id", nullable = false) @JoinColumn(name = "week_plan_id", nullable = false)
private WeekPlan weekPlan; private WeekPlan weekPlan;
@Column(name = "generated_at", nullable = false)
private Instant generatedAt = Instant.now();
@OneToMany(mappedBy = "shoppingList", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "shoppingList", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ShoppingListItem> items = new ArrayList<>(); private List<ShoppingListItem> items = new ArrayList<>();
@@ -36,5 +40,7 @@ public class ShoppingList {
public UUID getId() { return id; } public UUID getId() { return id; }
public Household getHousehold() { return household; } public Household getHousehold() { return household; }
public WeekPlan getWeekPlan() { return weekPlan; } public WeekPlan getWeekPlan() { return weekPlan; }
public Instant getGeneratedAt() { return generatedAt; }
public void setGeneratedAt(Instant generatedAt) { this.generatedAt = generatedAt; }
public List<ShoppingListItem> getItems() { return items; } public List<ShoppingListItem> getItems() { return items; }
} }

View File

@@ -0,0 +1,2 @@
ALTER TABLE shopping_list
ADD COLUMN generated_at timestamptz NOT NULL DEFAULT now();