Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/sql/30-swh-schema.sql
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
-- 2. list the contained directory_entry_file using array file_entries | -- 2. list the contained directory_entry_file using array file_entries | ||||
-- 3. list the contained directory_entry_rev using array rev_entries | -- 3. list the contained directory_entry_rev using array rev_entries | ||||
-- 4. UNION | -- 4. UNION | ||||
-- | -- | ||||
-- Synonyms/mappings: | -- Synonyms/mappings: | ||||
-- * git: tree | -- * git: tree | ||||
create table directory | create table directory | ||||
( | ( | ||||
id sha1_git, | id sha1_git not null, | ||||
dir_entries bigint[], -- sub-directories, reference directory_entry_dir | dir_entries bigint[], -- sub-directories, reference directory_entry_dir | ||||
file_entries bigint[], -- contained files, reference directory_entry_file | file_entries bigint[], -- contained files, reference directory_entry_file | ||||
rev_entries bigint[], -- mounted revisions, reference directory_entry_rev | rev_entries bigint[], -- mounted revisions, reference directory_entry_rev | ||||
object_id bigserial -- short object identifier | object_id bigserial -- short object identifier | ||||
); | ); | ||||
-- A directory entry pointing to a (sub-)directory. | -- A directory entry pointing to a (sub-)directory. | ||||
create table directory_entry_dir | create table directory_entry_dir | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
-- * git / subversion / etc: commit | -- * git / subversion / etc: commit | ||||
-- * tarball: a specific tarball | -- * tarball: a specific tarball | ||||
-- | -- | ||||
-- Revisions are organized as DAGs. Each revision points to 0, 1, or more (in | -- Revisions are organized as DAGs. Each revision points to 0, 1, or more (in | ||||
-- case of merges) parent revisions. Each revision points to a directory, i.e., | -- case of merges) parent revisions. Each revision points to a directory, i.e., | ||||
-- a file-system tree containing files and directories. | -- a file-system tree containing files and directories. | ||||
create table revision | create table revision | ||||
( | ( | ||||
id sha1_git, | id sha1_git not null, | ||||
date timestamptz, | date timestamptz, | ||||
date_offset smallint, | date_offset smallint, | ||||
committer_date timestamptz, | committer_date timestamptz, | ||||
committer_date_offset smallint, | committer_date_offset smallint, | ||||
type revision_type not null, | type revision_type not null, | ||||
directory sha1_git, -- source code "root" directory | directory sha1_git, -- source code "root" directory | ||||
message bytea, | message bytea, | ||||
author bigint, | author bigint, | ||||
committer bigint, | committer bigint, | ||||
synthetic boolean not null default false, -- true iff revision has been created by Software Heritage | synthetic boolean not null default false, -- true iff revision has been created by Software Heritage | ||||
metadata jsonb, -- extra metadata (tarball checksums, extra commit information, etc...) | metadata jsonb, -- extra metadata (tarball checksums, extra commit information, etc...) | ||||
object_id bigserial, | object_id bigserial, | ||||
date_neg_utc_offset boolean, | date_neg_utc_offset boolean, | ||||
committer_date_neg_utc_offset boolean | committer_date_neg_utc_offset boolean | ||||
); | ); | ||||
-- either this table or the sha1_git[] column on the revision table | -- either this table or the sha1_git[] column on the revision table | ||||
create table revision_history | create table revision_history | ||||
( | ( | ||||
id sha1_git, | id sha1_git not null, | ||||
parent_id sha1_git, | parent_id sha1_git not null, | ||||
parent_rank int not null default 0 | parent_rank int not null default 0 | ||||
-- parent position in merge commits, 0-based | -- parent position in merge commits, 0-based | ||||
); | ); | ||||
-- Crawling history of software origins visited by Software Heritage. Each | -- Crawling history of software origins visited by Software Heritage. Each | ||||
-- visit is a 3-way mapping between a software origin, a timestamp, and a | -- visit is a 3-way mapping between a software origin, a timestamp, and a | ||||
-- snapshot object capturing the full-state of the origin at visit time. | -- snapshot object capturing the full-state of the origin at visit time. | ||||
Show All 16 Lines | |||||
-- A snapshot represents the entire state of a software origin as crawled by | -- A snapshot represents the entire state of a software origin as crawled by | ||||
-- Software Heritage. This table is a simple mapping between (public) intrinsic | -- Software Heritage. This table is a simple mapping between (public) intrinsic | ||||
-- snapshot identifiers and (private) numeric sequential identifiers. | -- snapshot identifiers and (private) numeric sequential identifiers. | ||||
create table snapshot | create table snapshot | ||||
( | ( | ||||
object_id bigserial not null, -- PK internal object identifier | object_id bigserial not null, -- PK internal object identifier | ||||
id sha1_git -- snapshot intrinsic identifier | id sha1_git not null -- snapshot intrinsic identifier | ||||
); | ); | ||||
-- Each snapshot associate "branch" names to other objects in the Software | -- Each snapshot associate "branch" names to other objects in the Software | ||||
-- Heritage Merkle DAG. This table describes branches as mappings between names | -- Heritage Merkle DAG. This table describes branches as mappings between names | ||||
-- and target typed objects. | -- and target typed objects. | ||||
create table snapshot_branch | create table snapshot_branch | ||||
( | ( | ||||
object_id bigserial not null, -- PK internal object identifier | object_id bigserial not null, -- PK internal object identifier | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |