diff --git a/doorip-api/build.gradle b/doorip-api/build.gradle index 6c7cae5..048c55c 100644 --- a/doorip-api/build.gradle +++ b/doorip-api/build.gradle @@ -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') diff --git a/doorip-api/src/main/resources/db/migration/V1__ddl.sql b/doorip-api/src/main/resources/db/migration/V1__ddl.sql new file mode 100644 index 0000000..02f2a4e --- /dev/null +++ b/doorip-api/src/main/resources/db/migration/V1__ddl.sql @@ -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) +); \ No newline at end of file diff --git a/doorip-domain/src/main/java/org/doorip/trip/domain/Participant.java b/doorip-domain/src/main/java/org/doorip/trip/domain/Participant.java index fd58ae8..6e6c70b 100644 --- a/doorip-domain/src/main/java/org/doorip/trip/domain/Participant.java +++ b/doorip-domain/src/main/java/org/doorip/trip/domain/Participant.java @@ -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") diff --git a/doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java b/doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java index 265bf39..84139b1 100644 --- a/doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java +++ b/doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java @@ -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)