Skip to content

Commit

Permalink
https://youtu.be/UgX5lgv4uVM?si=4OsemIII76x8J_tR&t=7762
Browse files Browse the repository at this point in the history
  • Loading branch information
exobrian committed Oct 22, 2023
1 parent 1cf29de commit e59499e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.8'
services:
db:
image: postgres:alpine
ports:
- "5432:5432"
environment:
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: password
21 changes: 20 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -32,6 +31,26 @@
<artifactId>spring-boot-autoconfigure</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<!-- Database dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.postgresql</groupId>-->
<!-- <artifactId>postgresql</artifactId>-->
<!-- <version>42.6.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/exobrian/contentcalendar/model/Content.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.exobrian.contentcalendar.model;

import jakarta.validation.constraints.NotBlank;

import java.time.LocalDateTime;

public record Content(
Integer id,

@NotBlank
String title,

String desc,
Status status,
Type contentType,
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# h2 properties
spring.h2.console.enabled=true
spring.datasource.generate-unique-name=false
spring.datasource.name=content

# Postgres properties
#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
#spring.datasource.username=postgres
#spring.datasource.password=password
#spring.sql.init.mode=always

logging.level.org.springframework.jdbc=DEBUG
14 changes: 14 additions & 0 deletions src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE TABLE IF NOT EXISTS Content (
id INTEGER AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
desc TEXT,
status VARCHAR(20) NOT NULL,
content_type VARCHAR(50) NOT NULL,
date_created TIMESTAMP NOT NULL,
date_updated TIMESTAMP,
url VARCHAR(255),
PRIMARY KEY (id)
);

INSERT INTO Content(title, desc, status, content_type, date_created)
VALUES ('Free Guy', 'My favorite movie', 'IDEA', 'ARTICLE', CURRENT_TIMESTAMP)

0 comments on commit e59499e

Please sign in to comment.