Skip to content

Commit

Permalink
Merge pull request #10 from Team-Going/feature/8
Browse files Browse the repository at this point in the history
[chore] 데이터베이스 마이그레이션 flyway 라이브러리 적용
  • Loading branch information
SunwoongH authored Jan 5, 2024
2 parents af61733 + 457eeee commit f121d8c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
2 changes: 2 additions & 0 deletions doorip-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ dependencies {
implementation group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.5'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
implementation "org.flywaydb:flyway-core"
implementation "org.flywaydb:flyway-mysql"
implementation project(path: ':doorip-domain')
implementation project(path: ':doorip-external')
implementation project(path: ':doorip-common')
Expand Down
70 changes: 70 additions & 0 deletions doorip-api/src/main/resources/db/migration/V1__ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
create table users
(
created_date timestamp(6),
last_modified_date timestamp(6),
user_id bigint auto_increment,
name varchar(255) not null,
intro varchar(255) not null,
result integer,
platform_id varchar(255) not null,
platform varchar(255) check (platform in ('KAKAO', 'APPLE')),
refresh_token varchar(255),
primary key (user_id)
);

create table trip
(
created_date timestamp(6),
last_modified_date timestamp(6),
trip_id bigint auto_increment,
title varchar(255) not null,
start_date date not null,
end_date date not null,
code varchar(255) not null,
primary key (trip_id)
);

create table participant
(
created_date timestamp(6),
last_modified_date timestamp(6),
participant_id bigint auto_increment,
user_id bigint unique,
trip_id bigint unique,
role varchar(255) check (role in ('HOST', 'PARTICIPATION')),
style_a integer not null,
style_b integer not null,
style_c integer not null,
style_d integer not null,
style_e integer not null,
primary key (participant_id),
foreign key (user_id) references users (user_id),
foreign key (trip_id) references trip (trip_id)
);

create table todo
(
created_date timestamp(6),
last_modified_date timestamp(6),
todo_id bigint auto_increment,
trip_id bigint unique,
title varchar(255) not null,
end_date date,
memo varchar(255),
secret varchar(255) check (secret in ('OUR', 'MY')),
progress varchar(255) check (progress in ('INCOMPLETE', 'COMPLETE')),
primary key (todo_id),
foreign key (trip_id) references trip (trip_id)
);

create table allocator
(
created_date timestamp(6),
last_modified_date timestamp(6),
allocator_id bigint auto_increment,
participant_id bigint unique,
todo_id bigint unique,
primary key (allocator_id),
foreign key (participant_id) references participant (participant_id),
foreign key (todo_id) references todo (todo_id)
);
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public class Participant extends BaseTimeEntity {
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private Role role;
@Column(nullable = false)
@Column(nullable = false, name = "style_a")
private Integer styleA;
@Column(nullable = false)
@Column(nullable = false, name = "style_b")
private Integer styleB;
@Column(nullable = false)
@Column(nullable = false, name = "style_c")
private Integer styleC;
@Column(nullable = false)
@Column(nullable = false, name = "style_d")
private Integer styleD;
@Column(nullable = false)
@Column(nullable = false, name = "style_e")
private Integer styleE;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Entity
public class Trip extends BaseTimeEntity {
@Id
@GeneratedValue
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "trip_id")
private Long id;
@Column(nullable = false)
Expand Down

0 comments on commit f121d8c

Please sign in to comment.