Skip to content

Commit

Permalink
Update feature/search tables.
Browse files Browse the repository at this point in the history
Add security tables/functions.
  • Loading branch information
NickPhura committed Nov 22, 2023
1 parent bbaac45 commit 48b042c
Show file tree
Hide file tree
Showing 6 changed files with 469 additions and 44 deletions.
53 changes: 53 additions & 0 deletions api/src/openapi/schemas/biohub-data-submission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export const BioHubFeatureCollection = {

Check warning on line 1 in api/src/openapi/schemas/biohub-data-submission.ts

View check run for this annotation

Codecov / codecov/patch

api/src/openapi/schemas/biohub-data-submission.ts#L1

Added line #L1 was not covered by tests
title: 'BioHub Data Submission',
type: 'object',
required: ['id', 'type', 'features'],
properties: {
id: {
title: 'Unique id of the submission',
type: 'string'
},
type: {
type: 'string',
enum: ['Submission']
},
features: {
type: 'array',
items: {
$ref: '#/$defs/Feature'
}
}
},
$defs: {
Feature: {
title: 'BioHub Data Submission Feature',
type: 'object',
required: ['id', 'type', 'properties', 'features'],
properties: {
id: {
title: 'Unique id of the feature',
type: 'string'
},
type: {
title: 'Feature type',
type: 'string'
},
properties: {
title: 'Feature properties',
type: 'object',
properties: {}
},
features: {
title: 'Feature child features',
type: 'array',
items: {
$ref: '#/$defs/Feature'
}
}
},
additionalProperties: false
},
additionalProperties: false
},
additionalProperties: false
};
20 changes: 10 additions & 10 deletions database/src/migrations/20231109000001_feature_tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function up(knex: Knex): Promise<void> {
----------------------------------------------------------------------------------------
-- Create tables
----------------------------------------------------------------------------------------
set search_path=biohub,public;
set search_path=biohub,public;
CREATE TABLE submission_feature(
submission_feature_id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
Expand All @@ -34,7 +34,7 @@ export async function up(knex: Knex): Promise<void> {
revision_count integer DEFAULT 0 NOT NULL,
CONSTRAINT submission_feature_pk PRIMARY KEY (submission_feature_id)
);
COMMENT ON COLUMN submission_feature.submission_feature_id IS 'System generated surrogate primary key identifier.';
COMMENT ON COLUMN submission_feature.submission_id IS 'Foreign key to the submission table.';
COMMENT ON COLUMN submission_feature.feature_type_id IS 'Foreign key to the feature_type table.';
Expand All @@ -48,14 +48,14 @@ export async function up(knex: Knex): Promise<void> {
COMMENT ON COLUMN submission_feature.update_user IS 'The id of the user who updated the record as identified in the system user table.';
COMMENT ON COLUMN submission_feature.revision_count IS 'Revision count used for concurrency control.';
COMMENT ON TABLE submission_feature IS 'A set of data for a specific feature of a submission.';
----------------------------------------------------------------------------------------
CREATE TABLE feature_type(
feature_type_id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
name varchar(50) NOT NULL,
name varchar(100) NOT NULL,
display_name varchar(100) NOT NULL,
description varchar(3000),
description varchar(500),
record_effective_date date NOT NULL,
record_end_date date,
create_date timestamptz(6) DEFAULT now() NOT NULL,
Expand All @@ -78,7 +78,7 @@ export async function up(knex: Knex): Promise<void> {
COMMENT ON COLUMN feature_type.update_user IS 'The id of the user who updated the record as identified in the system user table.';
COMMENT ON COLUMN feature_type.revision_count IS 'Revision count used for concurrency control.';
COMMENT ON TABLE feature_type IS 'Defines feature types.';
----------------------------------------------------------------------------------------
CREATE TABLE feature_type_property(
Expand Down Expand Up @@ -106,15 +106,15 @@ export async function up(knex: Knex): Promise<void> {
COMMENT ON COLUMN feature_type_property.update_user IS 'The id of the user who updated the record as identified in the system user table.';
COMMENT ON COLUMN feature_type_property.revision_count IS 'Revision count used for concurrency control.';
COMMENT ON TABLE feature_type_property IS 'A join table on feature type and feature_property. Defines which properties can be used by a given feature type.';
----------------------------------------------------------------------------------------
CREATE TABLE feature_property(
feature_property_id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
feature_property_type_id integer NOT NULL,
name varchar(50) NOT NULL,
name varchar(100) NOT NULL,
display_name varchar(100) NOT NULL,
description varchar(3000),
description varchar(500),
parent_feature_property_id integer,
record_effective_date date NOT NULL,
record_end_date date,
Expand Down Expand Up @@ -146,7 +146,7 @@ export async function up(knex: Knex): Promise<void> {
CREATE TABLE feature_property_type(
feature_property_type_id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
name varchar(100) NOT NULL,
description varchar(3000),
description varchar(500),
record_effective_date date NOT NULL,
record_end_date date,
create_date timestamptz(6) DEFAULT now() NOT NULL,
Expand Down
32 changes: 6 additions & 26 deletions database/src/migrations/20231109000002_search_tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,44 @@ export async function up(knex: Knex): Promise<void> {
submission_feature_id integer NOT NULL,
feature_property_id integer NOT NULL,
value varchar(250) NOT NULL,
-- record_effective_date date NOT NULL,
-- record_end_date date,
create_date timestamptz(6) DEFAULT now() NOT NULL,
create_user integer NOT NULL,
update_date timestamptz(6),
update_user integer,
revision_count integer DEFAULT 0 NOT NULL,
CONSTRAINT search_string_pk PRIMARY KEY (search_string_id)
);
COMMENT ON COLUMN search_string.search_string_id IS 'System generated surrogate primary key identifier.';
COMMENT ON COLUMN search_string.submission_feature_id IS 'Foreign key to the submission_feature table.';
COMMENT ON COLUMN search_string.feature_property_id IS 'Foreign key to the feature_property table.';
COMMENT ON COLUMN search_string.value IS 'The search value of the record.';
-- COMMENT ON COLUMN search_string.record_effective_date IS 'Record level effective date.';
-- COMMENT ON COLUMN search_string.record_end_date IS 'Record level end date.';
COMMENT ON COLUMN search_string.create_date IS 'The datetime the record was created.';
COMMENT ON COLUMN search_string.create_user IS 'The id of the user who created the record as identified in the system user table.';
COMMENT ON COLUMN search_string.update_date IS 'The datetime the record was updated.';
COMMENT ON COLUMN search_string.update_user IS 'The id of the user who updated the record as identified in the system user table.';
COMMENT ON COLUMN search_string.revision_count IS 'Revision count used for concurrency control.';
COMMENT ON TABLE search_string IS 'String search values';
----------------------------------------------------------------------------------------
CREATE TABLE search_number(
search_number_id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
submission_feature_id integer NOT NULL,
feature_property_id integer NOT NULL,
value numeric NOT NULL,
-- record_effective_date date NOT NULL,
-- record_end_date date,
create_date timestamptz(6) DEFAULT now() NOT NULL,
create_user integer NOT NULL,
update_date timestamptz(6),
update_user integer,
revision_count integer DEFAULT 0 NOT NULL,
CONSTRAINT search_number_pk PRIMARY KEY (search_number_id)
);
COMMENT ON COLUMN search_number.search_number_id IS 'System generated surrogate primary key identifier.';
COMMENT ON COLUMN search_number.submission_feature_id IS 'Foreign key to the submission_feature table.';
COMMENT ON COLUMN search_number.feature_property_id IS 'Foreign key to the feature_property table.';
COMMENT ON COLUMN search_number.value IS 'The search value of the record.';
-- COMMENT ON COLUMN search_number.record_effective_date IS 'Record level effective date.';
-- COMMENT ON COLUMN search_number.record_end_date IS 'Record level end date.';
COMMENT ON COLUMN search_number.create_date IS 'The datetime the record was created.';
COMMENT ON COLUMN search_number.create_user IS 'The id of the user who created the record as identified in the system user table.';
COMMENT ON COLUMN search_number.update_date IS 'The datetime the record was updated.';
Expand All @@ -85,22 +77,18 @@ export async function up(knex: Knex): Promise<void> {
submission_feature_id integer NOT NULL,
feature_property_id integer NOT NULL,
value timestamptz(6) NOT NULL,
-- record_effective_date date NOT NULL,
-- record_end_date date,
create_date timestamptz(6) DEFAULT now() NOT NULL,
create_user integer NOT NULL,
update_date timestamptz(6),
update_user integer,
revision_count integer DEFAULT 0 NOT NULL,
CONSTRAINT search_datetime_pk PRIMARY KEY (search_datetime_id)
);
COMMENT ON COLUMN search_datetime.search_datetime_id IS 'System generated surrogate primary key identifier.';
COMMENT ON COLUMN search_datetime.submission_feature_id IS 'Foreign key to the submission_feature table.';
COMMENT ON COLUMN search_datetime.feature_property_id IS 'Foreign key to the feature_property table.';
COMMENT ON COLUMN search_datetime.value IS 'The search value of the record.';
-- COMMENT ON COLUMN search_datetime.record_effective_date IS 'Record level effective date.';
-- COMMENT ON COLUMN search_datetime.record_end_date IS 'Record level end date.';
COMMENT ON COLUMN search_datetime.create_date IS 'The datetime the record was created.';
COMMENT ON COLUMN search_datetime.create_user IS 'The id of the user who created the record as identified in the system user table.';
COMMENT ON COLUMN search_datetime.update_date IS 'The datetime the record was updated.';
Expand All @@ -115,22 +103,18 @@ export async function up(knex: Knex): Promise<void> {
submission_feature_id integer NOT NULL,
feature_property_id integer NOT NULL,
value geometry NOT NULL,
-- record_effective_date date NOT NULL,
-- record_end_date date,
create_date timestamptz(6) DEFAULT now() NOT NULL,
create_user integer NOT NULL,
update_date timestamptz(6),
update_user integer,
revision_count integer DEFAULT 0 NOT NULL,
CONSTRAINT search_spatial_pk PRIMARY KEY (search_spatial_id)
);
COMMENT ON COLUMN search_spatial.search_spatial_id IS 'System generated surrogate primary key identifier.';
COMMENT ON COLUMN search_spatial.submission_feature_id IS 'Foreign key to the submission_feature table.';
COMMENT ON COLUMN search_spatial.feature_property_id IS 'Foreign key to the feature_property table.';
COMMENT ON COLUMN search_spatial.value IS 'The search value of the record.';
-- COMMENT ON COLUMN search_spatial.record_effective_date IS 'Record level effective date.';
-- COMMENT ON COLUMN search_spatial.record_end_date IS 'Record level end date.';
COMMENT ON COLUMN search_spatial.create_date IS 'The spatial the record was created.';
COMMENT ON COLUMN search_spatial.create_user IS 'The id of the user who created the record as identified in the system user table.';
COMMENT ON COLUMN search_spatial.update_date IS 'The spatial the record was updated.';
Expand All @@ -145,22 +129,18 @@ export async function up(knex: Knex): Promise<void> {
submission_feature_id integer NOT NULL,
feature_property_id integer NOT NULL,
value numeric NOT NULL,
-- record_effective_date date NOT NULL,
-- record_end_date date,
create_date timestamptz(6) DEFAULT now() NOT NULL,
create_user integer NOT NULL,
update_date timestamptz(6),
update_user integer,
revision_count integer DEFAULT 0 NOT NULL,
CONSTRAINT search_taxonomy_pk PRIMARY KEY (search_taxonomy_id)
);
COMMENT ON COLUMN search_taxonomy.search_taxonomy_id IS 'System generated surrogate primary key identifier.';
COMMENT ON COLUMN search_taxonomy.submission_feature_id IS 'Foreign key to the submission_feature table.';
COMMENT ON COLUMN search_taxonomy.feature_property_id IS 'Foreign key to the feature_property table.';
COMMENT ON COLUMN search_taxonomy.value IS 'The search value of the record.';
-- COMMENT ON COLUMN search_taxonomy.record_effective_date IS 'Record level effective date.';
-- COMMENT ON COLUMN search_taxonomy.record_end_date IS 'Record level end date.';
COMMENT ON COLUMN search_taxonomy.create_date IS 'The taxonomy the record was created.';
COMMENT ON COLUMN search_taxonomy.create_user IS 'The id of the user who created the record as identified in the system user table.';
COMMENT ON COLUMN search_taxonomy.update_date IS 'The taxonomy the record was updated.';
Expand Down
Loading

0 comments on commit 48b042c

Please sign in to comment.