Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ext {
jwtVersion = '0.13.0'
passwordEncoderVersion = '6.4.5'
swaggerUIVersion = '2.2.0'
flywayVersion = '11.19.0'
}

java {
Expand Down Expand Up @@ -74,6 +75,9 @@ dependencies {

// * Swagger UI
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${swaggerUIVersion}"

// * Flyway
implementation "org.flywaydb:flyway-mysql:${flywayVersion}"
}

tasks.named('test') {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/example/bak/user/domain/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Profile {
@Column(nullable = false)
private String nickname;

@Column(name = "user_id")
private Long userId;

private Profile(Long id, String name, String nickname) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/example/bak/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class User {
@Column(nullable = false)
private String password;

@Column(name = "profile_id")
private Long profileId;

@Enumerated(EnumType.STRING)
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/application-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ spring:
h2:
console:
enabled: false
flyway:
enabled: true
locations:
- classpath:db/migration
baseline-on-migrate: true
baseline-version: 0
clean-disabled: false # (Caution!) Progress in Dev Environment

springdoc:
swagger-ui:
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/application-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ spring:

jpa:
hibernate:
ddl-auto: update
ddl-auto: none
properties:
hibernate:
format_sql: false
show_sql: false
dialect: org.hibernate.dialect.MySQL8Dialect
open-in-view: false

flyway:
enabled: true
locations:
- classpath:db/migration
baseline-on-migrate: true
baseline-version: 0

springdoc:
swagger-ui:
path: /api-test
Expand Down
81 changes: 81 additions & 0 deletions src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
-- Create companies table
CREATE TABLE companies
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
career_link VARCHAR(500) NOT NULL,
logo_url VARCHAR(500) NOT NULL,
description TEXT NOT NULL
);

-- Create communities table
CREATE TABLE communities
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
job_group VARCHAR(255) NOT NULL,
company_id BIGINT
);

-- Create profiles table
CREATE TABLE profiles
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
nickname VARCHAR(255) NOT NULL,
user_id BIGINT
);

-- Create users table
CREATE TABLE users
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role VARCHAR(50) DEFAULT 'NORMAL',
profile_id BIGINT NOT NULL
);

-- Create feeds table
CREATE TABLE feeds
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
community_id BIGINT NOT NULL,
author_id BIGINT NOT NULL
);

-- Create comments table
CREATE TABLE comments
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
feed_id BIGINT NOT NULL,
author_id BIGINT NOT NULL,
author_nickname VARCHAR(255) NOT NULL,
content VARCHAR(1000) NOT NULL
);

-- Create private_messages table
CREATE TABLE private_messages
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
sender_id BIGINT NOT NULL,
receiver_id BIGINT NOT NULL,
content VARCHAR(1000) NOT NULL,
read_at DATETIME,
deleted_at_by_sender DATETIME,
deleted_at_by_receiver DATETIME,
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)
);

-- Create indexes for better query performance
CREATE INDEX idx_users_email ON users (email);
CREATE INDEX idx_feeds_author ON feeds (author_id);
CREATE INDEX idx_feeds_community ON feeds (community_id);
CREATE INDEX idx_comments_feed ON comments (feed_id);
CREATE INDEX idx_comments_author ON comments (author_id);
CREATE INDEX idx_private_messages_sender ON private_messages (sender_id);
CREATE INDEX idx_private_messages_receiver ON private_messages (receiver_id);
CREATE INDEX idx_communities_company ON communities (company_id);
Loading