Skip to content

Commit da16b51

Browse files
committed
✨ Add data field to Product
1 parent 8d965d2 commit da16b51

4 files changed

Lines changed: 96 additions & 75 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package com.rubberduckcrew.ecoscan_backend.products.dto;
22

3-
public record ProductDTO(String id, String name, String description, String imageUrl) {
3+
public record ProductDTO(String id, String name, String description, String imageUrl, String data) {
44
}

ecoscan_backend/src/main/java/com/rubberduckcrew/ecoscan_backend/products/entity/Product.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ public class Product implements Serializable {
2929

3030
@NotNull @Size(max = 2048) @Column(length = 2048, nullable = false)
3131
private String description;
32+
33+
@NotNull private String data;
3234
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CREATE TABLE product
2+
(
3+
id VARCHAR(255) NOT NULL,
4+
dtype VARCHAR(31) NOT NULL,
5+
name VARCHAR(255) NOT NULL,
6+
image_url VARCHAR(255) NOT NULL,
7+
description VARCHAR(2048) NOT NULL,
8+
data VARCHAR(2048) NOT NULL,
9+
score INTEGER,
10+
environment_score INTEGER,
11+
social_score INTEGER,
12+
health_score INTEGER,
13+
justification VARCHAR(2048),
14+
scanned_date TIMESTAMP WITHOUT TIME ZONE,
15+
CONSTRAINT pk_product PRIMARY KEY (id)
16+
);
17+
18+
CREATE TABLE scan_history
19+
(
20+
id UUID NOT NULL,
21+
user_id UUID NOT NULL,
22+
product_id VARCHAR(255) NOT NULL,
23+
saved_date TIMESTAMP WITHOUT TIME ZONE NOT NULL,
24+
CONSTRAINT pk_scanhistory PRIMARY KEY (id)
25+
);
26+
27+
CREATE INDEX idx_scan_history_user_id ON scan_history (user_id);
28+
29+
ALTER TABLE scan_history
30+
ADD CONSTRAINT FK_SCANHISTORY_ON_PRODUCT FOREIGN KEY (product_id) REFERENCES product (id);

0 commit comments

Comments
 (0)