Skip to content

Commit

Permalink
feat: db setting (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmizz authored Jul 21, 2024
1 parent 7eabcb4 commit 75fd349
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 45 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/showpot-dev-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ jobs:
- name: Copy Secrets
uses: microsoft/variable-substitution@v1
with:
files: './app/src/main/resources/application-dev.yml, ./app/src/main/resources/application-cloud-dev.yml'
files: './app/src/main/resources/application-dev.yml, ./app/src/main/resources/application-cloud-dev.yml, ./app/domain/common-domain/src/main/resources/application-domain-dev.yml'
env:
token.secret-key: ${{ secrets.TOKEN_SECRET_KEY }}
cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY }}
cloud.aws.credentials.secretKey: ${{ secrets.AWS_SECRET_KEY }}
cloud.aws.region: ${{ secrets.AWS_REGION }}
cloud.aws.s3.bucket: ${{ secrets.AWS_BUCKET }}
spring.datasource.url: ${{ secrets.APPLICATION_DATASOURCE_URL_DEV }}
spring.datasource.username: ${{ secrets.APPLICATION_DATASOURCE_USERNAME }}
spring.datasource.password: ${{ secrets.APPLICATION_DATASOURCE_PASSWORD }}

- name: Build with Gradle Wrapper
run: ./gradlew clean build
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/showpot-dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ jobs:
- name: Copy Secrets
uses: microsoft/variable-substitution@v1
with:
files: './app/src/main/resources/application-dev.yml, ./app/src/main/resources/application-cloud-dev.yml'
files: './app/src/main/resources/application-dev.yml, ./app/src/main/resources/application-cloud-dev.yml, ./app/domain/common-domain/src/main/resources/application-domain-dev.yml'
env:
token.secret-key: ${{ secrets.TOKEN_SECRET_KEY }}
cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY }}
cloud.aws.credentials.secretKey: ${{ secrets.AWS_SECRET_KEY }}
cloud.aws.region: ${{ secrets.AWS_REGION }}
cloud.aws.s3.bucket: ${{ secrets.AWS_BUCKET }}
spring.datasource.url: ${{ secrets.APPLICATION_DATASOURCE_URL_DEV }}
spring.datasource.username: ${{ secrets.APPLICATION_DATASOURCE_USERNAME }}
spring.datasource.password: ${{ secrets.APPLICATION_DATASOURCE_PASSWORD }}

- name: Build with Gradle Wrapper
run: ./gradlew clean build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/showpot-prod-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ jobs:
- name: Copy Secrets
uses: microsoft/variable-substitution@v1
with:
files: ./app/src/main/resources/application-cloud-prod.yml
files: './app/src/main/resources/application-prod.yml, ./app/src/main/resources/application-cloud-prod.yml, ./app/domain/common-domain/src/main/resources/application-domain-prod.yml'
env:
token.secret-key: ${{ secrets.TOKEN_SECRET_KEY }}
cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY }}
cloud.aws.credentials.secretKey: ${{ secrets.AWS_SECRET_KEY }}
cloud.aws.region: ${{ secrets.AWS_REGION }}
cloud.aws.s3.bucket: ${{ secrets.AWS_BUCKET }}
spring.datasource.url: ${{ secrets.APPLICATION_DATASOURCE_URL_PROD }}
spring.datasource.username: ${{ secrets.APPLICATION_DATASOURCE_USERNAME }}
spring.datasource.password: ${{ secrets.APPLICATION_DATASOURCE_PASSWORD }}

- name: Build with Gradle Wrapper
run: ./gradlew clean build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
spring:
jpa:
hibernate:
ddl-auto: create
show-sql: true
open-in-view: false
generate-ddl: true
jpa:
hibernate:
ddl-auto: none
show-sql: true
datasource:
url: ${APPLICATION_DATASOURCE_URL_DEV}
username: ${APPLICATION_DATASOURCE_USERNAME}
password: ${APPLICATION_DATASOURCE_PASSWORD}
driver-class-name: org.postgresql.Driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spring:
jpa:
hibernate:
ddl-auto: none
show-sql: true
datasource:
url: ${APPLICATION_DATASOURCE_URL_PROD}
username: ${APPLICATION_DATASOURCE_USERNAME}
password: ${APPLICATION_DATASOURCE_PASSWORD}
driver-class-name: org.postgresql.Driver
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class ArtistSearch extends BaseEntity {
private String name;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "artist_id")
@JoinColumn(name = "artist_id", nullable = false)
private Artist artist;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ShowSearch extends BaseEntity {
private String name;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "show_id")
@JoinColumn(name = "show_id", nullable = false)
private Show show;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
@Table(name = "users")
public class User extends BaseEntity {

@Column(name = "nickname")
@Column(name = "nickname", nullable = false)
private String nickname;

@Column(name = "fcm_token")
@Column(name = "fcm_token", nullable = false)
private String fcmToken;

@Column(name = "birth", nullable = false)
Expand Down
191 changes: 191 additions & 0 deletions app/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
alter table if exists artist_search
drop constraint if exists fk_artist_artist_search;
alter table if exists show_search
drop constraint if exists fk_show_show_search;

drop table if exists admin cascade;
drop table if exists artist cascade;
drop table if exists artist_genre cascade;
drop table if exists artist_search cascade;
drop table if exists genre cascade;
drop table if exists interest_show cascade;
drop table if exists show cascade;
drop table if exists show_artist cascade;
drop table if exists show_genre cascade;
drop table if exists show_search cascade;
drop table if exists social_login cascade;
drop table if exists subscribe_artist cascade;
drop table if exists subscribe_genre cascade;
drop table if exists ticketing_alert cascade;
drop table if exists users cascade;

create table admin
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
email varchar(255) not null unique,
password varchar(255) not null,
primary key (id)
);
create table artist
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
country varchar(255) not null,
english_name varchar(255) not null,
gender varchar(255) not null check (gender in ('MAN', 'WOMAN')),
image varchar(255) not null,
korean_name varchar(255) not null,
type varchar(255) not null check (type in ('SOLO', 'GROUP')),
primary key (id)
);
create table artist_genre
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
artist_id uuid not null,
genre_id uuid not null,
id uuid not null,
primary key (id)
);
create table artist_search
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
artist_id uuid not null,
id uuid not null,
name varchar(255) not null,
primary key (id)
);
create table genre
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
name varchar(255) not null unique,
primary key (id)
);
create table interest_show
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
show_id uuid not null,
user_id uuid not null,
primary key (id)
);
create table show
(
date date not null,
is_deleted boolean not null,
create_at timestamp(6) not null,
ticket_open_time timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
content varchar(255) not null,
image varchar(255) not null,
location varchar(255) not null,
title varchar(255) not null,
seat_price jsonb not null,
ticketing jsonb not null,
primary key (id)
);
create table show_artist
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
artist_id uuid not null,
id uuid not null,
show_id uuid not null,
primary key (id)
);
create table show_genre
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
genre_id uuid not null,
id uuid not null,
show_id uuid not null,
primary key (id)
);
create table show_search
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
show_id uuid not null,
name varchar(255) not null,
primary key (id)
);
create table social_login
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
user_id uuid not null,
identifier varchar(255) not null,
social_login_type varchar(255) not null check (social_login_type in ('GOOGLE', 'KAKAO', 'APPLE')),
primary key (id),
constraint unq_social_login_type_identifier unique (social_login_type, identifier)
);
create table subscribe_artist
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
artist_id uuid not null,
id uuid not null,
user_id uuid not null,
primary key (id)
);
create table subscribe_genre
(
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
genre_id uuid not null,
id uuid not null,
user_id uuid not null,
primary key (id)
);
create table ticketing_alert
(
is_deleted boolean not null,
create_at timestamp(6) not null,
schedule_alert_time timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
show_id uuid not null,
user_id uuid not null,
name varchar(255) not null,
primary key (id)
);
create table users
(
birth date not null,
is_deleted boolean not null,
create_at timestamp(6) not null,
updated_at timestamp(6) not null,
id uuid not null,
fcm_token varchar(255) not null,
gender varchar(255) not null check (gender in ('MAN', 'WOMAN', 'NOT_CHOSEN')),
nickname varchar(255) not null,
role varchar(255) not null check (role in ('GUEST', 'USER', 'ADMIN')),
primary key (id)
);
alter table if exists artist_search
add constraint fk_artist_artist_search foreign key (artist_id) references artist;
alter table if exists show_search
add constraint fk_show_show_search foreign key (show_id) references show;
16 changes: 0 additions & 16 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
services:
postgresql:
container_name: yapp_postgresql
image: postgres:14
environment:
POSTGRES_DB: yapp
POSTGRES_USER: yapp
POSTGRES_PASSWORD: yapp
ports:
- '5432:5432'
restart: always
networks:
- app-network

redis:
container_name: yapp_redis
image: redis:alpine
Expand All @@ -26,9 +13,6 @@ services:
context: .
dockerfile: dockerfile-dev
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgresql:5432/yapp
SPRING_DATASOURCE_USERNAME: yapp
SPRING_DATASOURCE_PASSWORD: yapp
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
ports:
Expand Down
16 changes: 0 additions & 16 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
services:
postgresql:
container_name: yapp_postgresql
image: postgres:14
environment:
POSTGRES_DB: yapp
POSTGRES_USER: yapp
POSTGRES_PASSWORD: yapp
ports:
- '5432:5432'
restart: always
networks:
- app-network

redis:
container_name: yapp_redis
image: redis:alpine
Expand All @@ -26,9 +13,6 @@ services:
context: .
dockerfile: dockerfile-prod
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgresql:5432/yapp
SPRING_DATASOURCE_USERNAME: yapp
SPRING_DATASOURCE_PASSWORD: yapp
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
ports:
Expand Down

0 comments on commit 75fd349

Please sign in to comment.