diff --git a/.http-requests/auth/app-user.http b/.http-requests/auth/app-user.http
index cb5d388..80563b6 100644
--- a/.http-requests/auth/app-user.http
+++ b/.http-requests/auth/app-user.http
@@ -5,8 +5,8 @@ Content-Type: application/json
{
"firstName": "asd",
"lastName": "asd",
- "username": "test12",
- "password": "test12",
+ "username": "test",
+ "password": "test",
"email": "test@example.com"
}
diff --git a/pom.xml b/pom.xml
index 6f64477..59fe667 100644
--- a/pom.xml
+++ b/pom.xml
@@ -156,6 +156,17 @@
2.3.0
+
+ org.flywaydb
+ flyway-core
+ 10.10.0
+
+
+ org.flywaydb
+ flyway-database-postgresql
+ 10.10.0
+
+
diff --git a/src/main/resources/application-dev.yaml b/src/main/resources/application-dev.yaml
index 7f44a61..2e20381 100644
--- a/src/main/resources/application-dev.yaml
+++ b/src/main/resources/application-dev.yaml
@@ -7,10 +7,15 @@ server:
enabled: false # disable the Whitelabel page
include-message: always # always include the HTTP message
-spring:
+ flyway:
+ enabled: true
+ locations: classpath:db/migration
+ baseline-on-migrate: true
+
jpa:
hibernate:
- ddl-auto: update
+ ddl-auto: validate
+
logging:
level:
diff --git a/src/main/resources/application-production.yaml b/src/main/resources/application-production.yaml
index bbf37d5..073f8dd 100644
--- a/src/main/resources/application-production.yaml
+++ b/src/main/resources/application-production.yaml
@@ -3,6 +3,7 @@ spring:
url: ${DB_URL}
username: ${DB_USER}
password: ${DB_PASSWORD}
+ driver-class-name: org.postgresql.Driver
jwt:
jwtSecret: ${JWT_SECRET}
jwtExpiration: ${JWT_EXPIRATION}
diff --git a/src/main/resources/db/migration/V1__create-tables.sql b/src/main/resources/db/migration/V1__create-tables.sql
new file mode 100644
index 0000000..80942af
--- /dev/null
+++ b/src/main/resources/db/migration/V1__create-tables.sql
@@ -0,0 +1,19 @@
+CREATE TABLE public.app_user (
+ id SERIAL PRIMARY KEY,
+ first_name VARCHAR(255),
+ last_name VARCHAR(255),
+ username VARCHAR(255),
+ password VARCHAR(255),
+ email VARCHAR(255),
+ image_url VARCHAR(255),
+ create_date TIMESTAMP,
+ modify_date TIMESTAMP
+);
+
+CREATE TABLE public.app_user_user_role (
+ app_user_id INT NOT NULL,
+ user_role VARCHAR(50) NOT NULL,
+ CONSTRAINT fk_app_user FOREIGN KEY (app_user_id)
+ REFERENCES public.app_user(id)
+ ON DELETE CASCADE
+);
\ No newline at end of file
diff --git a/src/main/resources/db/migration/V2__insert-app-user.sql b/src/main/resources/db/migration/V2__insert-app-user.sql
new file mode 100644
index 0000000..d531773
--- /dev/null
+++ b/src/main/resources/db/migration/V2__insert-app-user.sql
@@ -0,0 +1,25 @@
+INSERT INTO public.app_user (
+ first_name,
+ last_name,
+ username,
+ password,
+ email,
+ image_url,
+ create_date,
+ modify_date
+) VALUES (
+ 'Benyamin',
+ 'Smith',
+ 'test10',
+ '$2b$12$ytf8RUEeUB4imdjah/.KBuBQpPGN/9M7bMtToTP5jf1X3pRMj8kUi',
+ 'venya@example.com',
+ 'https://example.com/images/ivan.jpg',
+ CURRENT_TIMESTAMP,
+ CURRENT_TIMESTAMP
+ );
+
+INSERT INTO public.app_user_user_role (app_user_id, user_role) VALUES (
+
+ (SELECT id FROM public.app_user WHERE username = 'test10'),
+ 'ADMIN'
+ );
\ No newline at end of file