111 lines
2.7 KiB
SQL
111 lines
2.7 KiB
SQL
-- Connect to database repostats
|
|
\c repostats
|
|
|
|
-- Create schema and define views
|
|
CREATE SCHEMA gitee;
|
|
|
|
-- Repos
|
|
CREATE TABLE gitee.repos (
|
|
id int8 NOT NULL,
|
|
full_name VARCHAR(1000),
|
|
human_name VARCHAR(1000),
|
|
path VARCHAR(1000),
|
|
name VARCHAR(1000),
|
|
url VARCHAR(1000),
|
|
owner_id int8,
|
|
assigner_id int8,
|
|
description VARCHAR(1000),
|
|
html_url VARCHAR(2000),
|
|
ssh_url VARCHAR(2000),
|
|
forked_repo BOOLEAN,
|
|
default_branch VARCHAR(1000),
|
|
forks_count INT ,
|
|
stargazers_count INT,
|
|
watchers_count INT,
|
|
license VARCHAR(1000),
|
|
pushed_at TIMESTAMP WITH TIME ZONE,
|
|
created_at TIMESTAMP WITH TIME ZONE,
|
|
updated_at TIMESTAMP WITH TIME ZONE,
|
|
CONSTRAINT uni_gitee_repo_id UNIQUE (id)
|
|
);
|
|
|
|
CREATE TABLE gitee.commits (
|
|
repo_id int8,
|
|
repo_url VARCHAR(2000),
|
|
sha VARCHAR(80) NOT NULL,
|
|
commit_url VARCHAR(2000) NOT NULL,
|
|
author_name VARCHAR(500) NULL,
|
|
author_email VARCHAR(500) NULL,
|
|
author_date TIMESTAMP WITH TIME ZONE,
|
|
committer_name VARCHAR(200) ,
|
|
committer_email VARCHAR(200) ,
|
|
committer_date TIMESTAMP WITH TIME ZONE ,
|
|
detail_message TEXT ,
|
|
tree VARCHAR(80),
|
|
CONSTRAINT uni_gitee_commits UNIQUE (sha,repo_id)
|
|
);
|
|
|
|
-- Issues
|
|
CREATE TABLE gitee.issues (
|
|
id int8 ,
|
|
html_url VARCHAR(2000),
|
|
"number" VARCHAR(100),
|
|
"state" VARCHAR(100),
|
|
title VARCHAR(1000),
|
|
"user_id" int8,
|
|
repo_id int8 ,
|
|
finished_at TIMESTAMP WITH TIME ZONE,
|
|
created_at TIMESTAMP WITH TIME ZONE,
|
|
updated_at TIMESTAMP WITH TIME ZONE,
|
|
plan_started_at TIMESTAMP WITH TIME ZONE,
|
|
comments INT,
|
|
priority INT,
|
|
issue_type VARCHAR(100),
|
|
issue_state VARCHAR(100),
|
|
security_hole BOOLEAN,
|
|
CONSTRAINT uni_gitee_issue_id UNIQUE (id)
|
|
);
|
|
|
|
-- Pull requests
|
|
CREATE TABLE gitee.pull_requests (
|
|
id int8 NOT NULL,
|
|
repo_id int8 NOT NULL,
|
|
"user_id" BIGINT NOT NULL,
|
|
html_url VARCHAR(500) NOT NULL,
|
|
"number" VARCHAR(40) NOT NULL,
|
|
"state" VARCHAR(40) NOT NULL,
|
|
finished_at TIMESTAMP WITH TIME ZONE,
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
updated_at TIMESTAMP WITH TIME ZONE,
|
|
closed_at TIMESTAMP WITH TIME ZONE,
|
|
merged_at TIMESTAMP WITH TIME ZONE,
|
|
mergeable BOOLEAN,
|
|
can_merge_check BOOLEAN,
|
|
CONSTRAINT uni_gitee_prs UNIQUE (id)
|
|
);
|
|
|
|
-- Stargazers
|
|
CREATE TABLE gitee.stargazers (
|
|
user_id int8 NOT NULL,
|
|
repo_id int8 NOT NULL,
|
|
star_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
CONSTRAINT uni_gitee_stargazers UNIQUE(user_id,repo_id)
|
|
);
|
|
|
|
-- Collaborators
|
|
CREATE TABLE gitee.collaborators (
|
|
"user_id" int8 NOT NULL,
|
|
repo_id int8 NOT NULL,
|
|
CONSTRAINT uni_gitee_rcs UNIQUE (user_id,repo_id)
|
|
);
|
|
|
|
-- Users
|
|
CREATE TABLE gitee.users (
|
|
id int8 NOT NULL,
|
|
login VARCHAR(100) NOT NULL,
|
|
"name" VARCHAR(255) NOT NULL,
|
|
html_url VARCHAR(255) NOT NULL,
|
|
"type" VARCHAR(50) NULL,
|
|
CONSTRAINT uni_gitee_users_id UNIQUE (id)
|
|
);
|