Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LUCY-1192] FEATURE** Add fields for bilge plugs #1193

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 90 additions & 75 deletions api/api_sources/schema-files/watercraftRiskAssessment.schema.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Water-Craft Risk Assessment Form Schema
version: '1.0'
includes:
version: "1.0"
includes:
- observerWorkflow.schema.yaml
- highRiskAssessment.schema.yaml
- inspectApp.codes.schema.yaml
- countryProvince.schema.yaml
schemas:
schemas:
## -- WaterCraftRiskAssessmentSchema
WatercraftRiskAssessmentSchema:
name: watercraft_risk_assessment
description: 'This is schema for data model of water craft observation for invasive aquatic species specially Mussels. This data model will be used to capture all kind of variables related to a water craft observation'
description: "This is schema for data model of water craft observation for invasive aquatic species specially Mussels. This data model will be used to capture all kind of variables related to a water craft observation"
baseSchema: RecordSchema
meta:
resource: true
Expand All @@ -19,87 +19,87 @@ schemas:
layout: {}
computedFields: {}
# Relations
relations:
relations:
journeys:
header:
key: 'watercraftAssessment.journeys'
key: "watercraftAssessment.journeys"
default: Water Craft Journeys
description:
key: 'watercraftAssessment.journeys.description'
default: 'Associated Water-bodies'
description:
key: "watercraftAssessment.journeys.description"
default: "Associated Water-bodies"
type: array
relationshipType: one-to-many
schema: WatercraftJourneySchema
meta:
embedded: true
meta:
embedded: true
# End: Relations
columns:
columns:
# Primary Column
id:
name: 'watercraft_risk_assessment_id'
comment: 'Auto generated primary key'
id:
name: "watercraft_risk_assessment_id"
comment: "Auto generated primary key"
definition: SERIAL PRIMARY KEY
# Time
timestamp:
name: 'timestamp'
comment: 'Date and time of watercraft observation.'
definition: 'TIMESTAMP NOT NULL'
timestamp:
name: "timestamp"
comment: "Date and time of watercraft observation."
definition: "TIMESTAMP NOT NULL"
# Boolean
passportHolder:
name: 'passport_holder_ind'
comment: 'Indicator to show that inspected boat has previously issued passport'
name: "passport_holder_ind"
comment: "Indicator to show that inspected boat has previously issued passport"
definition: BOOLEAN NOT NULL DEFAULT FALSE
isNewPassportIssued:
name: 'is_new_passport_issued'
comment: 'Indicator to show that inspected boat was issued a new passport'
name: "is_new_passport_issued"
comment: "Indicator to show that inspected boat was issued a new passport"
definition: BOOLEAN NOT NULL DEFAULT FALSE
k9Inspection:
name: k9_inspection_ind
comment: 'Indicator to show that inspection type is K9'
comment: "Indicator to show that inspection type is K9"
definition: BOOLEAN NOT NULL DEFAULT FALSE
marineSpeciesFound:
name: marine_species_found_ind
comment: 'Indicator to show any marine species found during inspection'
comment: "Indicator to show any marine species found during inspection"
definition: BOOLEAN NOT NULL DEFAULT FALSE
aquaticPlantsFound:
name: aquatic_plants_found_ind
comment: 'Indicator to show any aquatic plants found during inspection'
comment: "Indicator to show any aquatic plants found during inspection"
definition: BOOLEAN NOT NULL DEFAULT FALSE
previousAISKnowledge:
name: previous_ais_knowledge_ind
comment: 'Indicator to store status of previous AIS knowledge'
comment: "Indicator to store status of previous AIS knowledge"
definition: BOOLEAN NOT NULL DEFAULT FALSE
previousInspection:
name: previous_inspection_ind
comment: 'Indicator to store status of previous inspection'
comment: "Indicator to store status of previous inspection"
definition: BOOLEAN NOT NULL DEFAULT FALSE
marineMusselFound:
name: marine_mussel_found_ind
comment: 'Indicator to store status marine mussel found during inspection'
comment: "Indicator to store status marine mussel found during inspection"
definition: BOOLEAN NOT NULL DEFAULT FALSE
adultDreissenidaeFound:
name: adult_dreissenidae_found_ind
comment: 'Status flag any adult Dreissenidae found during inspection'
comment: "Status flag any adult Dreissenidae found during inspection"
definition: BOOLEAN NOT NULL DEFAULT FALSE
launchedOutsideBC:
name: launched_outside_bc_ind
comment: 'Status flag to check the boat was launched outside of bc or not'
comment: "Status flag to check the boat was launched outside of bc or not"
definition: BOOLEAN NOT NULL DEFAULT FALSE
decontaminationPerformed:
name: decontamination_performed_ind
comment: 'Status flag to check any decontamination performed during inspection'
comment: "Status flag to check any decontamination performed during inspection"
definition: BOOLEAN NOT NULL DEFAULT FALSE
commerciallyHauled:
name: commercially_hauled_ind
comment: 'Status flag to check inspected boats are commercially hauled or not'
comment: "Status flag to check inspected boats are commercially hauled or not"
definition: BOOLEAN NOT NULL DEFAULT FALSE
highRiskArea:
name: high_risk_area_ind
comment: 'Indicator flag to check boats are from High risk area or not.'
comment: "Indicator flag to check boats are from High risk area or not."
definition: BOOLEAN NOT NULL DEFAULT FALSE
highRiskAIS:
name: high_risk_ais_ind
comment: 'Indicator flag to check high risk AIS or not'
comment: "Indicator flag to check high risk AIS or not"
definition: BOOLEAN NOT NULL DEFAULT FALSE
previousDryStorage:
name: previous_dry_storage_ind
Expand Down Expand Up @@ -135,54 +135,54 @@ schemas:
definition: BOOLEAN NOT NULL DEFAULT FALSE
dreissenidMusselsFoundPrevious:
name: dreissenid_mussels_found_previous
comment: 'Status flag to check if dreissenid mussels were found on the previous inspection or not'
comment: "Status flag to check if dreissenid mussels were found on the previous inspection or not"
definition: BOOLEAN NOT NULL DEFAULT FALSE
# Counter
nonMotorized:
name: 'non_motorized_counter'
comment: 'Counter for non motorized boats in inspection'
name: "non_motorized_counter"
comment: "Counter for non motorized boats in inspection"
definition: INT NULL
simple:
name: 'simple_counter'
comment: 'Counter for number of simple boats in the inspection'
name: "simple_counter"
comment: "Counter for number of simple boats in the inspection"
definition: INT NULL
complex:
name: 'complex_counter'
comment: 'Counter for number of complex boats in the inspection'
definition: INT NULL
name: "complex_counter"
comment: "Counter for number of complex boats in the inspection"
definition: INT NULL
veryComplex:
name: 'very_complex_count'
comment: 'Counter for number of very complex boats in the inspection'
name: "very_complex_count"
comment: "Counter for number of very complex boats in the inspection"
definition: INT NULL
previousInspectionDays:
name: 'previous_inspection_days_count'
comment: 'Number of days the previous inspection was conducted'
name: "previous_inspection_days_count"
comment: "Number of days the previous inspection was conducted"
definition: VARCHAR(100) NULL
required: false
# Strings
generalComment:
name: general_comment
comment: 'General comment associated with assessment'
comment: "General comment associated with assessment"
definition: VARCHAR(300) NULL
required: false
passportNumber:
passportNumber:
name: passport_number
comment: 'Passport number associated with previous inspection'
comment: "Passport number associated with previous inspection"
definition: VARCHAR(100) NULL
decontaminationReference:
name: decontamination_reference
comment: 'Decontamination reference number. Optional and dependent on decontaminationPerformed indicator'
comment: "Decontamination reference number. Optional and dependent on decontaminationPerformed indicator"
definition: VARCHAR(100) NULL
required: false
# Relationship
highRiskAssessment:
name: high_risk_assessment_id
comment: 'Foreign key reference to High risk assessment of the inspection'
comment: "Foreign key reference to High risk assessment of the inspection"
definition: INT NULL
foreignTable: high_risk_assessment
refColumn: high_risk_assessment_id
required: false
meta:
meta:
embedded: true
previousAISKnowledgeSource:
name: previous_ais_knowledge_source_code_id
Expand All @@ -202,16 +202,16 @@ schemas:
deleteCascade: false
required: false
meta: {}
# Joint Relationship
# Joint Relationship
provinceOfResidence:
name: province_code
comment: 'Province of residence of the boat. Joint foreign key reference to country_province table province_code column along with country code'
comment: "Province of residence of the boat. Joint foreign key reference to country_province table province_code column along with country code"
definition: VARCHAR(3) NULL
required: false
meta:
# Joint Column info and key mapping
# Joint Column info and key mapping
jointColumnInfo:
jointColumnKeys:
jointColumnKeys:
- countryOfResidence
referenceSchema: CountryProvinceSchema
referenceColumnMapping:
Expand All @@ -224,20 +224,20 @@ schemas:
comment: Country of the water-body location. Joint foreign key reference to country_province table country_code column along with province_code.
definition: VARCHAR(3) NULL
required: false
examples:
examples:
- CAN
## -- end columns
## Additional Sql Commands
initialSqlCommands:
- comment: 'Adding Joint Foreign key reference'
sql: 'ALTER TABLE watercraft_risk_assessment ADD CONSTRAINT FK_watercraft_risk_assessment_country_province FOREIGN KEY (country_code, province_code) REFERENCES country_province (country_code, province_code) ON DELETE SET NULL;'
- comment: "Adding Joint Foreign key reference"
sql: "ALTER TABLE watercraft_risk_assessment ADD CONSTRAINT FK_watercraft_risk_assessment_country_province FOREIGN KEY (country_code, province_code) REFERENCES country_province (country_code, province_code) ON DELETE SET NULL;"
## Versions
versions:
## -- version: workflow
- name: 'workflow'
id: '20191106'
info: 'Adding workflow foreign key reference'
columns:
- name: "workflow"
id: "20191106"
info: "Adding workflow foreign key reference"
columns:
workflow:
name: observer_workflow_id
comment: Foreign key reference to reference to observer_workflow table
Expand All @@ -247,9 +247,9 @@ schemas:
meta: {}
## -- end: workflow
## -- version: numberOfPeopleInParty
- name: 'numberOfPeopleInParty'
id: '20200426'
info: 'Adding new column numberOfPeopleInParty'
- name: "numberOfPeopleInParty"
id: "20200426"
info: "Adding new column numberOfPeopleInParty"
columns:
numberOfPeopleInParty:
name: number_of_people_in_party
Expand All @@ -259,9 +259,9 @@ schemas:
meta: {}
## -- end: numberOfPeopleInParty
## -- version: inspectionTime
- name: 'inspectionTime'
id: '20210706'
info: 'Adding new column inspectionTime'
- name: "inspectionTime"
id: "20210706"
info: "Adding new column inspectionTime"
columns:
inspectionTime:
name: inspection_time
Expand All @@ -271,16 +271,31 @@ schemas:
meta: {}
## -- end: inspectionTime
## -- version: k9InspectionResults
- name: 'k9InspectionResults'
id: '20230330'
info: 'Adding new column k9InspectionResults'
- name: "k9InspectionResults"
id: "20230330"
info: "Adding new column k9InspectionResults"
columns:
k9InspectionResults:
name: k9_inspection_results
comment: 'result of k9 inspection'
comment: "result of k9 inspection"
definition: VARCHAR(100) NULL
required: false
## -- end: k9InspectionResults
## -- version: bilgePlugs
- name: "bilgePlugFields"
id: "20240605"
info: "Adding new columns drainplugRemovedAtInspection & watercraftHasDrainplugs"
columns:
watercraftHasDrainplugs:
name: watercraft_has_drainplugs
comment: "Indicator that the inspected watercraft contained drain plugs in Bilge"
definition: BOOLEAN NOT NULL DEFAULT FALSE
required: true
drainplugRemovedAtInspection:
name: drainplug_removed_at_inspection
comment: "With 'Pull The Plug' legislation in mind, were the drain plugs removed from vehicle"
definition: BOOLEAN NOT NULL DEFAULT FALSE
required: false

## -- end version
## --

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- ## Reverting table: watercraft_risk_assessment
-- ## Version: bilgePlugFields
-- ## Info: Adding new columns drainplugRemovedAtInspection & watercraftHasDrainplugs
-- ## Removing New Columns ## --
ALTER TABLE watercraft_risk_assessment DROP COLUMN IF EXISTS watercraft_has_drainplugs;
ALTER TABLE watercraft_risk_assessment DROP COLUMN IF EXISTS drainplug_removed_at_inspection;

-- ## Updating watercraft_risk_assessment ## --
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- ## Changing table: watercraft_risk_assessment
-- ## Version: bilgePlugFields
-- ## Info: Adding new columns drainplugRemovedAtInspection & watercraftHasDrainplugs
-- ## Adding New Columns ## --

-- ## Adding Column watercraft_has_drainplugs on table watercraft_risk_assessment
ALTER TABLE watercraft_risk_assessment ADD COLUMN watercraft_has_drainplugs BOOLEAN NOT NULL DEFAULT FALSE;
COMMENT ON COLUMN watercraft_risk_assessment.watercraft_has_drainplugs IS 'Indicator that the inspected watercraft contained drain plugs in Bilge';
-- ## --


-- ## Adding Column drainplug_removed_at_inspection on table watercraft_risk_assessment
ALTER TABLE watercraft_risk_assessment ADD COLUMN drainplug_removed_at_inspection BOOLEAN NOT NULL DEFAULT FALSE;
COMMENT ON COLUMN watercraft_risk_assessment.drainplug_removed_at_inspection IS 'With "Pull The Plug" legislation in mind, were the drain plugs removed from vehicle';
-- ## --


-- ## Updating watercraft_risk_assessment ## --
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { AppDBMigrator } from '../applicationSchemaInterface';
import { WatercraftRiskAssessmentSchema } from '../database-schema';

export class WatercraftRiskAssessmentBilgePlugs1717598304136 extends AppDBMigrator implements MigrationInterface {
watercraftRiskAssessment: WatercraftRiskAssessmentSchema;

setup() {
this.watercraftRiskAssessment = new WatercraftRiskAssessmentSchema();
this.addSchemaVersion(this.watercraftRiskAssessment, 'bilgePlugFields');
}
public async up(queryRunner: QueryRunner): Promise<any> {
this.log('[START]', 'UP');
await this.runQuerySqlFiles(this.upMigrations(), queryRunner);
this.log('[END]', 'UP');
}

public async down(queryRunner: QueryRunner): Promise<any> {
this.log('[STAR]', 'DOWN');
await this.runQuerySqlFiles(this.downMigrations(), queryRunner);
this.log('[END]', 'DOWN');
}

}
Loading
Loading