diff --git a/sql/upgrades/161.sql b/sql/upgrades/161.sql --- a/sql/upgrades/161.sql +++ b/sql/upgrades/161.sql @@ -12,6 +12,10 @@ set extra_headers = ARRAY[]::bytea[][] where extra_headers is null; +alter table revision + add constraint revision_extra_headers_not_null + check (extra_headers is not null) + not valid; alter table revision - alter column extra_headers set not null; + validate constraint revision_extra_headers_not_null; diff --git a/swh/storage/sql/30-swh-schema.sql b/swh/storage/sql/30-swh-schema.sql --- a/swh/storage/sql/30-swh-schema.sql +++ b/swh/storage/sql/30-swh-schema.sql @@ -238,9 +238,9 @@ 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...) 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) + date_neg_utc_offset boolean, -- not null, check 60-swh-indexes.sql + committer_date_neg_utc_offset boolean, -- not null, check 60-swh-indexes.sql + extra_headers bytea[][] -- not null, check 60-swh-indexes.sql (this is used in hash computation) ); comment on table revision is 'A revision represents the state of a source code tree at a specific point in time'; diff --git a/swh/storage/sql/60-swh-indexes.sql b/swh/storage/sql/60-swh-indexes.sql --- a/swh/storage/sql/60-swh-indexes.sql +++ b/swh/storage/sql/60-swh-indexes.sql @@ -89,11 +89,17 @@ add constraint revision_committer_date_neg_utc_offset_not_null check (committer_date is null or committer_date_neg_utc_offset is not null) not valid; +alter table revision + add constraint revision_extra_headers_not_null + check (extra_headers is not null) + not valid; alter table revision validate constraint revision_date_neg_utc_offset_not_null; alter table revision validate constraint revision_committer_date_neg_utc_offset_not_null; +alter table revision + validate constraint revision_extra_headers_not_null; create index concurrently on revision(directory); create unique index concurrently on revision(object_id);