diff --git a/.github/workflows/showpot-dev-cd.yml b/.github/workflows/showpot-dev-cd.yml index 32dbe9da..242edb62 100644 --- a/.github/workflows/showpot-dev-cd.yml +++ b/.github/workflows/showpot-dev-cd.yml @@ -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 diff --git a/.github/workflows/showpot-dev-ci.yml b/.github/workflows/showpot-dev-ci.yml index f5209822..bad4ce7b 100644 --- a/.github/workflows/showpot-dev-ci.yml +++ b/.github/workflows/showpot-dev-ci.yml @@ -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 diff --git a/.github/workflows/showpot-prod-ci.yml b/.github/workflows/showpot-prod-ci.yml index 47c3f1eb..8383143b 100644 --- a/.github/workflows/showpot-prod-ci.yml +++ b/.github/workflows/showpot-prod-ci.yml @@ -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 diff --git a/app/domain/common-domain/src/main/resources/application-domain-dev.yml b/app/domain/common-domain/src/main/resources/application-domain-dev.yml index 2ebac146..e8423075 100644 --- a/app/domain/common-domain/src/main/resources/application-domain-dev.yml +++ b/app/domain/common-domain/src/main/resources/application-domain-dev.yml @@ -1,7 +1,10 @@ spring: - jpa: - hibernate: - ddl-auto: create - show-sql: true - open-in-view: false - generate-ddl: true \ No newline at end of file + 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 \ No newline at end of file diff --git a/app/domain/common-domain/src/main/resources/application-domain-prod.yml b/app/domain/common-domain/src/main/resources/application-domain-prod.yml index e69de29b..e1422c9d 100644 --- a/app/domain/common-domain/src/main/resources/application-domain-prod.yml +++ b/app/domain/common-domain/src/main/resources/application-domain-prod.yml @@ -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 \ No newline at end of file diff --git a/app/domain/show-domain/src/main/java/org/example/entity/artist/ArtistSearch.java b/app/domain/show-domain/src/main/java/org/example/entity/artist/ArtistSearch.java index 27e55ed4..0e5326eb 100644 --- a/app/domain/show-domain/src/main/java/org/example/entity/artist/ArtistSearch.java +++ b/app/domain/show-domain/src/main/java/org/example/entity/artist/ArtistSearch.java @@ -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; } diff --git a/app/domain/show-domain/src/main/java/org/example/entity/show/ShowSearch.java b/app/domain/show-domain/src/main/java/org/example/entity/show/ShowSearch.java index 760802e4..e95ba128 100644 --- a/app/domain/show-domain/src/main/java/org/example/entity/show/ShowSearch.java +++ b/app/domain/show-domain/src/main/java/org/example/entity/show/ShowSearch.java @@ -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; } diff --git a/app/domain/user-domain/src/main/java/org/example/entity/User.java b/app/domain/user-domain/src/main/java/org/example/entity/User.java index 003ddfdd..35fa68c9 100644 --- a/app/domain/user-domain/src/main/java/org/example/entity/User.java +++ b/app/domain/user-domain/src/main/java/org/example/entity/User.java @@ -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) diff --git a/app/src/main/resources/schema.sql b/app/src/main/resources/schema.sql new file mode 100644 index 00000000..dbc0a3cd --- /dev/null +++ b/app/src/main/resources/schema.sql @@ -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; \ No newline at end of file diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 50c18e98..c6435cac 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -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 @@ -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: diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index c390f92a..11403f67 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -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 @@ -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: