우리맵

create table couple
(
    id                bigint auto_increment
        primary key,
    start_date        date     not null,
    created_date_time datetime not null,
    updated_date_time datetime not null
);

create table invite_code
(
    code             varchar(255) not null
        primary key,
    inviter_id       bigint       not null,
    expire_date_time datetime     not null
);

create table member
(
    id                bigint auto_increment
        primary key,
    couple_id         bigint       null,
    email             varchar(255) not null,
    password          varchar(255) not null,
    nickname          varchar(255) not null,
    image_url         varchar(255) null,
    created_date_time datetime     not null,
    updated_date_time datetime     not null,
    constraint email
        unique (email),
    constraint fk_member_to_couple
        foreign key (couple_id) references couple (id)
);

create table notification
(
    id                    bigint auto_increment
        primary key,
    content               varchar(255) not null,
    notification_type     varchar(255) not null,
    is_read               bit          not null,
    send_member_nick_name varchar(255) not null,
    receive_member_id     bigint       not null,
    content_id            bigint       not null,
    created_date_time     datetime     not null
);

create index receive_member_id_index
    on notification (receive_member_id);

create table post
(
    id                bigint auto_increment
        primary key,
    couple_id         bigint         not null,
    title             varchar(255)   not null,
    content           longtext       not null,
    latitude          decimal(10, 8) not null,
    longitude         decimal(11, 8) not null,
    created_date_time datetime       not null,
    updated_date_time datetime       not null,
    dating_date       date           not null,
    constraint fk_post_to_couple
        foreign key (couple_id) references couple (id)
            on update cascade on delete cascade
);

create table post_image
(
    id        bigint auto_increment
        primary key,
    post_id   bigint       not null,
    image_url varchar(255) not null,
    constraint fk_post_image_to_post
        foreign key (post_id) references post (id)
            on update cascade on delete cascade
);

create table tag
(
    id        bigint auto_increment
        primary key,
    name      varchar(10) not null,
    color     varchar(25) not null,
    couple_id bigint      not null,
    constraint fk_tag_to_couple
        foreign key (couple_id) references couple (id)
            on update cascade on delete cascade
);

create table post_tag
(
    id      bigint auto_increment
        primary key,
    post_id bigint not null,
    tag_id  bigint not null,
    constraint fk_post_tag_to_post
        foreign key (post_id) references post (id),
    constraint fk_post_tag_to_tag
        foreign key (tag_id) references tag (id)
);