diff --git a/api/api_sources/schema-files/watercraftRiskAssessment.schema.yaml b/api/api_sources/schema-files/watercraftRiskAssessment.schema.yaml index 3b729969..71dbba07 100644 --- a/api/api_sources/schema-files/watercraftRiskAssessment.schema.yaml +++ b/api/api_sources/schema-files/watercraftRiskAssessment.schema.yaml @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 ## -- - diff --git a/api/api_sources/schema-migration-sql/WatercraftRiskAssessmentSchema/WatercraftRiskAssessmentSchema-bilgePlugFields-20240605.down.sql b/api/api_sources/schema-migration-sql/WatercraftRiskAssessmentSchema/WatercraftRiskAssessmentSchema-bilgePlugFields-20240605.down.sql new file mode 100644 index 00000000..77311f20 --- /dev/null +++ b/api/api_sources/schema-migration-sql/WatercraftRiskAssessmentSchema/WatercraftRiskAssessmentSchema-bilgePlugFields-20240605.down.sql @@ -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 ## -- diff --git a/api/api_sources/schema-migration-sql/WatercraftRiskAssessmentSchema/WatercraftRiskAssessmentSchema-bilgePlugFields-20240605.up.sql b/api/api_sources/schema-migration-sql/WatercraftRiskAssessmentSchema/WatercraftRiskAssessmentSchema-bilgePlugFields-20240605.up.sql new file mode 100644 index 00000000..c907587a --- /dev/null +++ b/api/api_sources/schema-migration-sql/WatercraftRiskAssessmentSchema/WatercraftRiskAssessmentSchema-bilgePlugFields-20240605.up.sql @@ -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 ## -- diff --git a/api/api_sources/sources/database/migrations/1717598304136-watercraftRiskAssessmentBilgePlugs.ts b/api/api_sources/sources/database/migrations/1717598304136-watercraftRiskAssessmentBilgePlugs.ts new file mode 100644 index 00000000..a7d050ab --- /dev/null +++ b/api/api_sources/sources/database/migrations/1717598304136-watercraftRiskAssessmentBilgePlugs.ts @@ -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 { + this.log('[START]', 'UP'); + await this.runQuerySqlFiles(this.upMigrations(), queryRunner); + this.log('[END]', 'UP'); + } + + public async down(queryRunner: QueryRunner): Promise { + this.log('[STAR]', 'DOWN'); + await this.runQuerySqlFiles(this.downMigrations(), queryRunner); + this.log('[END]', 'DOWN'); + } + +} diff --git a/api/api_sources/sources/database/models/controllers/watercraftRiskAssessment.controller.ts b/api/api_sources/sources/database/models/controllers/watercraftRiskAssessment.controller.ts index 022c0ea9..24269a7a 100644 --- a/api/api_sources/sources/database/models/controllers/watercraftRiskAssessment.controller.ts +++ b/api/api_sources/sources/database/models/controllers/watercraftRiskAssessment.controller.ts @@ -1,7 +1,7 @@ // ** WatercraftRiskAssessmentController ** // import { RecordController } from '../generic.data.models'; -import { WatercraftRiskAssessment} from '../watercraftRiskAssessment'; +import { WatercraftRiskAssessment } from '../watercraftRiskAssessment'; import { WatercraftRiskAssessmentSchema } from '../../database-schema'; @@ -22,7 +22,7 @@ export class WatercraftRiskAssessmentController extends RecordController HighRiskAssessment, { eager: true}) - @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.highRiskAssessment, referencedColumnName: HighRiskAssessmentSchema.pk}) - @ModelProperty({type: PropertyType.object}) + @ManyToOne(type => HighRiskAssessment, { eager: true }) + @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.highRiskAssessment, referencedColumnName: HighRiskAssessmentSchema.pk }) + @ModelProperty({ type: PropertyType.object }) highRiskAssessment: HighRiskAssessment; /** * @description Getter/Setter property for column {previous_ais_knowledge_source_code_id} */ - @ManyToOne( type => PreviousAISKnowledgeSource, { eager: true}) - @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.previousAISKnowledgeSource, referencedColumnName: PreviousAISKnowledgeSourceSchema.pk}) - @ModelProperty({type: PropertyType.object}) + @ManyToOne(type => PreviousAISKnowledgeSource, { eager: true }) + @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.previousAISKnowledgeSource, referencedColumnName: PreviousAISKnowledgeSourceSchema.pk }) + @ModelProperty({ type: PropertyType.object }) previousAISKnowledgeSource: PreviousAISKnowledgeSource; /** * @description Getter/Setter property for column {previous_inspection_source_code_id} */ - @ManyToOne( type => PreviousInspectionSource, { eager: true}) - @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.previousInspectionSource, referencedColumnName: PreviousInspectionSourceSchema.pk}) - @ModelProperty({type: PropertyType.object}) + @ManyToOne(type => PreviousInspectionSource, { eager: true }) + @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.previousInspectionSource, referencedColumnName: PreviousInspectionSourceSchema.pk }) + @ModelProperty({ type: PropertyType.object }) previousInspectionSource: PreviousInspectionSource; /** * @description Getter/Setter property for column {province_code} */ - @Column({ name: WatercraftRiskAssessmentSchema.columns.provinceOfResidence}) - @ModelProperty({type: PropertyType.string}) + @Column({ name: WatercraftRiskAssessmentSchema.columns.provinceOfResidence }) + @ModelProperty({ type: PropertyType.string }) provinceOfResidence: string; /** * @description Getter/Setter property for column {country_code} */ - @Column({ name: WatercraftRiskAssessmentSchema.columns.countryOfResidence}) - @ModelProperty({type: PropertyType.string}) + @Column({ name: WatercraftRiskAssessmentSchema.columns.countryOfResidence }) + @ModelProperty({ type: PropertyType.string }) countryOfResidence: string; - /** + /** * @description Getter/Setter property for column {number_of_people_in_party} */ - @Column({name: WatercraftRiskAssessmentSchema.columns.numberOfPeopleInParty, transformer: new IntTransformer()}) - @ModelProperty({type: PropertyType.number}) + @Column({ name: WatercraftRiskAssessmentSchema.columns.numberOfPeopleInParty, transformer: new IntTransformer() }) + @ModelProperty({ type: PropertyType.number }) numberOfPeopleInParty: number; /** * @description Getter/Setter property for column {observer_workflow_id} */ - @ManyToOne( type => ObserverWorkflow, { eager: true}) - @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.workflow, referencedColumnName: ObserverWorkflowSchema.pk}) - @ModelProperty({type: PropertyType.object}) + @ManyToOne(type => ObserverWorkflow, { eager: true }) + @JoinColumn({ name: WatercraftRiskAssessmentSchema.columns.workflow, referencedColumnName: ObserverWorkflowSchema.pk }) + @ModelProperty({ type: PropertyType.object }) workflow: ObserverWorkflow; /** @@ -461,10 +465,25 @@ export class WatercraftRiskAssessment extends Record implements WatercraftRiskAs @OneToMany( type => WatercraftJourney, obj => obj.watercraftAssessment, - { eager: true} + { eager: true } ) - @ModelProperty({type: PropertyType.array, $ref: '#/definitions/WatercraftJourney'}) + @ModelProperty({ type: PropertyType.array, $ref: '#/definitions/WatercraftJourney' }) journeys: WatercraftJourney[]; + + + /** + * @description Getter/Setter property for column {watercraft_has_drainplugs} + */ + @Column({ name: WatercraftRiskAssessmentSchema.columns.watercraftHasDrainplugs }) + @ModelProperty({ type: PropertyType.boolean }) + watercraftHasDrainplugs: boolean; + + /** + * @description Getter/Setter property for column {drainplug_removed_at_inspection} + */ + @Column({ name: WatercraftRiskAssessmentSchema.columns.drainplugRemovedAtInspection }) + @ModelProperty({ type: PropertyType.boolean }) + drainplugRemovedAtInspection: boolean; } // -------------------------------------