From 1a33bae7f4517302e7596d065f052c8a92df138c Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:12:33 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E3=83=AA=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=A8=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=82=AB=E3=83=AB=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=82=92actor=E3=80=81Hideout=E8=87=AA=E8=BA=AB=E3=81=AE?= =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=82=92user=E3=81=AB?= =?UTF-8?q?=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V1__Init_DB.sql | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/main/resources/db/migration/V1__Init_DB.sql b/src/main/resources/db/migration/V1__Init_DB.sql index 234078e7..d1c00d0e 100644 --- a/src/main/resources/db/migration/V1__Init_DB.sql +++ b/src/main/resources/db/migration/V1__Init_DB.sql @@ -13,14 +13,13 @@ create table if not exists instance moderation_note varchar(10000) not null, created_at timestamp not null ); -create table if not exists users +create table if not exists actors ( id bigint primary key, "name" varchar(300) not null, "domain" varchar(1000) not null, screen_name varchar(300) not null, description varchar(10000) not null, - password varchar(255) null, inbox varchar(1000) not null unique, outbox varchar(1000) not null unique, url varchar(1000) not null unique, @@ -32,7 +31,17 @@ create table if not exists users followers varchar(1000) null, "instance" bigint null, unique ("name", "domain"), - constraint fk_users_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict + constraint fk_actors_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict +); + +create table if not exists user_details +( + id bigserial primary key, + actor_id bigint not null unique, + password varchar(255) null, + auto_accept_follow_request boolean not null, + auto_accept_followee_follow_request boolean not null, + constraint fk_user_details_actor_id__id foreign key (actor_id) references actors (id) on delete restrict on update restrict ); create table if not exists media @@ -58,7 +67,7 @@ create table if not exists meta_info create table if not exists posts ( id bigint primary key, - user_id bigint not null, + actor_id bigint not null, overview varchar(100) null, text varchar(3000) not null, created_at bigint not null, @@ -67,10 +76,10 @@ create table if not exists posts repost_id bigint null, reply_id bigint null, "sensitive" boolean default false not null, - ap_id varchar(100) not null unique + ap_id varchar(100) not null unique ); alter table posts - add constraint fk_posts_userid__id foreign key (user_id) references users (id) on delete restrict on update restrict; + add constraint fk_posts_actor_id__id foreign key (actor_id) references actors (id) on delete restrict on update restrict; alter table posts add constraint fk_posts_repostid__id foreign key (repost_id) references posts (id) on delete restrict on update restrict; alter table posts @@ -90,19 +99,19 @@ create table if not exists reactions id bigserial primary key, emoji_id bigint not null, post_id bigint not null, - user_id bigint not null + actor_id bigint not null ); alter table reactions add constraint fk_reactions_post_id__id foreign key (post_id) references posts (id) on delete restrict on update restrict; alter table reactions - add constraint fk_reactions_user_id__id foreign key (user_id) references users (id) on delete restrict on update restrict; + add constraint fk_reactions_actor_id__id foreign key (actor_id) references actors (id) on delete restrict on update restrict; create table if not exists timelines ( id bigint primary key, user_id bigint not null, timeline_id bigint not null, post_id bigint not null, - post_user_id bigint not null, + post_actor_id bigint not null, created_at bigint not null, reply_id bigint null, repost_id bigint null, @@ -177,14 +186,14 @@ create table if not exists registered_client create table if not exists relationships ( id bigserial primary key, - user_id bigint not null, - target_user_id bigint not null, + actor_id bigint not null, + target_actor_id bigint not null, following boolean not null, blocking boolean not null, muting boolean not null, follow_request boolean not null, ignore_follow_request boolean not null, - constraint fk_relationships_user_id__id foreign key (user_id) references users (id) on delete restrict on update restrict, - constraint fk_relationships_target_user_id__id foreign key (target_user_id) references users (id) on delete restrict on update restrict, - unique (user_id, target_user_id) + constraint fk_relationships_actor_id__id foreign key (actor_id) references actors (id) on delete restrict on update restrict, + constraint fk_relationships_target_actor_id__id foreign key (target_actor_id) references actors (id) on delete restrict on update restrict, + unique (actor_id, target_actor_id) )