Add member db schema
- add member db schema - rename queryMapper - extract ddl, dml script
This commit is contained in:
@@ -10,6 +10,7 @@ import lombok.ToString;
|
||||
public final class Account {
|
||||
|
||||
private Long id;
|
||||
private Long memberId;
|
||||
private String email;
|
||||
private String password;
|
||||
private String emailCheckToken;
|
||||
|
||||
@@ -17,6 +17,7 @@ public class DatabaseConfiguration {
|
||||
return new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("classpath:sql/ddl.sql")
|
||||
.addScript("classpath:sql/dml.sql")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
0
src/main/java/com/yam/app/member/domain/empty.txt
Normal file
0
src/main/java/com/yam/app/member/domain/empty.txt
Normal file
@@ -9,12 +9,6 @@
|
||||
WHERE email = #{email}
|
||||
</select>
|
||||
|
||||
<select id="existsByNickname" parameterType="String" resultType="boolean">
|
||||
SELECT COUNT(nickname)
|
||||
FROM ACCOUNT
|
||||
WHERE nickname = #{nickname}
|
||||
</select>
|
||||
|
||||
<select id="findByEmail" parameterType="String"
|
||||
resultType="com.yam.app.account.domain.Account">
|
||||
SELECT * FROM ACCOUNT WHERE email = #{email}
|
||||
@@ -11,16 +11,22 @@ create table account
|
||||
password varchar(255) not null,
|
||||
withdraw boolean not null,
|
||||
withdrawal_at timestamp,
|
||||
member_id bigint,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table member(
|
||||
id bigint generated by default as identity,
|
||||
nickname varchar(255) not null,
|
||||
image varchar(255) not null,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
alter table account
|
||||
add constraint UK_q0uja26qgu1atulenwup9rxyr unique (email);
|
||||
|
||||
insert into account(email, email_check_token, email_check_token_generated_at, email_verified,
|
||||
joined_at, last_modified_at, password, withdraw, role)
|
||||
values ('jiwonDev@gmail.com', 'emailchecktoken', now(), false, now(), now(), 'password!',
|
||||
false, 'DEFAULT'),
|
||||
('loginCheck@gmail.com', 'emailchecktoken1', now(), true, now(), now(),
|
||||
'$2a$10$EqbMbYB0vcZnuA5CClqa9uiLDnjA6pCjxn208ZchzA2q3ofqnkhcq',
|
||||
false, 'DEFAULT');
|
||||
alter table member
|
||||
add constraint UK_hh9kg6jti4n1eoiertn2k6qsc unique (nickname);
|
||||
|
||||
alter table account
|
||||
add constraint FKr5j0huynd7nsv1s7e9vb8qvwo foreign key (member_id) references member;
|
||||
|
||||
7
src/main/resources/sql/dml.sql
Normal file
7
src/main/resources/sql/dml.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
insert into account(email, email_check_token, email_check_token_generated_at, email_verified,
|
||||
joined_at, last_modified_at, password, withdraw, role)
|
||||
values ('jiwonDev@gmail.com', 'emailchecktoken', now(), false, now(), now(), 'password!',
|
||||
false, 'DEFAULT'),
|
||||
('loginCheck@gmail.com', 'emailchecktoken1', now(), true, now(), now(),
|
||||
'$2a$10$EqbMbYB0vcZnuA5CClqa9uiLDnjA6pCjxn208ZchzA2q3ofqnkhcq',
|
||||
false, 'DEFAULT');
|
||||
@@ -24,7 +24,8 @@ final class RegisterAccountProcessorTest {
|
||||
return Arrays.asList(
|
||||
DynamicTest.dynamicTest("회원가입에 성공한다.", () -> {
|
||||
// Act
|
||||
var account = processor.register("rebwon@gmail.com", "password!");
|
||||
processor.register("rebwon@gmail.com", "password!");
|
||||
var account = reader.findByEmail("rebwon@gmail.com").get();
|
||||
|
||||
// Assert
|
||||
assertThat(account.getId()).isEqualTo(1L);
|
||||
|
||||
Reference in New Issue
Block a user