Skip to content

Commit a50b2d5

Browse files
product-api: flyway and 1st migration
1 parent 9651f44 commit a50b2d5

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757
<groupId>org.springframework.boot</groupId>
5858
<artifactId>spring-boot-starter-validation</artifactId>
5959
</dependency>
60+
<dependency>
61+
<groupId>org.flywaydb</groupId>
62+
<artifactId>flyway-core</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.flywaydb</groupId>
66+
<artifactId>flyway-database-postgresql</artifactId>
67+
</dependency>
6068
</dependencies>
6169

6270
<build>

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ spring.datasource.username=amigoscode
44
spring.datasource.password=
55
spring.datasource.driver-class-name=org.postgresql.Driver
66

7-
spring.jpa.hibernate.ddl-auto=create-drop
7+
spring.jpa.hibernate.ddl-auto=validate
88
spring.jpa.show-sql=true
99
spring.jpa.properties.hibernate.format_sql=true
1010

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
2+
3+
CREATE TABLE IF NOT EXISTS product (
4+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
5+
name VARCHAR(50) NOT NULL CHECK (char_length(name) > 1),
6+
description VARCHAR(500) CHECK (char_length(description) >= 5),
7+
price NUMERIC(10, 2) NOT NULL CHECK (price > 0),
8+
image_url VARCHAR(200) CHECK (char_length(image_url) > 0),
9+
stock_level INT NOT NULL DEFAULT 1 CHECK (stock_level >= 0),
10+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
11+
updated_at TIMESTAMPTZ DEFAULT NOW(),
12+
deleted_at TIMESTAMPTZ
13+
);

0 commit comments

Comments
 (0)