Skip to content

Commit

Permalink
[OING-33] feat: DDL 작성 및 flyway 활성화 (#24)
Browse files Browse the repository at this point in the history
* feat: add sql DDL script

* feat: enable flyway

* fix: change url datatype to TEXT

* feat: change emoji to ascii

* test: fix s3 test
  • Loading branch information
CChuYong committed Jan 11, 2024
1 parent 3d0ab8b commit 551cf53
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
3 changes: 3 additions & 0 deletions gateway/src/main/resources/application-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ spring:
enabled: true
show_sql: false
format_sql: false
flyway:
enabled: true
baseline-on-migrate: true
h2:
console:
enabled: false
99 changes: 99 additions & 0 deletions gateway/src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
CREATE TABLE `app_version`
(
`app_key` CHAR(36) PRIMARY KEY COMMENT 'UUID',
`app_version` VARCHAR(36) NOT NULL,
`in_service` BOOL NOT NULL,
`in_review` BOOL NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '앱버전관리테이블';

CREATE TABLE `member`
(
`member_id` CHAR(26) NOT NULL COMMENT 'ULID',
`family_id` CHAR(26) DEFAULT NULL,
`day_of_birth` DATE NOT NULL,
`name` VARCHAR(36) NOT NULL,
`profile_img_url` TEXT,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL,
INDEX `member_idx1` (`family_id`),
PRIMARY KEY (`member_id`)
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '사용자테이블';

CREATE TABLE `social_member`
(
`provider` VARCHAR(16) NOT NULL COMMENT 'APPLE|KAKAO',
`identifier` VARCHAR(64) NOT NULL,
`member_id` CHAR(26) NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY `social_member_fk1` (member_id) REFERENCES `member`(member_id),
PRIMARY KEY (`provider`, `identifier`)
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '소셜로그인사용자테이블';

CREATE TABLE `member_device`
(
`member_id` CHAR(26) NOT NULL,
`fcm_token` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY `member_device_fk1` (member_id) REFERENCES `member`(member_id),
INDEX `member_device_idx1` (`fcm_token`),
PRIMARY KEY (`member_id`, `fcm_token`)
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '사용자기기테이블';

CREATE TABLE `family`
(
`family_id` CHAR(26) NOT NULL COMMENT 'ULID',
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`family_id`)
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '가족테이블';

CREATE TABLE `member_post`
(
`post_id` CHAR(26) NOT NULL COMMENT 'ULID',
`member_id` CHAR(26) NOT NULL,
`post_date` DATE NOT NULL,
`image_url` TEXT,
`comment_cnt` INTEGER NOT NULL DEFAULT 0,
`reaction_cnt` INTEGER NOT NULL DEFAULT 0,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX `member_post_idx1` (`member_id`),
PRIMARY KEY (`post_id`)
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '게시물테이블';

CREATE TABLE `member_post_reaction`
(
`reaction_id` CHAR(26) NOT NULL COMMENT 'ULID',
`post_id` CHAR(26) NOT NULL,
`member_id` CHAR(26) NOT NULL,
`ascii` VARCHAR(16) NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY `member_post_reaction_pk1` (post_id) REFERENCES `member_post`(`post_id`),
INDEX `member_post_reaction_idx1` (`post_id`),
INDEX `member_post_reaction_idx2` (`member_id`),
PRIMARY KEY (`reaction_id`)
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '게시물이모지';

CREATE TABLE `member_post_comment`
(
`comment_id` CHAR(26) NOT NULL COMMENT 'ULID',
`post_id` CHAR(26) NOT NULL,
`member_id` CHAR(26) NOT NULL,
`comment` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY `member_post_comment_pk1` (post_id) REFERENCES `member_post`(`post_id`),
INDEX `member_post_comment_idx1` (`post_id`),
INDEX `member_post_comment_idx2` (`member_id`),
PRIMARY KEY (`comment_id`)
) DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci comment '게시물댓글';
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void getPreSignedUrl() {
// then
Assertions.assertAll(
() -> assertNotNull(response),
() -> assertEquals(mockPresignedUrl.toString(), response.url())
() -> assertEquals(mockPresignedUrl.toString(), response.getUrl())
);
}
}

0 comments on commit 551cf53

Please sign in to comment.