Skip to content

Commit

Permalink
Add song creation date
Browse files Browse the repository at this point in the history
  • Loading branch information
Migwel committed Dec 30, 2023
1 parent d95b0c7 commit a7982e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db/tables/Song.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ CREATE TABLE Song (
id BIGINT NOT NULL DEFAULT nextval('song_seq'),
artist VARCHAR,
title VARCHAR,
raw_data VARCHAR
raw_data VARCHAR,
creation_date TIMESTAMP WITH TIME ZONE DEFAULT now()
);
14 changes: 14 additions & 0 deletions src/main/java/dev/migwel/sts/database/entities/Song.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package dev.migwel.sts.database.entities;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;

import java.util.Date;

@Entity
public class Song {
@Id
Expand All @@ -17,6 +20,9 @@ public class Song {
private String title;
private String rawData;

@Column(insertable = false) // Rely on Postgres now() default value
private Date creationDate;

public Song() {
// Needed for Spring JPA
}
Expand Down Expand Up @@ -65,4 +71,12 @@ public String getRawData() {
public void setRawData(String rawData) {
this.rawData = rawData;
}

public Date getCreationDate() {
return creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
}

0 comments on commit a7982e3

Please sign in to comment.