+-- description: add {,committer_}date_offset_bytes to rev/rel + raw_manifest to dir/rev/rel, part 1
+
+insert into dbversion(version, release, description)
+ values(179, now(), 'Work In Progress');
+
+-- step 1: add columns, update functions
+
+alter table release
+ add column date_offset_bytes bytea,
+ add column raw_manifest bytea;
+comment on column release.date_offset_bytes is 'Raw git representation of the timezone, as an offset from UTC. It should follow this format: ``+HHMM`` or ``-HHMM``';
+comment on column release.raw_manifest is 'git manifest of the object, if it cannot be represented using only the other fields';
+
+
+alter table revision
+ add column date_offset_bytes bytea,
+ add column committer_date_offset_bytes bytea,
+ add column raw_manifest bytea;
+comment on column revision.date_offset_bytes is 'Raw git representation of the timezone, as an offset from UTC. It should follow this format: ``+HHMM`` or ``-HHMM``';
+comment on column revision.committer_date_offset_bytes is 'Raw git representation of the timezone, as an offset from UTC. It should follow this format: ``+HHMM`` or ``-HHMM``';
+comment on column revision.raw_manifest is 'git manifest of the object, if it cannot be represented using only the other fields';
+
+drop function swh_revision_log;
+drop function swh_revision_list_by_object_id;
+drop function swh_revision_add;
+drop type revision_entry;
+create type revision_entry as
+(
+ id sha1_git,
+ date timestamptz,
+ date_offset smallint,
+ date_neg_utc_offset boolean,
+ date_offset_bytes bytea,
+ committer_date timestamptz,
+ committer_date_offset smallint,
+ committer_date_neg_utc_offset boolean,
+ committer_date_offset_bytes bytea,
+ type revision_type,
+ directory sha1_git,
+ message bytea,
+ author_id bigint,
+ author_fullname bytea,
+ author_name bytea,
+ author_email bytea,
+ committer_id bigint,
+ committer_fullname bytea,
+ committer_name bytea,
+ committer_email bytea,
+ metadata jsonb,
+ synthetic boolean,
+ parents bytea[],
+ object_id bigint,
+ extra_headers bytea[][],
+ raw_manifest bytea
+);
+
+alter table directory
+ add column raw_manifest bytea;
+comment on column directory.raw_manifest is 'git manifest of the object, if it cannot be represented using only the other fields';
+
+create or replace function swh_directory_add()
+ returns void
+ language plpgsql
+as $$
+begin
+ perform swh_directory_entry_add('file');
+ perform swh_directory_entry_add('dir');
+ perform swh_directory_entry_add('rev');
+
+ insert into directory (id, dir_entries, file_entries, rev_entries, raw_manifest)
+ select id, dir_entries, file_entries, rev_entries, raw_manifest from tmp_directory t
+ where not exists (
+ select 1 from directory d
+ where d.id = t.id);
+
+ return;
+end
+$$;
+
+create or replace function swh_revision_log(root_revisions bytea[], num_revs bigint default NULL)
+ raw_manifest bytea -- git manifest of the object, if it cannot be represented using only the other fields
);
comment on table directory is 'Contents of a directory, synonymous to tree (git)';
@@ -146,6 +147,7 @@
comment on column directory.file_entries is 'Contained files, reference directory_entry_file';
comment on column directory.rev_entries is 'Mounted revisions, reference directory_entry_rev';
comment on column directory.object_id is 'Short object identifier';
+comment on column directory.raw_manifest is 'git manifest of the object, if it cannot be represented using only the other fields';
-- A directory entry pointing to a (sub-)directory.
@@ -240,7 +242,10 @@
object_id bigserial,
date_neg_utc_offset boolean,
committer_date_neg_utc_offset boolean,
- extra_headers bytea[][] not null -- extra headers (used in hash computation)
+ extra_headers bytea[][] not null, -- extra headers (used in hash computation)
+ date_offset_bytes bytea,
+ committer_date_offset_bytes bytea,
+ raw_manifest bytea -- git manifest of the object, if it cannot be represented using only the other fields
);
comment on table revision is 'A revision represents the state of a source code tree at a specific point in time';
@@ -260,6 +265,9 @@
comment on column revision.metadata is 'Extra revision metadata';
comment on column revision.object_id is 'Non-intrinsic, sequential object identifier';
comment on column revision.extra_headers is 'Extra revision headers; used in revision hash computation';
+comment on column revision.date_offset_bytes is 'Raw git representation of the timezone, as an offset from UTC. It should follow this format: ``+HHMM`` or ``-HHMM``';
+comment on column revision.committer_date_offset_bytes is 'Raw git representation of the timezone, as an offset from UTC. It should follow this format: ``+HHMM`` or ``-HHMM``';
+comment on column revision.raw_manifest is 'git manifest of the object, if it cannot be represented using only the other fields';
-- either this table or the sha1_git[] column on the revision table
@@ -378,7 +386,9 @@
synthetic boolean not null default false, -- true iff release has been created by Software Heritage
object_id bigserial,
target_type object_type not null,
- date_neg_utc_offset boolean
+ date_neg_utc_offset boolean,
+ date_offset_bytes bytea,
+ raw_manifest bytea
);
comment on table release is 'Details of a software release, synonymous with
@@ -395,6 +405,8 @@
comment on column release.target_type is 'Object type (''content'', ''directory'', ''revision'',
''release'', ''snapshot'')';
comment on column release.date_neg_utc_offset is 'True indicates -0 UTC offset for release timestamp';
+comment on column release.date_offset_bytes is 'Raw git representation of the timezone, as an offset from UTC. It should follow this format: ``+HHMM`` or ``-HHMM``';
+comment on column release.raw_manifest is 'git manifest of the object, if it cannot be represented using only the other fields';
-select release.id as id,date,date_offset,date_neg_utc_offset,comment,release.name as name,synthetic,target,target_type,a.id as author_id,a.name as author_name,a.email as author_email,a.fullname as author_fullname
+select release.id as id,date,date_offset,date_neg_utc_offset,date_offset_bytes,comment,release.name as name,synthetic,target,target_type,a.id as author_id,a.name as author_name,a.email as author_email,a.fullname as author_fullname,raw_manifest