Skip to content

Commit

Permalink
SIMSBIOHUB-641: Fix Migration (#1435)
Browse files Browse the repository at this point in the history
* Drop not-null constraint from survey block geojson column.
* Minor tweak to openapi schema for blocks (survey_id was required, but was causing issues when editing a survey).
* Fix outdated openapi spec
* Bump database setup pod memory limit
  • Loading branch information
NickPhura authored Nov 22, 2024
1 parent 9f51398 commit be4656f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 49 deletions.
2 changes: 1 addition & 1 deletion api/src/openapi/schemas/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export const surveyBlockSchema: OpenAPIV3.SchemaObject = {
title: 'Survey Block',
type: 'object',
additionalProperties: false,
required: ['name', 'description', 'survey_id', 'geojson'],
required: ['name', 'description', 'geojson'],
properties: {
survey_block_id: {
description: 'Survey block id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
paginationRequestQueryParamSchema,
paginationResponseSchema
} from '../../../../../../openapi/schemas/pagination';
import { surveyBlockSchema } from '../../../../../../openapi/schemas/survey';
import { techniqueSimpleViewSchema } from '../../../../../../openapi/schemas/technique';
import { authorizeRequestHandler } from '../../../../../../request-handlers/security/authorization';
import { PostSampleLocations, SampleLocationService } from '../../../../../../services/sample-location-service';
Expand Down Expand Up @@ -437,47 +438,7 @@ POST.apiDoc = {
},
blocks: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
required: ['survey_block_id'],
properties: {
survey_block_id: {
type: 'number'
},
survey_id: {
type: 'integer'
},
name: {
type: 'string'
},
description: {
type: 'string'
},
sample_block_count: {
type: 'number'
},
create_date: {
type: 'string',
nullable: true
},
create_user: {
type: 'integer',
nullable: true
},
update_date: {
type: 'string',
nullable: true
},
update_user: {
type: 'integer',
nullable: true
},
revision_count: {
type: 'number'
}
}
}
items: surveyBlockSchema
},
stratums: {
type: 'array',
Expand Down
1 change: 1 addition & 0 deletions app/src/interfaces/useSurveyApi.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export interface IGetSurveyLocation {

export interface IGetSurveyBlock {
survey_block_id: number;
survey_id?: number;
name: string;
description: string;
revision_count: number;
Expand Down
2 changes: 1 addition & 1 deletion database/.pipeline/lib/db.setup.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const dbSetupDeploy = async (settings) => {
CPU_REQUEST: '50m',
CPU_LIMIT: '1000m',
MEMORY_REQUEST: '100Mi',
MEMORY_LIMIT: '1.5Gi'
MEMORY_LIMIT: '1.75Gi'
}
})
);
Expand Down
25 changes: 19 additions & 6 deletions database/src/migrations/20241101160200_survey_block_geojson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,32 @@ import { Knex } from 'knex';
* @return {*} {Promise<void>}
*/
export async function up(knex: Knex): Promise<void> {
await knex.raw(`
await knex.raw(`--sql
----------------------------------------------------------------------------------------
-- Drop views
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub_dapi_v1;
DROP VIEW IF EXISTS biohub_dapi_v1.survey_block;
----------------------------------------------------------------------------------------
-- Alter tables/data
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub, public;
ALTER TABLE biohub.survey_block ADD COLUMN geojson JSONB NOT NULL;
ALTER TABLE biohub.survey_block ADD COLUMN geojson JSONB;
ALTER TABLE biohub.survey_block ADD COLUMN geometry geometry(geometry, 3005);
ALTER TABLE biohub.survey_block ADD COLUMN geography geography(geometry, 4326);
COMMENT ON COLUMN survey_block.geojson IS 'A JSON representation of the project boundary geometry that provides necessary details for shape manipulation in client side tools.';
COMMENT ON COLUMN survey_block.geometry IS 'The containing geometry of the record.';
COMMENT ON COLUMN survey_block.geography IS 'The containing geography of the record.';
----------------------------------------------------------------------------------------
-- Update views
--------------------------------------------------------------------------------
SET SEARCH_PATH=biohub_dapi_v1;
CREATE OR REPLACE VIEW biohub_dapi_v1.survey_block AS SELECT * FROM biohub.survey_block;
`);
}
Expand Down

0 comments on commit be4656f

Please sign in to comment.