mirror of https://github.com/usbharu/Hideout.git
feat: PostgreSQLで使用できるように
This commit is contained in:
parent
9ce7b6e6dd
commit
699dceea2e
|
@ -1,188 +1,188 @@
|
||||||
CREATE TABLE IF NOT EXISTS "INSTANCE"
|
create table if not exists instance
|
||||||
(
|
(
|
||||||
ID BIGINT PRIMARY KEY,
|
id bigint primary key,
|
||||||
"NAME" VARCHAR(1000) NOT NULL,
|
"name" varchar(1000) not null,
|
||||||
DESCRIPTION VARCHAR(5000) NOT NULL,
|
description varchar(5000) not null,
|
||||||
URL VARCHAR(255) NOT NULL,
|
url varchar(255) not null,
|
||||||
ICON_URL VARCHAR(255) NOT NULL,
|
icon_url varchar(255) not null,
|
||||||
SHARED_INBOX VARCHAR(255) NULL,
|
shared_inbox varchar(255) null,
|
||||||
SOFTWARE VARCHAR(255) NOT NULL,
|
software varchar(255) not null,
|
||||||
VERSION VARCHAR(255) NOT NULL,
|
version varchar(255) not null,
|
||||||
IS_BLOCKED BOOLEAN NOT NULL,
|
is_blocked boolean not null,
|
||||||
IS_MUTED BOOLEAN NOT NULL,
|
is_muted boolean not null,
|
||||||
MODERATION_NOTE VARCHAR(10000) NOT NULL,
|
moderation_note varchar(10000) not null,
|
||||||
CREATED_AT TIMESTAMP NOT NULL
|
created_at timestamp not null
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS USERS
|
create table if not exists users
|
||||||
(
|
(
|
||||||
ID BIGINT PRIMARY KEY,
|
id bigint primary key,
|
||||||
"NAME" VARCHAR(300) NOT NULL,
|
"name" varchar(300) not null,
|
||||||
"DOMAIN" VARCHAR(1000) NOT NULL,
|
"domain" varchar(1000) not null,
|
||||||
SCREEN_NAME VARCHAR(300) NOT NULL,
|
screen_name varchar(300) not null,
|
||||||
DESCRIPTION VARCHAR(10000) NOT NULL,
|
description varchar(10000) not null,
|
||||||
PASSWORD VARCHAR(255) NULL,
|
password varchar(255) null,
|
||||||
INBOX VARCHAR(1000) NOT NULL,
|
inbox varchar(1000) not null,
|
||||||
OUTBOX VARCHAR(1000) NOT NULL,
|
outbox varchar(1000) not null,
|
||||||
URL VARCHAR(1000) NOT NULL,
|
url varchar(1000) not null,
|
||||||
PUBLIC_KEY VARCHAR(10000) NOT NULL,
|
public_key varchar(10000) not null,
|
||||||
PRIVATE_KEY VARCHAR(10000) NULL,
|
private_key varchar(10000) null,
|
||||||
CREATED_AT BIGINT NOT NULL,
|
created_at bigint not null,
|
||||||
KEY_ID VARCHAR(1000) NOT NULL,
|
key_id varchar(1000) not null,
|
||||||
"FOLLOWING" VARCHAR(1000) NULL,
|
"following" varchar(1000) null,
|
||||||
FOLLOWERS VARCHAR(1000) NULL,
|
followers varchar(1000) null,
|
||||||
"INSTANCE" BIGINT NULL,
|
"instance" bigint null,
|
||||||
CONSTRAINT FK_USERS_INSTANCE__ID FOREIGN KEY ("INSTANCE") REFERENCES "INSTANCE" (ID) ON DELETE RESTRICT ON UPDATE RESTRICT
|
constraint fk_users_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS FOLLOW_REQUESTS
|
create table if not exists follow_requests
|
||||||
(
|
(
|
||||||
ID BIGSERIAL PRIMARY KEY,
|
id bigserial primary key,
|
||||||
USER_ID BIGINT NOT NULL,
|
user_id bigint not null,
|
||||||
FOLLOWER_ID BIGINT NOT NULL,
|
follower_id bigint not null,
|
||||||
CONSTRAINT FK_FOLLOW_REQUESTS_USER_ID__ID FOREIGN KEY (USER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
constraint fk_follow_requests_user_id__id foreign key (user_id) references users (id) on delete restrict on update restrict,
|
||||||
CONSTRAINT FK_FOLLOW_REQUESTS_FOLLOWER_ID__ID FOREIGN KEY (FOLLOWER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT
|
constraint fk_follow_requests_follower_id__id foreign key (follower_id) references users (id) on delete restrict on update restrict
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS MEDIA
|
create table if not exists media
|
||||||
(
|
(
|
||||||
ID BIGINT PRIMARY KEY,
|
id bigint primary key,
|
||||||
"NAME" VARCHAR(255) NOT NULL,
|
"name" varchar(255) not null,
|
||||||
URL VARCHAR(255) NOT NULL,
|
url varchar(255) not null,
|
||||||
REMOTE_URL VARCHAR(255) NULL,
|
remote_url varchar(255) null,
|
||||||
THUMBNAIL_URL VARCHAR(255) NULL,
|
thumbnail_url varchar(255) null,
|
||||||
"TYPE" INT NOT NULL,
|
"type" int not null,
|
||||||
BLURHASH VARCHAR(255) NULL,
|
blurhash varchar(255) null,
|
||||||
MIME_TYPE VARCHAR(255) NOT NULL,
|
mime_type varchar(255) not null,
|
||||||
DESCRIPTION VARCHAR(4000) NULL
|
description varchar(4000) null
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS META_INFO
|
create table if not exists meta_info
|
||||||
(
|
(
|
||||||
ID BIGINT PRIMARY KEY,
|
id bigint primary key,
|
||||||
VERSION VARCHAR(1000) NOT NULL,
|
version varchar(1000) not null,
|
||||||
KID VARCHAR(1000) NOT NULL,
|
kid varchar(1000) not null,
|
||||||
JWT_PRIVATE_KEY VARCHAR(100000) NOT NULL,
|
jwt_private_key varchar(100000) not null,
|
||||||
JWT_PUBLIC_KEY VARCHAR(100000) NOT NULL
|
jwt_public_key varchar(100000) not null
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS POSTS
|
create table if not exists posts
|
||||||
(
|
(
|
||||||
ID BIGINT PRIMARY KEY,
|
id bigint primary key,
|
||||||
USER_ID BIGINT NOT NULL,
|
user_id bigint not null,
|
||||||
OVERVIEW VARCHAR(100) NULL,
|
overview varchar(100) null,
|
||||||
TEXT VARCHAR(3000) NOT NULL,
|
text varchar(3000) not null,
|
||||||
CREATED_AT BIGINT NOT NULL,
|
created_at bigint not null,
|
||||||
VISIBILITY INT DEFAULT 0 NOT NULL,
|
visibility int default 0 not null,
|
||||||
URL VARCHAR(500) NOT NULL,
|
url varchar(500) not null,
|
||||||
REPOST_ID BIGINT NULL,
|
repost_id bigint null,
|
||||||
REPLY_ID BIGINT NULL,
|
reply_id bigint null,
|
||||||
"SENSITIVE" BOOLEAN DEFAULT FALSE NOT NULL,
|
"sensitive" boolean default false not null,
|
||||||
AP_ID VARCHAR(100) NOT NULL
|
ap_id varchar(100) not null
|
||||||
);
|
);
|
||||||
ALTER TABLE POSTS
|
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_userid__id foreign key (user_id) references users (id) on delete restrict on update restrict;
|
||||||
ALTER TABLE POSTS
|
alter table posts
|
||||||
ADD CONSTRAINT FK_POSTS_REPOSTID__ID FOREIGN KEY (REPOST_ID) REFERENCES POSTS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
add constraint fk_posts_repostid__id foreign key (repost_id) references posts (id) on delete restrict on update restrict;
|
||||||
ALTER TABLE POSTS
|
alter table posts
|
||||||
ADD CONSTRAINT FK_POSTS_REPLYID__ID FOREIGN KEY (REPLY_ID) REFERENCES POSTS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
add constraint fk_posts_replyid__id foreign key (reply_id) references posts (id) on delete restrict on update restrict;
|
||||||
CREATE TABLE IF NOT EXISTS POSTS_MEDIA
|
create table if not exists posts_media
|
||||||
(
|
(
|
||||||
POST_ID BIGINT,
|
post_id bigint,
|
||||||
MEDIA_ID BIGINT,
|
media_id bigint,
|
||||||
CONSTRAINT pk_PostsMedia PRIMARY KEY (POST_ID, MEDIA_ID)
|
constraint pk_postsmedia primary key (post_id, media_id)
|
||||||
);
|
);
|
||||||
ALTER TABLE POSTS_MEDIA
|
alter table posts_media
|
||||||
ADD CONSTRAINT FK_POSTS_MEDIA_POST_ID__ID FOREIGN KEY (POST_ID) REFERENCES POSTS (ID) ON DELETE CASCADE ON UPDATE CASCADE;
|
add constraint fk_posts_media_post_id__id foreign key (post_id) references posts (id) on delete cascade on update cascade;
|
||||||
ALTER TABLE POSTS_MEDIA
|
alter table posts_media
|
||||||
ADD CONSTRAINT FK_POSTS_MEDIA_MEDIA_ID__ID FOREIGN KEY (MEDIA_ID) REFERENCES MEDIA (ID) ON DELETE CASCADE ON UPDATE CASCADE;
|
add constraint fk_posts_media_media_id__id foreign key (media_id) references media (id) on delete cascade on update cascade;
|
||||||
CREATE TABLE IF NOT EXISTS REACTIONS
|
create table if not exists reactions
|
||||||
(
|
(
|
||||||
ID BIGSERIAL PRIMARY KEY,
|
id bigserial primary key,
|
||||||
EMOJI_ID BIGINT NOT NULL,
|
emoji_id bigint not null,
|
||||||
POST_ID BIGINT NOT NULL,
|
post_id bigint not null,
|
||||||
USER_ID BIGINT NOT NULL
|
user_id bigint not null
|
||||||
);
|
);
|
||||||
ALTER TABLE REACTIONS
|
alter table reactions
|
||||||
ADD CONSTRAINT FK_REACTIONS_POST_ID__ID FOREIGN KEY (POST_ID) REFERENCES POSTS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
add constraint fk_reactions_post_id__id foreign key (post_id) references posts (id) on delete restrict on update restrict;
|
||||||
ALTER TABLE REACTIONS
|
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_user_id__id foreign key (user_id) references users (id) on delete restrict on update restrict;
|
||||||
CREATE TABLE IF NOT EXISTS TIMELINES
|
create table if not exists timelines
|
||||||
(
|
(
|
||||||
ID BIGINT PRIMARY KEY,
|
id bigint primary key,
|
||||||
USER_ID BIGINT NOT NULL,
|
user_id bigint not null,
|
||||||
TIMELINE_ID BIGINT NOT NULL,
|
timeline_id bigint not null,
|
||||||
POST_ID BIGINT NOT NULL,
|
post_id bigint not null,
|
||||||
POST_USER_ID BIGINT NOT NULL,
|
post_user_id bigint not null,
|
||||||
CREATED_AT BIGINT NOT NULL,
|
created_at bigint not null,
|
||||||
REPLY_ID BIGINT NULL,
|
reply_id bigint null,
|
||||||
REPOST_ID BIGINT NULL,
|
repost_id bigint null,
|
||||||
VISIBILITY INT NOT NULL,
|
visibility int not null,
|
||||||
"SENSITIVE" BOOLEAN NOT NULL,
|
"sensitive" boolean not null,
|
||||||
IS_LOCAL BOOLEAN NOT NULL,
|
is_local boolean not null,
|
||||||
IS_PURE_REPOST BOOLEAN NOT NULL,
|
is_pure_repost boolean not null,
|
||||||
MEDIA_IDS VARCHAR(255) NOT NULL
|
media_ids varchar(255) not null
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS USERS_FOLLOWERS
|
create table if not exists users_followers
|
||||||
(
|
(
|
||||||
ID BIGSERIAL PRIMARY KEY,
|
id bigserial primary key,
|
||||||
USER_ID BIGINT NOT NULL,
|
user_id bigint not null,
|
||||||
FOLLOWER_ID BIGINT NOT NULL,
|
follower_id bigint not null,
|
||||||
CONSTRAINT FK_USERS_FOLLOWERS_USER_ID__ID FOREIGN KEY (USER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
constraint fk_users_followers_user_id__id foreign key (user_id) references users (id) on delete restrict on update restrict,
|
||||||
CONSTRAINT FK_USERS_FOLLOWERS_FOLLOWER_ID__ID FOREIGN KEY (FOLLOWER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT
|
constraint fk_users_followers_follower_id__id foreign key (follower_id) references users (id) on delete restrict on update restrict
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS APPLICATION_AUTHORIZATION
|
create table if not exists application_authorization
|
||||||
(
|
(
|
||||||
ID VARCHAR(255) PRIMARY KEY,
|
id varchar(255) primary key,
|
||||||
REGISTERED_CLIENT_ID VARCHAR(255) NOT NULL,
|
registered_client_id varchar(255) not null,
|
||||||
PRINCIPAL_NAME VARCHAR(255) NOT NULL,
|
principal_name varchar(255) not null,
|
||||||
AUTHORIZATION_GRANT_TYPE VARCHAR(255) NOT NULL,
|
authorization_grant_type varchar(255) not null,
|
||||||
AUTHORIZED_SCOPES VARCHAR(1000) DEFAULT NULL NULL,
|
authorized_scopes varchar(1000) default null null,
|
||||||
"ATTRIBUTES" VARCHAR(4000) DEFAULT NULL NULL,
|
"attributes" varchar(4000) default null null,
|
||||||
"STATE" VARCHAR(500) DEFAULT NULL NULL,
|
"state" varchar(500) default null null,
|
||||||
AUTHORIZATION_CODE_VALUE VARCHAR(4000) DEFAULT NULL NULL,
|
authorization_code_value varchar(4000) default null null,
|
||||||
AUTHORIZATION_CODE_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
|
authorization_code_issued_at timestamp default null null,
|
||||||
AUTHORIZATION_CODE_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
|
authorization_code_expires_at timestamp default null null,
|
||||||
AUTHORIZATION_CODE_METADATA VARCHAR(2000) DEFAULT NULL NULL,
|
authorization_code_metadata varchar(2000) default null null,
|
||||||
ACCESS_TOKEN_VALUE VARCHAR(4000) DEFAULT NULL NULL,
|
access_token_value varchar(4000) default null null,
|
||||||
ACCESS_TOKEN_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
|
access_token_issued_at timestamp default null null,
|
||||||
ACCESS_TOKEN_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
|
access_token_expires_at timestamp default null null,
|
||||||
ACCESS_TOKEN_METADATA VARCHAR(2000) DEFAULT NULL NULL,
|
access_token_metadata varchar(2000) default null null,
|
||||||
ACCESS_TOKEN_TYPE VARCHAR(255) DEFAULT NULL NULL,
|
access_token_type varchar(255) default null null,
|
||||||
ACCESS_TOKEN_SCOPES VARCHAR(1000) DEFAULT NULL NULL,
|
access_token_scopes varchar(1000) default null null,
|
||||||
REFRESH_TOKEN_VALUE VARCHAR(4000) DEFAULT NULL NULL,
|
refresh_token_value varchar(4000) default null null,
|
||||||
REFRESH_TOKEN_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
|
refresh_token_issued_at timestamp default null null,
|
||||||
REFRESH_TOKEN_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
|
refresh_token_expires_at timestamp default null null,
|
||||||
REFRESH_TOKEN_METADATA VARCHAR(2000) DEFAULT NULL NULL,
|
refresh_token_metadata varchar(2000) default null null,
|
||||||
OIDC_ID_TOKEN_VALUE VARCHAR(4000) DEFAULT NULL NULL,
|
oidc_id_token_value varchar(4000) default null null,
|
||||||
OIDC_ID_TOKEN_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
|
oidc_id_token_issued_at timestamp default null null,
|
||||||
OIDC_ID_TOKEN_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
|
oidc_id_token_expires_at timestamp default null null,
|
||||||
OIDC_ID_TOKEN_METADATA VARCHAR(2000) DEFAULT NULL NULL,
|
oidc_id_token_metadata varchar(2000) default null null,
|
||||||
OIDC_ID_TOKEN_CLAIMS VARCHAR(2000) DEFAULT NULL NULL,
|
oidc_id_token_claims varchar(2000) default null null,
|
||||||
USER_CODE_VALUE VARCHAR(4000) DEFAULT NULL NULL,
|
user_code_value varchar(4000) default null null,
|
||||||
USER_CODE_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
|
user_code_issued_at timestamp default null null,
|
||||||
USER_CODE_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
|
user_code_expires_at timestamp default null null,
|
||||||
USER_CODE_METADATA VARCHAR(2000) DEFAULT NULL NULL,
|
user_code_metadata varchar(2000) default null null,
|
||||||
DEVICE_CODE_VALUE VARCHAR(4000) DEFAULT NULL NULL,
|
device_code_value varchar(4000) default null null,
|
||||||
DEVICE_CODE_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
|
device_code_issued_at timestamp default null null,
|
||||||
DEVICE_CODE_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
|
device_code_expires_at timestamp default null null,
|
||||||
DEVICE_CODE_METADATA VARCHAR(2000) DEFAULT NULL NULL
|
device_code_metadata varchar(2000) default null null
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS OAUTH2_AUTHORIZATION_CONSENT
|
create table if not exists oauth2_authorization_consent
|
||||||
(
|
(
|
||||||
REGISTERED_CLIENT_ID VARCHAR(100),
|
registered_client_id varchar(100),
|
||||||
PRINCIPAL_NAME VARCHAR(200),
|
principal_name varchar(200),
|
||||||
AUTHORITIES VARCHAR(1000) NOT NULL,
|
authorities varchar(1000) not null,
|
||||||
CONSTRAINT pk_oauth2_authorization_consent PRIMARY KEY (REGISTERED_CLIENT_ID, PRINCIPAL_NAME)
|
constraint pk_oauth2_authorization_consent primary key (registered_client_id, principal_name)
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS REGISTERED_CLIENT
|
create table if not exists registered_client
|
||||||
(
|
(
|
||||||
ID VARCHAR(100) PRIMARY KEY,
|
id varchar(100) primary key,
|
||||||
CLIENT_ID VARCHAR(100) NOT NULL,
|
client_id varchar(100) not null,
|
||||||
CLIENT_ID_ISSUED_AT TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
client_id_issued_at timestamp default current_timestamp not null,
|
||||||
CLIENT_SECRET VARCHAR(200) DEFAULT NULL NULL,
|
client_secret varchar(200) default null null,
|
||||||
CLIENT_SECRET_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
|
client_secret_expires_at timestamp default null null,
|
||||||
CLIENT_NAME VARCHAR(200) NOT NULL,
|
client_name varchar(200) not null,
|
||||||
CLIENT_AUTHENTICATION_METHODS VARCHAR(1000) NOT NULL,
|
client_authentication_methods varchar(1000) not null,
|
||||||
AUTHORIZATION_GRANT_TYPES VARCHAR(1000) NOT NULL,
|
authorization_grant_types varchar(1000) not null,
|
||||||
REDIRECT_URIS VARCHAR(1000) DEFAULT NULL NULL,
|
redirect_uris varchar(1000) default null null,
|
||||||
POST_LOGOUT_REDIRECT_URIS VARCHAR(1000) DEFAULT NULL NULL,
|
post_logout_redirect_uris varchar(1000) default null null,
|
||||||
SCOPES VARCHAR(1000) NOT NULL,
|
scopes varchar(1000) not null,
|
||||||
CLIENT_SETTINGS VARCHAR(2000) NOT NULL,
|
client_settings varchar(2000) not null,
|
||||||
TOKEN_SETTINGS VARCHAR(2000) NOT NULL
|
token_settings varchar(2000) not null
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue