From bd16f69e28a06344cc6d761b9708c06a8fa4b503 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 5 Dec 2025 23:11:57 +0000 Subject: [PATCH] Initially made it through full update with new fieldseeker schema --- arcgis-go | 2 +- arcgis.go | 9 +- cmd/query-test/main.go | 39 +- db/bob | 2 +- db/dberrors/bob_errors.bob.go | 2 +- db/dberrors/bob_main.bob_test.go | 2 +- .../fieldseeker.containerrelate.bob.go | 4 +- .../fieldseeker.fieldscoutinglog.bob.go | 4 +- db/dberrors/fieldseeker.habitatrelate.bob.go | 4 +- .../fieldseeker.inspectionsample.bob.go | 4 +- .../fieldseeker.inspectionsampledetail.bob.go | 4 +- db/dberrors/fieldseeker.linelocation.bob.go | 4 +- .../fieldseeker.locationtracking.bob.go | 4 +- .../fieldseeker.mosquitoinspection.bob.go | 4 +- db/dberrors/fieldseeker.pointlocation.bob.go | 4 +- .../fieldseeker.polygonlocation.bob.go | 4 +- db/dberrors/fieldseeker.pool.bob.go | 4 +- db/dberrors/fieldseeker.pooldetail.bob.go | 4 +- .../fieldseeker.proposedtreatmentarea.bob.go | 4 +- .../fieldseeker.qamosquitoinspection.bob.go | 4 +- db/dberrors/fieldseeker.rodentlocation.bob.go | 4 +- .../fieldseeker.samplecollection.bob.go | 4 +- db/dberrors/fieldseeker.samplelocation.bob.go | 4 +- db/dberrors/fieldseeker.servicerequest.bob.go | 4 +- .../fieldseeker.speciesabundance.bob.go | 4 +- db/dberrors/fieldseeker.stormdrain.bob.go | 4 +- db/dberrors/fieldseeker.timecard.bob.go | 4 +- db/dberrors/fieldseeker.trapdata.bob.go | 4 +- db/dberrors/fieldseeker.traplocation.bob.go | 4 +- db/dberrors/fieldseeker.treatment.bob.go | 4 +- db/dberrors/fieldseeker.treatmentarea.bob.go | 4 +- db/dberrors/fieldseeker.zones.bob.go | 4 +- db/dberrors/fieldseeker.zones2.bob.go | 4 +- db/dberrors/fieldseeker_sync.bob.go | 2 +- db/dberrors/fs_containerrelate.bob.go | 2 +- db/dberrors/fs_fieldscoutinglog.bob.go | 2 +- db/dberrors/fs_habitatrelate.bob.go | 2 +- db/dberrors/fs_inspectionsample.bob.go | 2 +- db/dberrors/fs_inspectionsampledetail.bob.go | 2 +- db/dberrors/fs_linelocation.bob.go | 2 +- db/dberrors/fs_locationtracking.bob.go | 2 +- db/dberrors/fs_mosquitoinspection.bob.go | 2 +- db/dberrors/fs_pointlocation.bob.go | 2 +- db/dberrors/fs_polygonlocation.bob.go | 2 +- db/dberrors/fs_pool.bob.go | 2 +- db/dberrors/fs_pooldetail.bob.go | 2 +- db/dberrors/fs_proposedtreatmentarea.bob.go | 2 +- db/dberrors/fs_qamosquitoinspection.bob.go | 2 +- db/dberrors/fs_rodentlocation.bob.go | 2 +- db/dberrors/fs_samplecollection.bob.go | 2 +- db/dberrors/fs_samplelocation.bob.go | 2 +- db/dberrors/fs_servicerequest.bob.go | 2 +- db/dberrors/fs_speciesabundance.bob.go | 2 +- db/dberrors/fs_stormdrain.bob.go | 2 +- db/dberrors/fs_timecard.bob.go | 2 +- db/dberrors/fs_trapdata.bob.go | 2 +- db/dberrors/fs_traplocation.bob.go | 2 +- db/dberrors/fs_treatment.bob.go | 2 +- db/dberrors/fs_treatmentarea.bob.go | 2 +- db/dberrors/fs_zones.bob.go | 2 +- db/dberrors/fs_zones2.bob.go | 2 +- db/dberrors/goose_db_version.bob.go | 2 +- db/dberrors/h3_aggregation.bob.go | 2 +- db/dberrors/h3_aggregation.bob_test.go | 2 +- db/dberrors/history_containerrelate.bob.go | 2 +- db/dberrors/history_fieldscoutinglog.bob.go | 2 +- db/dberrors/history_habitatrelate.bob.go | 2 +- db/dberrors/history_inspectionsample.bob.go | 2 +- .../history_inspectionsampledetail.bob.go | 2 +- db/dberrors/history_linelocation.bob.go | 2 +- db/dberrors/history_locationtracking.bob.go | 2 +- db/dberrors/history_mosquitoinspection.bob.go | 2 +- db/dberrors/history_pointlocation.bob.go | 2 +- db/dberrors/history_polygonlocation.bob.go | 2 +- db/dberrors/history_pool.bob.go | 2 +- db/dberrors/history_pooldetail.bob.go | 2 +- .../history_proposedtreatmentarea.bob.go | 2 +- .../history_qamosquitoinspection.bob.go | 2 +- db/dberrors/history_rodentlocation.bob.go | 2 +- db/dberrors/history_samplecollection.bob.go | 2 +- db/dberrors/history_samplelocation.bob.go | 2 +- db/dberrors/history_servicerequest.bob.go | 2 +- db/dberrors/history_speciesabundance.bob.go | 2 +- db/dberrors/history_stormdrain.bob.go | 2 +- db/dberrors/history_timecard.bob.go | 2 +- db/dberrors/history_trapdata.bob.go | 2 +- db/dberrors/history_traplocation.bob.go | 2 +- db/dberrors/history_treatment.bob.go | 2 +- db/dberrors/history_treatmentarea.bob.go | 2 +- db/dberrors/history_zones.bob.go | 2 +- db/dberrors/history_zones2.bob.go | 2 +- db/dberrors/notification.bob.go | 2 +- db/dberrors/oauth_token.bob.go | 2 +- db/dberrors/organization.bob.go | 2 +- db/dberrors/sessions.bob.go | 2 +- db/dberrors/spatial_ref_sys.bob.go | 2 +- db/dberrors/user_.bob.go | 2 +- db/dbinfo/bob_types.bob.go | 2 +- db/dbinfo/fieldseeker.aerialsprayline.bob.go | 48 - .../fieldseeker.aerialspraysession.bob.go | 48 - db/dbinfo/fieldseeker.barrierspray.bob.go | 48 - .../fieldseeker.barriersprayroute.bob.go | 48 - db/dbinfo/fieldseeker.containerrelate.bob.go | 23 +- db/dbinfo/fieldseeker.fieldscoutinglog.bob.go | 23 +- db/dbinfo/fieldseeker.habitatrelate.bob.go | 23 +- db/dbinfo/fieldseeker.inspectionsample.bob.go | 23 +- .../fieldseeker.inspectionsampledetail.bob.go | 23 +- db/dbinfo/fieldseeker.landingcount.bob.go | 48 - .../fieldseeker.landingcountlocation.bob.go | 48 - db/dbinfo/fieldseeker.linelocation.bob.go | 23 +- db/dbinfo/fieldseeker.locationtracking.bob.go | 23 +- .../fieldseeker.mosquitoinspection.bob.go | 23 +- db/dbinfo/fieldseeker.pointlocation.bob.go | 23 +- db/dbinfo/fieldseeker.polygonlocation.bob.go | 23 +- db/dbinfo/fieldseeker.pool.bob.go | 23 +- db/dbinfo/fieldseeker.poolbuffer.bob.go | 48 - db/dbinfo/fieldseeker.pooldetail.bob.go | 23 +- .../fieldseeker.proposedtreatmentarea.bob.go | 23 +- db/dbinfo/fieldseeker.qalarvcount.bob.go | 48 - .../fieldseeker.qamosquitoinspection.bob.go | 23 +- .../fieldseeker.qaproductobservation.bob.go | 48 - db/dbinfo/fieldseeker.restrictedarea.bob.go | 48 - db/dbinfo/fieldseeker.rodentinspection.bob.go | 48 - db/dbinfo/fieldseeker.rodentlocation.bob.go | 52 +- db/dbinfo/fieldseeker.samplecollection.bob.go | 23 +- db/dbinfo/fieldseeker.samplelocation.bob.go | 23 +- db/dbinfo/fieldseeker.servicerequest.bob.go | 23 +- db/dbinfo/fieldseeker.speciesabundance.bob.go | 23 +- db/dbinfo/fieldseeker.stormdrain.bob.go | 23 +- db/dbinfo/fieldseeker.timecard.bob.go | 23 +- db/dbinfo/fieldseeker.tracklog.bob.go | 48 - db/dbinfo/fieldseeker.trapdata.bob.go | 23 +- db/dbinfo/fieldseeker.traplocation.bob.go | 23 +- db/dbinfo/fieldseeker.treatment.bob.go | 23 +- db/dbinfo/fieldseeker.treatmentarea.bob.go | 23 +- db/dbinfo/fieldseeker.ulvsprayroute.bob.go | 48 - db/dbinfo/fieldseeker.zones.bob.go | 23 +- db/dbinfo/fieldseeker.zones2.bob.go | 23 +- db/dbinfo/fieldseeker_sync.bob.go | 2 +- db/dbinfo/fs_containerrelate.bob.go | 2 +- db/dbinfo/fs_fieldscoutinglog.bob.go | 2 +- db/dbinfo/fs_habitatrelate.bob.go | 2 +- db/dbinfo/fs_inspectionsample.bob.go | 2 +- db/dbinfo/fs_inspectionsampledetail.bob.go | 2 +- db/dbinfo/fs_linelocation.bob.go | 2 +- db/dbinfo/fs_locationtracking.bob.go | 2 +- db/dbinfo/fs_mosquitoinspection.bob.go | 2 +- db/dbinfo/fs_pointlocation.bob.go | 2 +- db/dbinfo/fs_polygonlocation.bob.go | 2 +- db/dbinfo/fs_pool.bob.go | 2 +- db/dbinfo/fs_pooldetail.bob.go | 2 +- db/dbinfo/fs_proposedtreatmentarea.bob.go | 2 +- db/dbinfo/fs_qamosquitoinspection.bob.go | 2 +- db/dbinfo/fs_rodentlocation.bob.go | 2 +- db/dbinfo/fs_samplecollection.bob.go | 2 +- db/dbinfo/fs_samplelocation.bob.go | 2 +- db/dbinfo/fs_servicerequest.bob.go | 2 +- db/dbinfo/fs_speciesabundance.bob.go | 2 +- db/dbinfo/fs_stormdrain.bob.go | 2 +- db/dbinfo/fs_timecard.bob.go | 2 +- db/dbinfo/fs_trapdata.bob.go | 2 +- db/dbinfo/fs_traplocation.bob.go | 2 +- db/dbinfo/fs_treatment.bob.go | 2 +- db/dbinfo/fs_treatmentarea.bob.go | 2 +- db/dbinfo/fs_zones.bob.go | 2 +- db/dbinfo/fs_zones2.bob.go | 2 +- db/dbinfo/geography_columns.bob.go | 2 +- db/dbinfo/geometry_columns.bob.go | 2 +- db/dbinfo/goose_db_version.bob.go | 2 +- db/dbinfo/h3_aggregation.bob.go | 2 +- db/dbinfo/history_containerrelate.bob.go | 2 +- db/dbinfo/history_fieldscoutinglog.bob.go | 2 +- db/dbinfo/history_habitatrelate.bob.go | 2 +- db/dbinfo/history_inspectionsample.bob.go | 2 +- .../history_inspectionsampledetail.bob.go | 2 +- db/dbinfo/history_linelocation.bob.go | 2 +- db/dbinfo/history_locationtracking.bob.go | 2 +- db/dbinfo/history_mosquitoinspection.bob.go | 2 +- db/dbinfo/history_pointlocation.bob.go | 2 +- db/dbinfo/history_polygonlocation.bob.go | 2 +- db/dbinfo/history_pool.bob.go | 2 +- db/dbinfo/history_pooldetail.bob.go | 2 +- .../history_proposedtreatmentarea.bob.go | 2 +- db/dbinfo/history_qamosquitoinspection.bob.go | 2 +- db/dbinfo/history_rodentlocation.bob.go | 2 +- db/dbinfo/history_samplecollection.bob.go | 2 +- db/dbinfo/history_samplelocation.bob.go | 2 +- db/dbinfo/history_servicerequest.bob.go | 2 +- db/dbinfo/history_speciesabundance.bob.go | 2 +- db/dbinfo/history_stormdrain.bob.go | 2 +- db/dbinfo/history_timecard.bob.go | 2 +- db/dbinfo/history_trapdata.bob.go | 2 +- db/dbinfo/history_traplocation.bob.go | 2 +- db/dbinfo/history_treatment.bob.go | 2 +- db/dbinfo/history_treatmentarea.bob.go | 2 +- db/dbinfo/history_zones.bob.go | 2 +- db/dbinfo/history_zones2.bob.go | 2 +- db/dbinfo/notification.bob.go | 2 +- db/dbinfo/oauth_token.bob.go | 2 +- db/dbinfo/organization.bob.go | 2 +- db/dbinfo/raster_columns.bob.go | 2 +- db/dbinfo/raster_overviews.bob.go | 2 +- db/dbinfo/sessions.bob.go | 2 +- db/dbinfo/spatial_ref_sys.bob.go | 2 +- db/dbinfo/user_.bob.go | 2 +- db/enums/enums.bob.go | 2 +- db/factory/bobfactory_context.bob.go | 43 +- db/factory/bobfactory_main.bob.go | 441 +- db/factory/bobfactory_main.bob_test.go | 2 +- db/factory/bobfactory_random.bob.go | 2 +- db/factory/bobfactory_random.bob_test.go | 2 +- db/factory/fieldseeker.aerialsprayline.bob.go | 90 - .../fieldseeker.aerialspraysession.bob.go | 91 - db/factory/fieldseeker.barrierspray.bob.go | 90 - .../fieldseeker.barriersprayroute.bob.go | 90 - db/factory/fieldseeker.containerrelate.bob.go | 42 +- .../fieldseeker.fieldscoutinglog.bob.go | 42 +- db/factory/fieldseeker.habitatrelate.bob.go | 42 +- .../fieldseeker.inspectionsample.bob.go | 42 +- .../fieldseeker.inspectionsampledetail.bob.go | 42 +- db/factory/fieldseeker.landingcount.bob.go | 90 - .../fieldseeker.landingcountlocation.bob.go | 91 - db/factory/fieldseeker.linelocation.bob.go | 42 +- .../fieldseeker.locationtracking.bob.go | 42 +- .../fieldseeker.mosquitoinspection.bob.go | 42 +- db/factory/fieldseeker.pointlocation.bob.go | 42 +- db/factory/fieldseeker.polygonlocation.bob.go | 42 +- db/factory/fieldseeker.pool.bob.go | 42 +- db/factory/fieldseeker.poolbuffer.bob.go | 90 - db/factory/fieldseeker.pooldetail.bob.go | 42 +- .../fieldseeker.proposedtreatmentarea.bob.go | 42 +- db/factory/fieldseeker.qalarvcount.bob.go | 90 - .../fieldseeker.qamosquitoinspection.bob.go | 42 +- .../fieldseeker.qaproductobservation.bob.go | 91 - db/factory/fieldseeker.restrictedarea.bob.go | 90 - .../fieldseeker.rodentinspection.bob.go | 90 - db/factory/fieldseeker.rodentlocation.bob.go | 158 +- .../fieldseeker.samplecollection.bob.go | 42 +- db/factory/fieldseeker.samplelocation.bob.go | 42 +- db/factory/fieldseeker.servicerequest.bob.go | 42 +- .../fieldseeker.speciesabundance.bob.go | 42 +- db/factory/fieldseeker.stormdrain.bob.go | 42 +- db/factory/fieldseeker.timecard.bob.go | 42 +- db/factory/fieldseeker.tracklog.bob.go | 90 - db/factory/fieldseeker.trapdata.bob.go | 42 +- db/factory/fieldseeker.traplocation.bob.go | 42 +- db/factory/fieldseeker.treatment.bob.go | 42 +- db/factory/fieldseeker.treatmentarea.bob.go | 42 +- db/factory/fieldseeker.ulvsprayroute.bob.go | 90 - db/factory/fieldseeker.zones.bob.go | 42 +- db/factory/fieldseeker.zones2.bob.go | 42 +- db/factory/fieldseeker_sync.bob.go | 2 +- db/factory/fs_containerrelate.bob.go | 2 +- db/factory/fs_fieldscoutinglog.bob.go | 2 +- db/factory/fs_habitatrelate.bob.go | 2 +- db/factory/fs_inspectionsample.bob.go | 2 +- db/factory/fs_inspectionsampledetail.bob.go | 2 +- db/factory/fs_linelocation.bob.go | 2 +- db/factory/fs_locationtracking.bob.go | 2 +- db/factory/fs_mosquitoinspection.bob.go | 2 +- db/factory/fs_pointlocation.bob.go | 2 +- db/factory/fs_polygonlocation.bob.go | 2 +- db/factory/fs_pool.bob.go | 2 +- db/factory/fs_pooldetail.bob.go | 2 +- db/factory/fs_proposedtreatmentarea.bob.go | 2 +- db/factory/fs_qamosquitoinspection.bob.go | 2 +- db/factory/fs_rodentlocation.bob.go | 2 +- db/factory/fs_samplecollection.bob.go | 2 +- db/factory/fs_samplelocation.bob.go | 2 +- db/factory/fs_servicerequest.bob.go | 2 +- db/factory/fs_speciesabundance.bob.go | 2 +- db/factory/fs_stormdrain.bob.go | 2 +- db/factory/fs_timecard.bob.go | 2 +- db/factory/fs_trapdata.bob.go | 2 +- db/factory/fs_traplocation.bob.go | 2 +- db/factory/fs_treatment.bob.go | 2 +- db/factory/fs_treatmentarea.bob.go | 2 +- db/factory/fs_zones.bob.go | 2 +- db/factory/fs_zones2.bob.go | 2 +- db/factory/geography_columns.bob.go | 2 +- db/factory/geometry_columns.bob.go | 2 +- db/factory/goose_db_version.bob.go | 2 +- db/factory/h3_aggregation.bob.go | 2 +- db/factory/history_containerrelate.bob.go | 2 +- db/factory/history_fieldscoutinglog.bob.go | 2 +- db/factory/history_habitatrelate.bob.go | 2 +- db/factory/history_inspectionsample.bob.go | 2 +- .../history_inspectionsampledetail.bob.go | 2 +- db/factory/history_linelocation.bob.go | 2 +- db/factory/history_locationtracking.bob.go | 2 +- db/factory/history_mosquitoinspection.bob.go | 2 +- db/factory/history_pointlocation.bob.go | 2 +- db/factory/history_polygonlocation.bob.go | 2 +- db/factory/history_pool.bob.go | 2 +- db/factory/history_pooldetail.bob.go | 2 +- .../history_proposedtreatmentarea.bob.go | 2 +- .../history_qamosquitoinspection.bob.go | 2 +- db/factory/history_rodentlocation.bob.go | 2 +- db/factory/history_samplecollection.bob.go | 2 +- db/factory/history_samplelocation.bob.go | 2 +- db/factory/history_servicerequest.bob.go | 2 +- db/factory/history_speciesabundance.bob.go | 2 +- db/factory/history_stormdrain.bob.go | 2 +- db/factory/history_timecard.bob.go | 2 +- db/factory/history_trapdata.bob.go | 2 +- db/factory/history_traplocation.bob.go | 2 +- db/factory/history_treatment.bob.go | 2 +- db/factory/history_treatmentarea.bob.go | 2 +- db/factory/history_zones.bob.go | 2 +- db/factory/history_zones2.bob.go | 2 +- db/factory/notification.bob.go | 2 +- db/factory/oauth_token.bob.go | 2 +- db/factory/organization.bob.go | 316 +- db/factory/raster_columns.bob.go | 2 +- db/factory/raster_overviews.bob.go | 2 +- db/factory/sessions.bob.go | 2 +- db/factory/spatial_ref_sys.bob.go | 2 +- db/factory/user_.bob.go | 2 +- db/fieldseeker-schema/containerrelate.sql | 42 - db/fieldseeker-schema/fieldscoutinglog.sql | 38 - db/fieldseeker-schema/habitatrelate.sql | 76 - .../insert_containerrelate_versioned.sql | 171 +- .../insert_fieldscoutinglog_versioned.sql | 153 +- .../insert/insert_habitatrelate_versioned.sql | 159 +- .../insert_inspectionsample_versioned.sql | 171 +- ...nsert_inspectionsampledetail_versioned.sql | 237 +- .../insert/insert_linelocation_versioned.sql | 375 +- .../insert_locationtracking_versioned.sql | 159 +- .../insert_mosquitoinspection_versioned.sql | 429 +- .../insert/insert_pointlocation_versioned.sql | 351 +- .../insert_polygonlocation_versioned.sql | 339 +- .../insert/insert_pool_versioned.sql | 255 +- .../insert/insert_pooldetail_versioned.sql | 171 +- ...insert_proposedtreatmentarea_versioned.sql | 285 +- .../insert_qamosquitoinspection_versioned.sql | 459 +- .../insert_rodentlocation_versioned.sql | 267 +- .../insert_samplecollection_versioned.sql | 363 +- .../insert_samplelocation_versioned.sql | 231 +- .../insert_servicerequest_versioned.sql | 603 +- .../insert_speciesabundance_versioned.sql | 261 +- .../insert/insert_stormdrain_versioned.sql | 201 +- .../insert/insert_timecard_versioned.sql | 255 +- .../insert/insert_trapdata_versioned.sql | 339 +- .../insert/insert_traplocation_versioned.sql | 267 +- .../insert/insert_treatment_versioned.sql | 411 +- .../insert/insert_treatmentarea_versioned.sql | 195 +- .../insert/insert_zones2_versioned.sql | 165 +- .../insert/insert_zones_versioned.sql | 171 +- db/fieldseeker-schema/inspectionsample.sql | 41 - .../inspectionsampledetail.sql | 78 - db/fieldseeker-schema/linelocation.sql | 198 - db/fieldseeker-schema/locationtracking.sql | 33 - db/fieldseeker-schema/mosquitoinspection.sql | 224 - db/fieldseeker-schema/pointlocation.sql | 236 - db/fieldseeker-schema/polygonlocation.sql | 186 - db/fieldseeker-schema/pool.sql | 93 - db/fieldseeker-schema/pooldetail.sql | 37 - .../proposedtreatmentarea.sql | 99 - .../qamosquitoinspection.sql | 254 - db/fieldseeker-schema/rodentlocation.sql | 94 - db/fieldseeker-schema/samplecollection.sql | 197 - db/fieldseeker-schema/samplelocation.sql | 93 - db/fieldseeker-schema/servicerequest.sql | 324 -- db/fieldseeker-schema/speciesabundance.sql | 66 - db/fieldseeker-schema/stormdrain.sql | 48 - db/fieldseeker-schema/timecard.sql | 93 - db/fieldseeker-schema/trapdata.sql | 131 - db/fieldseeker-schema/traplocation.sql | 98 - db/fieldseeker-schema/treatment.sql | 259 - db/fieldseeker-schema/treatmentarea.sql | 38 - db/fieldseeker-schema/zones.sql | 34 - db/fieldseeker-schema/zones2.sql | 33 - db/fieldseeker.go | 349 +- db/migrations/00016_fieldseeker_schema.sql | 4879 ++++------------- db/migrations/00017_fieldseeker_inserts.sql | 4016 +++++++++++++- db/models/bob_joins.bob.go | 4 +- db/models/bob_loaders.bob.go | 6 +- db/models/bob_types.bob_test.go | 41 +- db/models/bob_where.bob.go | 41 +- db/models/fieldseeker.aerialsprayline.bob.go | 79 - .../fieldseeker.aerialspraysession.bob.go | 79 - db/models/fieldseeker.barrierspray.bob.go | 79 - .../fieldseeker.barriersprayroute.bob.go | 79 - db/models/fieldseeker.containerrelate.bob.go | 56 +- db/models/fieldseeker.fieldscoutinglog.bob.go | 56 +- db/models/fieldseeker.habitatrelate.bob.go | 56 +- db/models/fieldseeker.inspectionsample.bob.go | 56 +- .../fieldseeker.inspectionsampledetail.bob.go | 56 +- db/models/fieldseeker.landingcount.bob.go | 79 - .../fieldseeker.landingcountlocation.bob.go | 79 - db/models/fieldseeker.linelocation.bob.go | 56 +- db/models/fieldseeker.locationtracking.bob.go | 56 +- .../fieldseeker.mosquitoinspection.bob.go | 56 +- db/models/fieldseeker.pointlocation.bob.go | 56 +- db/models/fieldseeker.polygonlocation.bob.go | 56 +- db/models/fieldseeker.pool.bob.go | 56 +- db/models/fieldseeker.poolbuffer.bob.go | 79 - db/models/fieldseeker.pooldetail.bob.go | 56 +- .../fieldseeker.proposedtreatmentarea.bob.go | 56 +- db/models/fieldseeker.qalarvcount.bob.go | 79 - .../fieldseeker.qamosquitoinspection.bob.go | 56 +- .../fieldseeker.qaproductobservation.bob.go | 79 - db/models/fieldseeker.restrictedarea.bob.go | 79 - db/models/fieldseeker.rodentinspection.bob.go | 79 - db/models/fieldseeker.rodentlocation.bob.go | 422 +- db/models/fieldseeker.samplecollection.bob.go | 56 +- db/models/fieldseeker.samplelocation.bob.go | 56 +- db/models/fieldseeker.servicerequest.bob.go | 56 +- db/models/fieldseeker.speciesabundance.bob.go | 56 +- db/models/fieldseeker.stormdrain.bob.go | 56 +- db/models/fieldseeker.timecard.bob.go | 56 +- db/models/fieldseeker.tracklog.bob.go | 79 - db/models/fieldseeker.trapdata.bob.go | 56 +- db/models/fieldseeker.traplocation.bob.go | 56 +- db/models/fieldseeker.treatment.bob.go | 56 +- db/models/fieldseeker.treatmentarea.bob.go | 56 +- db/models/fieldseeker.ulvsprayroute.bob.go | 79 - db/models/fieldseeker.zones.bob.go | 56 +- db/models/fieldseeker.zones2.bob.go | 56 +- db/models/fieldseeker_sync.bob.go | 2 +- db/models/fs_containerrelate.bob.go | 2 +- db/models/fs_fieldscoutinglog.bob.go | 2 +- db/models/fs_habitatrelate.bob.go | 2 +- db/models/fs_inspectionsample.bob.go | 2 +- db/models/fs_inspectionsampledetail.bob.go | 2 +- db/models/fs_linelocation.bob.go | 2 +- db/models/fs_locationtracking.bob.go | 2 +- db/models/fs_mosquitoinspection.bob.go | 2 +- db/models/fs_pointlocation.bob.go | 2 +- db/models/fs_polygonlocation.bob.go | 2 +- db/models/fs_pool.bob.go | 2 +- db/models/fs_pooldetail.bob.go | 2 +- db/models/fs_proposedtreatmentarea.bob.go | 2 +- db/models/fs_qamosquitoinspection.bob.go | 2 +- db/models/fs_rodentlocation.bob.go | 2 +- db/models/fs_samplecollection.bob.go | 2 +- db/models/fs_samplelocation.bob.go | 2 +- db/models/fs_servicerequest.bob.go | 2 +- db/models/fs_speciesabundance.bob.go | 2 +- db/models/fs_stormdrain.bob.go | 2 +- db/models/fs_timecard.bob.go | 2 +- db/models/fs_trapdata.bob.go | 2 +- db/models/fs_traplocation.bob.go | 2 +- db/models/fs_treatment.bob.go | 2 +- db/models/fs_treatmentarea.bob.go | 2 +- db/models/fs_zones.bob.go | 2 +- db/models/fs_zones2.bob.go | 2 +- db/models/geography_columns.bob.go | 2 +- db/models/geometry_columns.bob.go | 2 +- db/models/goose_db_version.bob.go | 2 +- db/models/h3_aggregation.bob.go | 2 +- db/models/history_containerrelate.bob.go | 2 +- db/models/history_fieldscoutinglog.bob.go | 2 +- db/models/history_habitatrelate.bob.go | 2 +- db/models/history_inspectionsample.bob.go | 2 +- .../history_inspectionsampledetail.bob.go | 2 +- db/models/history_linelocation.bob.go | 2 +- db/models/history_locationtracking.bob.go | 2 +- db/models/history_mosquitoinspection.bob.go | 2 +- db/models/history_pointlocation.bob.go | 2 +- db/models/history_polygonlocation.bob.go | 2 +- db/models/history_pool.bob.go | 2 +- db/models/history_pooldetail.bob.go | 2 +- .../history_proposedtreatmentarea.bob.go | 2 +- db/models/history_qamosquitoinspection.bob.go | 2 +- db/models/history_rodentlocation.bob.go | 2 +- db/models/history_samplecollection.bob.go | 2 +- db/models/history_samplelocation.bob.go | 2 +- db/models/history_servicerequest.bob.go | 2 +- db/models/history_speciesabundance.bob.go | 2 +- db/models/history_stormdrain.bob.go | 2 +- db/models/history_timecard.bob.go | 2 +- db/models/history_trapdata.bob.go | 2 +- db/models/history_traplocation.bob.go | 2 +- db/models/history_treatment.bob.go | 2 +- db/models/history_treatmentarea.bob.go | 2 +- db/models/history_zones.bob.go | 2 +- db/models/history_zones2.bob.go | 2 +- db/models/notification.bob.go | 2 +- db/models/oauth_token.bob.go | 2 +- db/models/organization.bob.go | 195 +- db/models/raster_columns.bob.go | 2 +- db/models/raster_overviews.bob.go | 2 +- db/models/sessions.bob.go | 2 +- db/models/spatial_ref_sys.bob.go | 2 +- db/models/user_.bob.go | 2 +- db/prepared.go | 179 +- db/sql/oauth_by_user_id.bob.go | 4 +- db/sql/oauth_by_user_id.bob.sql | 2 +- db/sql/oauth_by_user_id.bob_test.go | 2 +- db/sql/org_by_oauth_id.bob.go | 4 +- db/sql/org_by_oauth_id.bob.sql | 2 +- db/sql/org_by_oauth_id.bob_test.go | 2 +- db/sql/test_utils.bob_test.go | 2 +- db/sql/trapcount_by_location_id.bob.go | 4 +- db/sql/trapcount_by_location_id.bob.sql | 2 +- db/sql/trapcount_by_location_id.bob_test.go | 2 +- db/sql/trapdata_by_location_id_recent.bob.go | 4 +- db/sql/trapdata_by_location_id_recent.bob.sql | 2 +- ...trapdata_by_location_id_recent.bob_test.go | 2 +- db/sql/traplocation_by_source_id.bob.go | 4 +- db/sql/traplocation_by_source_id.bob.sql | 2 +- db/sql/traplocation_by_source_id.bob_test.go | 2 +- db/sql/update_oauth_org.bob.go | 4 +- db/sql/update_oauth_org.bob.sql | 2 +- db/sql/update_oauth_org.bob_test.go | 2 +- db/sql/user_by_username.bob.go | 4 +- db/sql/user_by_username.bob.sql | 2 +- db/sql/user_by_username.bob_test.go | 2 +- main.go | 12 +- 510 files changed, 13617 insertions(+), 14851 deletions(-) delete mode 100644 db/dbinfo/fieldseeker.aerialsprayline.bob.go delete mode 100644 db/dbinfo/fieldseeker.aerialspraysession.bob.go delete mode 100644 db/dbinfo/fieldseeker.barrierspray.bob.go delete mode 100644 db/dbinfo/fieldseeker.barriersprayroute.bob.go delete mode 100644 db/dbinfo/fieldseeker.landingcount.bob.go delete mode 100644 db/dbinfo/fieldseeker.landingcountlocation.bob.go delete mode 100644 db/dbinfo/fieldseeker.poolbuffer.bob.go delete mode 100644 db/dbinfo/fieldseeker.qalarvcount.bob.go delete mode 100644 db/dbinfo/fieldseeker.qaproductobservation.bob.go delete mode 100644 db/dbinfo/fieldseeker.restrictedarea.bob.go delete mode 100644 db/dbinfo/fieldseeker.rodentinspection.bob.go delete mode 100644 db/dbinfo/fieldseeker.tracklog.bob.go delete mode 100644 db/dbinfo/fieldseeker.ulvsprayroute.bob.go delete mode 100644 db/factory/fieldseeker.aerialsprayline.bob.go delete mode 100644 db/factory/fieldseeker.aerialspraysession.bob.go delete mode 100644 db/factory/fieldseeker.barrierspray.bob.go delete mode 100644 db/factory/fieldseeker.barriersprayroute.bob.go delete mode 100644 db/factory/fieldseeker.landingcount.bob.go delete mode 100644 db/factory/fieldseeker.landingcountlocation.bob.go delete mode 100644 db/factory/fieldseeker.poolbuffer.bob.go delete mode 100644 db/factory/fieldseeker.qalarvcount.bob.go delete mode 100644 db/factory/fieldseeker.qaproductobservation.bob.go delete mode 100644 db/factory/fieldseeker.restrictedarea.bob.go delete mode 100644 db/factory/fieldseeker.rodentinspection.bob.go delete mode 100644 db/factory/fieldseeker.tracklog.bob.go delete mode 100644 db/factory/fieldseeker.ulvsprayroute.bob.go delete mode 100644 db/fieldseeker-schema/containerrelate.sql delete mode 100644 db/fieldseeker-schema/fieldscoutinglog.sql delete mode 100644 db/fieldseeker-schema/habitatrelate.sql delete mode 100644 db/fieldseeker-schema/inspectionsample.sql delete mode 100644 db/fieldseeker-schema/inspectionsampledetail.sql delete mode 100644 db/fieldseeker-schema/linelocation.sql delete mode 100644 db/fieldseeker-schema/locationtracking.sql delete mode 100644 db/fieldseeker-schema/mosquitoinspection.sql delete mode 100644 db/fieldseeker-schema/pointlocation.sql delete mode 100644 db/fieldseeker-schema/polygonlocation.sql delete mode 100644 db/fieldseeker-schema/pool.sql delete mode 100644 db/fieldseeker-schema/pooldetail.sql delete mode 100644 db/fieldseeker-schema/proposedtreatmentarea.sql delete mode 100644 db/fieldseeker-schema/qamosquitoinspection.sql delete mode 100644 db/fieldseeker-schema/rodentlocation.sql delete mode 100644 db/fieldseeker-schema/samplecollection.sql delete mode 100644 db/fieldseeker-schema/samplelocation.sql delete mode 100644 db/fieldseeker-schema/servicerequest.sql delete mode 100644 db/fieldseeker-schema/speciesabundance.sql delete mode 100644 db/fieldseeker-schema/stormdrain.sql delete mode 100644 db/fieldseeker-schema/timecard.sql delete mode 100644 db/fieldseeker-schema/trapdata.sql delete mode 100644 db/fieldseeker-schema/traplocation.sql delete mode 100644 db/fieldseeker-schema/treatment.sql delete mode 100644 db/fieldseeker-schema/treatmentarea.sql delete mode 100644 db/fieldseeker-schema/zones.sql delete mode 100644 db/fieldseeker-schema/zones2.sql delete mode 100644 db/models/fieldseeker.aerialsprayline.bob.go delete mode 100644 db/models/fieldseeker.aerialspraysession.bob.go delete mode 100644 db/models/fieldseeker.barrierspray.bob.go delete mode 100644 db/models/fieldseeker.barriersprayroute.bob.go delete mode 100644 db/models/fieldseeker.landingcount.bob.go delete mode 100644 db/models/fieldseeker.landingcountlocation.bob.go delete mode 100644 db/models/fieldseeker.poolbuffer.bob.go delete mode 100644 db/models/fieldseeker.qalarvcount.bob.go delete mode 100644 db/models/fieldseeker.qaproductobservation.bob.go delete mode 100644 db/models/fieldseeker.restrictedarea.bob.go delete mode 100644 db/models/fieldseeker.rodentinspection.bob.go delete mode 100644 db/models/fieldseeker.tracklog.bob.go delete mode 100644 db/models/fieldseeker.ulvsprayroute.bob.go diff --git a/arcgis-go b/arcgis-go index 587561f7..af786fab 160000 --- a/arcgis-go +++ b/arcgis-go @@ -1 +1 @@ -Subproject commit 587561f779b018d0701a3353c85f8da48519340b +Subproject commit af786fabcc08ed506a23718a71aa0dd52ce047ac diff --git a/arcgis.go b/arcgis.go index 53dd8e7c..8a5b0da8 100644 --- a/arcgis.go +++ b/arcgis.go @@ -97,6 +97,7 @@ func downloadFieldseekerSchema(ctx context.Context, fieldseekerClient *fieldseek log.Error().Err(err).Msg("Failed to open output") return } + defer output.Close() schema, err := fieldseekerClient.Schema(layer.ID) if err != nil { log.Error().Err(err).Msg("Failed to get schema") @@ -888,8 +889,8 @@ func insertRowFromFeatureFS(ctx context.Context, transaction pgx.Tx, table strin args[k] = v } // specially add geometry since it isn't in the list of attributes - args["geometry_x"] = feature.Geometry.X - args["geometry_y"] = feature.Geometry.Y + //args["geometry_x"] = feature.Geometry.X + //args["geometry_y"] = feature.Geometry.Y args["organization_id"] = org_id args["updated"] = time.Now() @@ -1059,8 +1060,8 @@ func updateRowFromFeatureFS(ctx context.Context, transaction pgx.Tx, table strin args[k] = v } // specially add geometry since it isn't in the list of attributes - args["geometry_x"] = feature.Geometry.X - args["geometry_y"] = feature.Geometry.Y + //args["geometry_x"] = feature.Geometry.X + //args["geometry_y"] = feature.Geometry.Y args["updated"] = time.Now() _, err := transaction.Exec(ctx, sb.String(), args) diff --git a/cmd/query-test/main.go b/cmd/query-test/main.go index bb2bbcd8..fc9747de 100644 --- a/cmd/query-test/main.go +++ b/cmd/query-test/main.go @@ -3,9 +3,12 @@ package main import ( "context" "os" + "time" + fslayer "github.com/Gleipnir-Technology/arcgis-go/fieldseeker/layer" "github.com/Gleipnir-Technology/nidus-sync/db" "github.com/alexedwards/scs/v2" + "github.com/google/uuid" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) @@ -69,9 +72,41 @@ func main() { os.Exit(2) } ctx := context.Background() - err = db.TestPreparedQuery(ctx) + row := fslayer.RodentLocation{ + ObjectID: 1, + LocationName: "some location", + Zone: "", + Zone2: "", + Habitat: fslayer.RodentLocationRodentLocationHabitatCommercial, + Priority: fslayer.RodentLocationLocationPriority1None, + Usetype: fslayer.RodentLocationLocationUseType1Residential, + Active: fslayer.RodentLocationNotInUITF1True, + Description: "", + Accessdesc: "", + Comments: "", + Symbology: fslayer.RodentLocationRodentLocationSymbologyActionrequired, + ExternalID: "", + Nextactiondatescheduled: time.Now(), + Locationnumber: 1, + LastInspectionDate: time.Now(), + LastInspectionSpecies: "", + LastInspectionAction: "", + LastInspectionConditions: "", + LastInspectionRodentEvidence: "", + GlobalID: uuid.New(), + CreatedUser: "", + CreatedDate: time.Now(), + LastEditedUser: "", + LastEditedDate: time.Now(), + CreationDate: time.Now(), + Creator: "", + EditDate: time.Now(), + Editor: "", + Jurisdiction: "", + } + err = db.TestPreparedQuery(ctx, &row) if err != nil { - log.Error().Str("err", err.Error()).Msg("Failed to connect to database") + log.Error().Str("err", err.Error()).Msg("Failed to run prepared query") os.Exit(3) } log.Info().Msg("Complete.") diff --git a/db/bob b/db/bob index 8e41efed..d277a066 160000 --- a/db/bob +++ b/db/bob @@ -1 +1 @@ -Subproject commit 8e41efed4f7ea4782ee7c2d06e2643967cce71d7 +Subproject commit d277a066d6bac5336e49615495ce2c74e736a7fd diff --git a/db/dberrors/bob_errors.bob.go b/db/dberrors/bob_errors.bob.go index 352ac860..588cc968 100644 --- a/db/dberrors/bob_errors.bob.go +++ b/db/dberrors/bob_errors.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/bob_main.bob_test.go b/db/dberrors/bob_main.bob_test.go index 67cde417..fc2ceba9 100644 --- a/db/dberrors/bob_main.bob_test.go +++ b/db/dberrors/bob_main.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.containerrelate.bob.go b/db/dberrors/fieldseeker.containerrelate.bob.go index c9fea5de..f1648dcd 100644 --- a/db/dberrors/fieldseeker.containerrelate.bob.go +++ b/db/dberrors/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerContainerrelateErrors = &fieldseekerContainerrelateErrors{ ErrUniqueContainerrelatePkey: &UniqueConstraintError{ schema: "fieldseeker", table: "containerrelate", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "containerrelate_pkey", }, } diff --git a/db/dberrors/fieldseeker.fieldscoutinglog.bob.go b/db/dberrors/fieldseeker.fieldscoutinglog.bob.go index 063e1be6..b3f155fc 100644 --- a/db/dberrors/fieldseeker.fieldscoutinglog.bob.go +++ b/db/dberrors/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerFieldscoutinglogErrors = &fieldseekerFieldscoutinglogErrors{ ErrUniqueFieldscoutinglogPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "fieldscoutinglog", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "fieldscoutinglog_pkey", }, } diff --git a/db/dberrors/fieldseeker.habitatrelate.bob.go b/db/dberrors/fieldseeker.habitatrelate.bob.go index 2a653662..50b934c9 100644 --- a/db/dberrors/fieldseeker.habitatrelate.bob.go +++ b/db/dberrors/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerHabitatrelateErrors = &fieldseekerHabitatrelateErrors{ ErrUniqueHabitatrelatePkey: &UniqueConstraintError{ schema: "fieldseeker", table: "habitatrelate", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "habitatrelate_pkey", }, } diff --git a/db/dberrors/fieldseeker.inspectionsample.bob.go b/db/dberrors/fieldseeker.inspectionsample.bob.go index 52724ece..25cf1ed5 100644 --- a/db/dberrors/fieldseeker.inspectionsample.bob.go +++ b/db/dberrors/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerInspectionsampleErrors = &fieldseekerInspectionsampleErrors{ ErrUniqueInspectionsamplePkey: &UniqueConstraintError{ schema: "fieldseeker", table: "inspectionsample", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "inspectionsample_pkey", }, } diff --git a/db/dberrors/fieldseeker.inspectionsampledetail.bob.go b/db/dberrors/fieldseeker.inspectionsampledetail.bob.go index b048c104..ca3cbc6b 100644 --- a/db/dberrors/fieldseeker.inspectionsampledetail.bob.go +++ b/db/dberrors/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerInspectionsampledetailErrors = &fieldseekerInspectionsampledetail ErrUniqueInspectionsampledetailPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "inspectionsampledetail", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "inspectionsampledetail_pkey", }, } diff --git a/db/dberrors/fieldseeker.linelocation.bob.go b/db/dberrors/fieldseeker.linelocation.bob.go index c58921d6..a56317e0 100644 --- a/db/dberrors/fieldseeker.linelocation.bob.go +++ b/db/dberrors/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerLinelocationErrors = &fieldseekerLinelocationErrors{ ErrUniqueLinelocationPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "linelocation", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "linelocation_pkey", }, } diff --git a/db/dberrors/fieldseeker.locationtracking.bob.go b/db/dberrors/fieldseeker.locationtracking.bob.go index 6e0a0c79..5d78b877 100644 --- a/db/dberrors/fieldseeker.locationtracking.bob.go +++ b/db/dberrors/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerLocationtrackingErrors = &fieldseekerLocationtrackingErrors{ ErrUniqueLocationtrackingPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "locationtracking", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "locationtracking_pkey", }, } diff --git a/db/dberrors/fieldseeker.mosquitoinspection.bob.go b/db/dberrors/fieldseeker.mosquitoinspection.bob.go index bc0905a8..cbed889f 100644 --- a/db/dberrors/fieldseeker.mosquitoinspection.bob.go +++ b/db/dberrors/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerMosquitoinspectionErrors = &fieldseekerMosquitoinspectionErrors{ ErrUniqueMosquitoinspectionPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "mosquitoinspection", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "mosquitoinspection_pkey", }, } diff --git a/db/dberrors/fieldseeker.pointlocation.bob.go b/db/dberrors/fieldseeker.pointlocation.bob.go index 842a8bba..d0538eb7 100644 --- a/db/dberrors/fieldseeker.pointlocation.bob.go +++ b/db/dberrors/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerPointlocationErrors = &fieldseekerPointlocationErrors{ ErrUniquePointlocationPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "pointlocation", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "pointlocation_pkey", }, } diff --git a/db/dberrors/fieldseeker.polygonlocation.bob.go b/db/dberrors/fieldseeker.polygonlocation.bob.go index 6fe7c8d5..42e57b61 100644 --- a/db/dberrors/fieldseeker.polygonlocation.bob.go +++ b/db/dberrors/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerPolygonlocationErrors = &fieldseekerPolygonlocationErrors{ ErrUniquePolygonlocationPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "polygonlocation", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "polygonlocation_pkey", }, } diff --git a/db/dberrors/fieldseeker.pool.bob.go b/db/dberrors/fieldseeker.pool.bob.go index a3fe5e55..b318a796 100644 --- a/db/dberrors/fieldseeker.pool.bob.go +++ b/db/dberrors/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerPoolErrors = &fieldseekerPoolErrors{ ErrUniquePoolPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "pool", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "pool_pkey", }, } diff --git a/db/dberrors/fieldseeker.pooldetail.bob.go b/db/dberrors/fieldseeker.pooldetail.bob.go index 317460b5..2861b4c4 100644 --- a/db/dberrors/fieldseeker.pooldetail.bob.go +++ b/db/dberrors/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerPooldetailErrors = &fieldseekerPooldetailErrors{ ErrUniquePooldetailPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "pooldetail", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "pooldetail_pkey", }, } diff --git a/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go b/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go index 3a914a33..4120f147 100644 --- a/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerProposedtreatmentareaErrors = &fieldseekerProposedtreatmentareaEr ErrUniqueProposedtreatmentareaPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "proposedtreatmentarea", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "proposedtreatmentarea_pkey", }, } diff --git a/db/dberrors/fieldseeker.qamosquitoinspection.bob.go b/db/dberrors/fieldseeker.qamosquitoinspection.bob.go index fa3cd5d3..c0c62fbe 100644 --- a/db/dberrors/fieldseeker.qamosquitoinspection.bob.go +++ b/db/dberrors/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerQamosquitoinspectionErrors = &fieldseekerQamosquitoinspectionErro ErrUniqueQamosquitoinspectionPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "qamosquitoinspection", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "qamosquitoinspection_pkey", }, } diff --git a/db/dberrors/fieldseeker.rodentlocation.bob.go b/db/dberrors/fieldseeker.rodentlocation.bob.go index 47d2500e..e48264a1 100644 --- a/db/dberrors/fieldseeker.rodentlocation.bob.go +++ b/db/dberrors/fieldseeker.rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerRodentlocationErrors = &fieldseekerRodentlocationErrors{ ErrUniqueRodentlocationPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "rodentlocation", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "rodentlocation_pkey", }, } diff --git a/db/dberrors/fieldseeker.samplecollection.bob.go b/db/dberrors/fieldseeker.samplecollection.bob.go index d243fe94..f6ec4c2f 100644 --- a/db/dberrors/fieldseeker.samplecollection.bob.go +++ b/db/dberrors/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerSamplecollectionErrors = &fieldseekerSamplecollectionErrors{ ErrUniqueSamplecollectionPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "samplecollection", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "samplecollection_pkey", }, } diff --git a/db/dberrors/fieldseeker.samplelocation.bob.go b/db/dberrors/fieldseeker.samplelocation.bob.go index 918b5b60..3d4c5cd0 100644 --- a/db/dberrors/fieldseeker.samplelocation.bob.go +++ b/db/dberrors/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerSamplelocationErrors = &fieldseekerSamplelocationErrors{ ErrUniqueSamplelocationPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "samplelocation", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "samplelocation_pkey", }, } diff --git a/db/dberrors/fieldseeker.servicerequest.bob.go b/db/dberrors/fieldseeker.servicerequest.bob.go index 4592c068..4c3627ee 100644 --- a/db/dberrors/fieldseeker.servicerequest.bob.go +++ b/db/dberrors/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerServicerequestErrors = &fieldseekerServicerequestErrors{ ErrUniqueServicerequestPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "servicerequest", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "servicerequest_pkey", }, } diff --git a/db/dberrors/fieldseeker.speciesabundance.bob.go b/db/dberrors/fieldseeker.speciesabundance.bob.go index 20a29f74..105fce55 100644 --- a/db/dberrors/fieldseeker.speciesabundance.bob.go +++ b/db/dberrors/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerSpeciesabundanceErrors = &fieldseekerSpeciesabundanceErrors{ ErrUniqueSpeciesabundancePkey: &UniqueConstraintError{ schema: "fieldseeker", table: "speciesabundance", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "speciesabundance_pkey", }, } diff --git a/db/dberrors/fieldseeker.stormdrain.bob.go b/db/dberrors/fieldseeker.stormdrain.bob.go index ab28ff51..3da060d0 100644 --- a/db/dberrors/fieldseeker.stormdrain.bob.go +++ b/db/dberrors/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerStormdrainErrors = &fieldseekerStormdrainErrors{ ErrUniqueStormdrainPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "stormdrain", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "stormdrain_pkey", }, } diff --git a/db/dberrors/fieldseeker.timecard.bob.go b/db/dberrors/fieldseeker.timecard.bob.go index 2c0052f9..1fa8bfe6 100644 --- a/db/dberrors/fieldseeker.timecard.bob.go +++ b/db/dberrors/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerTimecardErrors = &fieldseekerTimecardErrors{ ErrUniqueTimecardPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "timecard", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "timecard_pkey", }, } diff --git a/db/dberrors/fieldseeker.trapdata.bob.go b/db/dberrors/fieldseeker.trapdata.bob.go index bf7710c9..223885b0 100644 --- a/db/dberrors/fieldseeker.trapdata.bob.go +++ b/db/dberrors/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerTrapdatumErrors = &fieldseekerTrapdatumErrors{ ErrUniqueTrapdataPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "trapdata", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "trapdata_pkey", }, } diff --git a/db/dberrors/fieldseeker.traplocation.bob.go b/db/dberrors/fieldseeker.traplocation.bob.go index 6b9ad066..bfa3de7c 100644 --- a/db/dberrors/fieldseeker.traplocation.bob.go +++ b/db/dberrors/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerTraplocationErrors = &fieldseekerTraplocationErrors{ ErrUniqueTraplocationPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "traplocation", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "traplocation_pkey", }, } diff --git a/db/dberrors/fieldseeker.treatment.bob.go b/db/dberrors/fieldseeker.treatment.bob.go index 0559b8ef..7a7604fa 100644 --- a/db/dberrors/fieldseeker.treatment.bob.go +++ b/db/dberrors/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerTreatmentErrors = &fieldseekerTreatmentErrors{ ErrUniqueTreatmentPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "treatment", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "treatment_pkey", }, } diff --git a/db/dberrors/fieldseeker.treatmentarea.bob.go b/db/dberrors/fieldseeker.treatmentarea.bob.go index 031dd88e..4cf22e26 100644 --- a/db/dberrors/fieldseeker.treatmentarea.bob.go +++ b/db/dberrors/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerTreatmentareaErrors = &fieldseekerTreatmentareaErrors{ ErrUniqueTreatmentareaPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "treatmentarea", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "treatmentarea_pkey", }, } diff --git a/db/dberrors/fieldseeker.zones.bob.go b/db/dberrors/fieldseeker.zones.bob.go index 7ae04980..6172abc2 100644 --- a/db/dberrors/fieldseeker.zones.bob.go +++ b/db/dberrors/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerZoneErrors = &fieldseekerZoneErrors{ ErrUniqueZonesPkey: &UniqueConstraintError{ schema: "fieldseeker", table: "zones", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "zones_pkey", }, } diff --git a/db/dberrors/fieldseeker.zones2.bob.go b/db/dberrors/fieldseeker.zones2.bob.go index c4d7bdb3..763d302b 100644 --- a/db/dberrors/fieldseeker.zones2.bob.go +++ b/db/dberrors/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors @@ -7,7 +7,7 @@ var FieldseekerZones2Errors = &fieldseekerZones2Errors{ ErrUniqueZones2Pkey: &UniqueConstraintError{ schema: "fieldseeker", table: "zones2", - columns: []string{"objectid"}, + columns: []string{"objectid", "version"}, s: "zones2_pkey", }, } diff --git a/db/dberrors/fieldseeker_sync.bob.go b/db/dberrors/fieldseeker_sync.bob.go index 8128df32..a05c8131 100644 --- a/db/dberrors/fieldseeker_sync.bob.go +++ b/db/dberrors/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_containerrelate.bob.go b/db/dberrors/fs_containerrelate.bob.go index 7806cbab..02df3d36 100644 --- a/db/dberrors/fs_containerrelate.bob.go +++ b/db/dberrors/fs_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_fieldscoutinglog.bob.go b/db/dberrors/fs_fieldscoutinglog.bob.go index 01b30548..d49e4ce3 100644 --- a/db/dberrors/fs_fieldscoutinglog.bob.go +++ b/db/dberrors/fs_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_habitatrelate.bob.go b/db/dberrors/fs_habitatrelate.bob.go index bcfc8df9..6ed93b93 100644 --- a/db/dberrors/fs_habitatrelate.bob.go +++ b/db/dberrors/fs_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_inspectionsample.bob.go b/db/dberrors/fs_inspectionsample.bob.go index ccdb7b15..fb79b576 100644 --- a/db/dberrors/fs_inspectionsample.bob.go +++ b/db/dberrors/fs_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_inspectionsampledetail.bob.go b/db/dberrors/fs_inspectionsampledetail.bob.go index a8ce43c2..e06faf5a 100644 --- a/db/dberrors/fs_inspectionsampledetail.bob.go +++ b/db/dberrors/fs_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_linelocation.bob.go b/db/dberrors/fs_linelocation.bob.go index 2e04536f..437425e7 100644 --- a/db/dberrors/fs_linelocation.bob.go +++ b/db/dberrors/fs_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_locationtracking.bob.go b/db/dberrors/fs_locationtracking.bob.go index b8d6ac8f..dda54281 100644 --- a/db/dberrors/fs_locationtracking.bob.go +++ b/db/dberrors/fs_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_mosquitoinspection.bob.go b/db/dberrors/fs_mosquitoinspection.bob.go index 6783adda..d8c4e4c5 100644 --- a/db/dberrors/fs_mosquitoinspection.bob.go +++ b/db/dberrors/fs_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_pointlocation.bob.go b/db/dberrors/fs_pointlocation.bob.go index 50cc24ff..6164a0ba 100644 --- a/db/dberrors/fs_pointlocation.bob.go +++ b/db/dberrors/fs_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_polygonlocation.bob.go b/db/dberrors/fs_polygonlocation.bob.go index 0b2a146e..e7ed3c1b 100644 --- a/db/dberrors/fs_polygonlocation.bob.go +++ b/db/dberrors/fs_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_pool.bob.go b/db/dberrors/fs_pool.bob.go index 54af0b20..5cdc196e 100644 --- a/db/dberrors/fs_pool.bob.go +++ b/db/dberrors/fs_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_pooldetail.bob.go b/db/dberrors/fs_pooldetail.bob.go index 0e1e3815..b0f20fda 100644 --- a/db/dberrors/fs_pooldetail.bob.go +++ b/db/dberrors/fs_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_proposedtreatmentarea.bob.go b/db/dberrors/fs_proposedtreatmentarea.bob.go index 5a873647..ff5c9f7e 100644 --- a/db/dberrors/fs_proposedtreatmentarea.bob.go +++ b/db/dberrors/fs_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_qamosquitoinspection.bob.go b/db/dberrors/fs_qamosquitoinspection.bob.go index 4d43ee97..e682d923 100644 --- a/db/dberrors/fs_qamosquitoinspection.bob.go +++ b/db/dberrors/fs_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_rodentlocation.bob.go b/db/dberrors/fs_rodentlocation.bob.go index e350fae2..4fd0c7d9 100644 --- a/db/dberrors/fs_rodentlocation.bob.go +++ b/db/dberrors/fs_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_samplecollection.bob.go b/db/dberrors/fs_samplecollection.bob.go index 0af415bf..a2e4585d 100644 --- a/db/dberrors/fs_samplecollection.bob.go +++ b/db/dberrors/fs_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_samplelocation.bob.go b/db/dberrors/fs_samplelocation.bob.go index 5e072bd9..ccd58bfe 100644 --- a/db/dberrors/fs_samplelocation.bob.go +++ b/db/dberrors/fs_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_servicerequest.bob.go b/db/dberrors/fs_servicerequest.bob.go index 1c7e8194..29fb740a 100644 --- a/db/dberrors/fs_servicerequest.bob.go +++ b/db/dberrors/fs_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_speciesabundance.bob.go b/db/dberrors/fs_speciesabundance.bob.go index a24952ae..6417abfc 100644 --- a/db/dberrors/fs_speciesabundance.bob.go +++ b/db/dberrors/fs_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_stormdrain.bob.go b/db/dberrors/fs_stormdrain.bob.go index 233684b8..7de48ce6 100644 --- a/db/dberrors/fs_stormdrain.bob.go +++ b/db/dberrors/fs_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_timecard.bob.go b/db/dberrors/fs_timecard.bob.go index abfa0584..a9100887 100644 --- a/db/dberrors/fs_timecard.bob.go +++ b/db/dberrors/fs_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_trapdata.bob.go b/db/dberrors/fs_trapdata.bob.go index a1a2f938..964d3ac1 100644 --- a/db/dberrors/fs_trapdata.bob.go +++ b/db/dberrors/fs_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_traplocation.bob.go b/db/dberrors/fs_traplocation.bob.go index df2e110f..85551047 100644 --- a/db/dberrors/fs_traplocation.bob.go +++ b/db/dberrors/fs_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_treatment.bob.go b/db/dberrors/fs_treatment.bob.go index 5bbbf4d4..1683ef2f 100644 --- a/db/dberrors/fs_treatment.bob.go +++ b/db/dberrors/fs_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_treatmentarea.bob.go b/db/dberrors/fs_treatmentarea.bob.go index 8910b50c..c435bfa1 100644 --- a/db/dberrors/fs_treatmentarea.bob.go +++ b/db/dberrors/fs_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_zones.bob.go b/db/dberrors/fs_zones.bob.go index f6923d58..57ec5028 100644 --- a/db/dberrors/fs_zones.bob.go +++ b/db/dberrors/fs_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fs_zones2.bob.go b/db/dberrors/fs_zones2.bob.go index 1df17a14..64e9eb33 100644 --- a/db/dberrors/fs_zones2.bob.go +++ b/db/dberrors/fs_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/goose_db_version.bob.go b/db/dberrors/goose_db_version.bob.go index 867d0b85..0fdbe32c 100644 --- a/db/dberrors/goose_db_version.bob.go +++ b/db/dberrors/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/h3_aggregation.bob.go b/db/dberrors/h3_aggregation.bob.go index 83a93779..2b930123 100644 --- a/db/dberrors/h3_aggregation.bob.go +++ b/db/dberrors/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/h3_aggregation.bob_test.go b/db/dberrors/h3_aggregation.bob_test.go index 0fb602d8..9aba7b1f 100644 --- a/db/dberrors/h3_aggregation.bob_test.go +++ b/db/dberrors/h3_aggregation.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_containerrelate.bob.go b/db/dberrors/history_containerrelate.bob.go index a0272455..5c848208 100644 --- a/db/dberrors/history_containerrelate.bob.go +++ b/db/dberrors/history_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_fieldscoutinglog.bob.go b/db/dberrors/history_fieldscoutinglog.bob.go index eb3af697..d25326a6 100644 --- a/db/dberrors/history_fieldscoutinglog.bob.go +++ b/db/dberrors/history_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_habitatrelate.bob.go b/db/dberrors/history_habitatrelate.bob.go index b2713d8b..6e0ecfa0 100644 --- a/db/dberrors/history_habitatrelate.bob.go +++ b/db/dberrors/history_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_inspectionsample.bob.go b/db/dberrors/history_inspectionsample.bob.go index b47c6e20..8f5c5c20 100644 --- a/db/dberrors/history_inspectionsample.bob.go +++ b/db/dberrors/history_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_inspectionsampledetail.bob.go b/db/dberrors/history_inspectionsampledetail.bob.go index 3ec3e8b9..70fe6a7d 100644 --- a/db/dberrors/history_inspectionsampledetail.bob.go +++ b/db/dberrors/history_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_linelocation.bob.go b/db/dberrors/history_linelocation.bob.go index 4fc1df93..b236f231 100644 --- a/db/dberrors/history_linelocation.bob.go +++ b/db/dberrors/history_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_locationtracking.bob.go b/db/dberrors/history_locationtracking.bob.go index 0d8b455a..f5c9b242 100644 --- a/db/dberrors/history_locationtracking.bob.go +++ b/db/dberrors/history_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_mosquitoinspection.bob.go b/db/dberrors/history_mosquitoinspection.bob.go index 8a75c779..dd4d8ec2 100644 --- a/db/dberrors/history_mosquitoinspection.bob.go +++ b/db/dberrors/history_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_pointlocation.bob.go b/db/dberrors/history_pointlocation.bob.go index 4b6bc493..e71bef1d 100644 --- a/db/dberrors/history_pointlocation.bob.go +++ b/db/dberrors/history_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_polygonlocation.bob.go b/db/dberrors/history_polygonlocation.bob.go index 1d32153f..0e552eec 100644 --- a/db/dberrors/history_polygonlocation.bob.go +++ b/db/dberrors/history_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_pool.bob.go b/db/dberrors/history_pool.bob.go index 981f805f..7e0c7b0b 100644 --- a/db/dberrors/history_pool.bob.go +++ b/db/dberrors/history_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_pooldetail.bob.go b/db/dberrors/history_pooldetail.bob.go index f6142e51..be5a8cad 100644 --- a/db/dberrors/history_pooldetail.bob.go +++ b/db/dberrors/history_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_proposedtreatmentarea.bob.go b/db/dberrors/history_proposedtreatmentarea.bob.go index 85a9bffd..c3602129 100644 --- a/db/dberrors/history_proposedtreatmentarea.bob.go +++ b/db/dberrors/history_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_qamosquitoinspection.bob.go b/db/dberrors/history_qamosquitoinspection.bob.go index e47ab6cd..3b9ee2c3 100644 --- a/db/dberrors/history_qamosquitoinspection.bob.go +++ b/db/dberrors/history_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_rodentlocation.bob.go b/db/dberrors/history_rodentlocation.bob.go index 54871347..89e97c54 100644 --- a/db/dberrors/history_rodentlocation.bob.go +++ b/db/dberrors/history_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_samplecollection.bob.go b/db/dberrors/history_samplecollection.bob.go index 6a2eb921..23cc5309 100644 --- a/db/dberrors/history_samplecollection.bob.go +++ b/db/dberrors/history_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_samplelocation.bob.go b/db/dberrors/history_samplelocation.bob.go index 2414369f..67ce597e 100644 --- a/db/dberrors/history_samplelocation.bob.go +++ b/db/dberrors/history_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_servicerequest.bob.go b/db/dberrors/history_servicerequest.bob.go index acc99957..6cf9a49a 100644 --- a/db/dberrors/history_servicerequest.bob.go +++ b/db/dberrors/history_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_speciesabundance.bob.go b/db/dberrors/history_speciesabundance.bob.go index b76156b7..96387e55 100644 --- a/db/dberrors/history_speciesabundance.bob.go +++ b/db/dberrors/history_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_stormdrain.bob.go b/db/dberrors/history_stormdrain.bob.go index c118d2d3..9af00a32 100644 --- a/db/dberrors/history_stormdrain.bob.go +++ b/db/dberrors/history_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_timecard.bob.go b/db/dberrors/history_timecard.bob.go index b57a8b37..fe4adc89 100644 --- a/db/dberrors/history_timecard.bob.go +++ b/db/dberrors/history_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_trapdata.bob.go b/db/dberrors/history_trapdata.bob.go index 53e1e0c9..2ce0ef5b 100644 --- a/db/dberrors/history_trapdata.bob.go +++ b/db/dberrors/history_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_traplocation.bob.go b/db/dberrors/history_traplocation.bob.go index bcb56b5a..db0c8c81 100644 --- a/db/dberrors/history_traplocation.bob.go +++ b/db/dberrors/history_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_treatment.bob.go b/db/dberrors/history_treatment.bob.go index 23fcbf9a..b6c764c6 100644 --- a/db/dberrors/history_treatment.bob.go +++ b/db/dberrors/history_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_treatmentarea.bob.go b/db/dberrors/history_treatmentarea.bob.go index e38da3f2..227e50ab 100644 --- a/db/dberrors/history_treatmentarea.bob.go +++ b/db/dberrors/history_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_zones.bob.go b/db/dberrors/history_zones.bob.go index 8ca16c8e..318137fd 100644 --- a/db/dberrors/history_zones.bob.go +++ b/db/dberrors/history_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/history_zones2.bob.go b/db/dberrors/history_zones2.bob.go index 273e5777..6fddfe71 100644 --- a/db/dberrors/history_zones2.bob.go +++ b/db/dberrors/history_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/notification.bob.go b/db/dberrors/notification.bob.go index df71850b..c6271307 100644 --- a/db/dberrors/notification.bob.go +++ b/db/dberrors/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/oauth_token.bob.go b/db/dberrors/oauth_token.bob.go index 01d3a92c..62b458e4 100644 --- a/db/dberrors/oauth_token.bob.go +++ b/db/dberrors/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/organization.bob.go b/db/dberrors/organization.bob.go index 486a777c..2f7bc6b9 100644 --- a/db/dberrors/organization.bob.go +++ b/db/dberrors/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/sessions.bob.go b/db/dberrors/sessions.bob.go index 291a41b8..e7150f3a 100644 --- a/db/dberrors/sessions.bob.go +++ b/db/dberrors/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/spatial_ref_sys.bob.go b/db/dberrors/spatial_ref_sys.bob.go index b3f65a50..81a1157b 100644 --- a/db/dberrors/spatial_ref_sys.bob.go +++ b/db/dberrors/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/user_.bob.go b/db/dberrors/user_.bob.go index 1dc3f51f..70522a60 100644 --- a/db/dberrors/user_.bob.go +++ b/db/dberrors/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dbinfo/bob_types.bob.go b/db/dbinfo/bob_types.bob.go index c987ed5d..f1fec63d 100644 --- a/db/dbinfo/bob_types.bob.go +++ b/db/dbinfo/bob_types.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.aerialsprayline.bob.go b/db/dbinfo/fieldseeker.aerialsprayline.bob.go deleted file mode 100644 index 183bafd0..00000000 --- a/db/dbinfo/fieldseeker.aerialsprayline.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerAerialspraylines = Table[ - fieldseekerAerialspraylineColumns, - fieldseekerAerialspraylineIndexes, - fieldseekerAerialspraylineForeignKeys, - fieldseekerAerialspraylineUniques, - fieldseekerAerialspraylineChecks, -]{ - Schema: "fieldseeker", - Name: "aerialsprayline", - Columns: fieldseekerAerialspraylineColumns{}, - - Comment: "", -} - -type fieldseekerAerialspraylineColumns struct{} - -func (c fieldseekerAerialspraylineColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerAerialspraylineIndexes struct{} - -func (i fieldseekerAerialspraylineIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerAerialspraylineForeignKeys struct{} - -func (f fieldseekerAerialspraylineForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerAerialspraylineUniques struct{} - -func (u fieldseekerAerialspraylineUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerAerialspraylineChecks struct{} - -func (c fieldseekerAerialspraylineChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.aerialspraysession.bob.go b/db/dbinfo/fieldseeker.aerialspraysession.bob.go deleted file mode 100644 index 0a019864..00000000 --- a/db/dbinfo/fieldseeker.aerialspraysession.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerAerialspraysessions = Table[ - fieldseekerAerialspraysessionColumns, - fieldseekerAerialspraysessionIndexes, - fieldseekerAerialspraysessionForeignKeys, - fieldseekerAerialspraysessionUniques, - fieldseekerAerialspraysessionChecks, -]{ - Schema: "fieldseeker", - Name: "aerialspraysession", - Columns: fieldseekerAerialspraysessionColumns{}, - - Comment: "", -} - -type fieldseekerAerialspraysessionColumns struct{} - -func (c fieldseekerAerialspraysessionColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerAerialspraysessionIndexes struct{} - -func (i fieldseekerAerialspraysessionIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerAerialspraysessionForeignKeys struct{} - -func (f fieldseekerAerialspraysessionForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerAerialspraysessionUniques struct{} - -func (u fieldseekerAerialspraysessionUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerAerialspraysessionChecks struct{} - -func (c fieldseekerAerialspraysessionChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.barrierspray.bob.go b/db/dbinfo/fieldseeker.barrierspray.bob.go deleted file mode 100644 index eb704b8a..00000000 --- a/db/dbinfo/fieldseeker.barrierspray.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerBarriersprays = Table[ - fieldseekerBarriersprayColumns, - fieldseekerBarriersprayIndexes, - fieldseekerBarriersprayForeignKeys, - fieldseekerBarriersprayUniques, - fieldseekerBarriersprayChecks, -]{ - Schema: "fieldseeker", - Name: "barrierspray", - Columns: fieldseekerBarriersprayColumns{}, - - Comment: "", -} - -type fieldseekerBarriersprayColumns struct{} - -func (c fieldseekerBarriersprayColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerBarriersprayIndexes struct{} - -func (i fieldseekerBarriersprayIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerBarriersprayForeignKeys struct{} - -func (f fieldseekerBarriersprayForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerBarriersprayUniques struct{} - -func (u fieldseekerBarriersprayUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerBarriersprayChecks struct{} - -func (c fieldseekerBarriersprayChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.barriersprayroute.bob.go b/db/dbinfo/fieldseeker.barriersprayroute.bob.go deleted file mode 100644 index 66244508..00000000 --- a/db/dbinfo/fieldseeker.barriersprayroute.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerBarriersprayroutes = Table[ - fieldseekerBarriersprayrouteColumns, - fieldseekerBarriersprayrouteIndexes, - fieldseekerBarriersprayrouteForeignKeys, - fieldseekerBarriersprayrouteUniques, - fieldseekerBarriersprayrouteChecks, -]{ - Schema: "fieldseeker", - Name: "barriersprayroute", - Columns: fieldseekerBarriersprayrouteColumns{}, - - Comment: "", -} - -type fieldseekerBarriersprayrouteColumns struct{} - -func (c fieldseekerBarriersprayrouteColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerBarriersprayrouteIndexes struct{} - -func (i fieldseekerBarriersprayrouteIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerBarriersprayrouteForeignKeys struct{} - -func (f fieldseekerBarriersprayrouteForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerBarriersprayrouteUniques struct{} - -func (u fieldseekerBarriersprayrouteUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerBarriersprayrouteChecks struct{} - -func (c fieldseekerBarriersprayrouteChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.containerrelate.bob.go b/db/dbinfo/fieldseeker.containerrelate.bob.go index 29c72c27..1a92b00e 100644 --- a/db/dbinfo/fieldseeker.containerrelate.bob.go +++ b/db/dbinfo/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -141,6 +141,15 @@ var FieldseekerContainerrelates = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerContainerrelateIndexes{ ContainerrelatePkey: index{ @@ -152,10 +161,15 @@ var FieldseekerContainerrelates = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -163,7 +177,7 @@ var FieldseekerContainerrelates = Table[ }, PrimaryKey: &constraint{ Name: "containerrelate_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -185,11 +199,12 @@ type fieldseekerContainerrelateColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerContainerrelateColumns) AsSlice() []column { return []column{ - c.Objectid, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Inspsampleid, c.Mosquitoinspid, c.Treatmentid, c.Containertype, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Inspsampleid, c.Mosquitoinspid, c.Treatmentid, c.Containertype, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go b/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go index a41d78f8..de12e074 100644 --- a/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go +++ b/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -114,6 +114,15 @@ var FieldseekerFieldscoutinglogs = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerFieldscoutinglogIndexes{ FieldscoutinglogPkey: index{ @@ -125,10 +134,15 @@ var FieldseekerFieldscoutinglogs = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -136,7 +150,7 @@ var FieldseekerFieldscoutinglogs = Table[ }, PrimaryKey: &constraint{ Name: "fieldscoutinglog_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -155,11 +169,12 @@ type fieldseekerFieldscoutinglogColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerFieldscoutinglogColumns) AsSlice() []column { return []column{ - c.Objectid, c.Status, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.Status, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.habitatrelate.bob.go b/db/dbinfo/fieldseeker.habitatrelate.bob.go index 4d95e3ec..da5fff58 100644 --- a/db/dbinfo/fieldseeker.habitatrelate.bob.go +++ b/db/dbinfo/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -123,6 +123,15 @@ var FieldseekerHabitatrelates = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerHabitatrelateIndexes{ HabitatrelatePkey: index{ @@ -134,10 +143,15 @@ var FieldseekerHabitatrelates = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -145,7 +159,7 @@ var FieldseekerHabitatrelates = Table[ }, PrimaryKey: &constraint{ Name: "habitatrelate_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -165,11 +179,12 @@ type fieldseekerHabitatrelateColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerHabitatrelateColumns) AsSlice() []column { return []column{ - c.Objectid, c.ForeignID, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Habitattype, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.ForeignID, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Habitattype, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.inspectionsample.bob.go b/db/dbinfo/fieldseeker.inspectionsample.bob.go index 0e8e2246..3d3f98fd 100644 --- a/db/dbinfo/fieldseeker.inspectionsample.bob.go +++ b/db/dbinfo/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -141,6 +141,15 @@ var FieldseekerInspectionsamples = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerInspectionsampleIndexes{ InspectionsamplePkey: index{ @@ -152,10 +161,15 @@ var FieldseekerInspectionsamples = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -163,7 +177,7 @@ var FieldseekerInspectionsamples = Table[ }, PrimaryKey: &constraint{ Name: "inspectionsample_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -185,11 +199,12 @@ type fieldseekerInspectionsampleColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerInspectionsampleColumns) AsSlice() []column { return []column{ - c.Objectid, c.InspID, c.Sampleid, c.Processed, c.Idbytech, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.InspID, c.Sampleid, c.Processed, c.Idbytech, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go b/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go index 4001e2c4..1cdef1a9 100644 --- a/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go +++ b/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -240,6 +240,15 @@ var FieldseekerInspectionsampledetails = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerInspectionsampledetailIndexes{ InspectionsampledetailPkey: index{ @@ -251,10 +260,15 @@ var FieldseekerInspectionsampledetails = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -262,7 +276,7 @@ var FieldseekerInspectionsampledetails = Table[ }, PrimaryKey: &constraint{ Name: "inspectionsampledetail_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -295,11 +309,12 @@ type fieldseekerInspectionsampledetailColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerInspectionsampledetailColumns) AsSlice() []column { return []column{ - c.Objectid, c.InspsampleID, c.Fieldspecies, c.Flarvcount, c.Fpupcount, c.Feggcount, c.Flstages, c.Fdomstage, c.Fadultact, c.Labspecies, c.Llarvcount, c.Lpupcount, c.Leggcount, c.Ldomstage, c.Comments, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Processed, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.InspsampleID, c.Fieldspecies, c.Flarvcount, c.Fpupcount, c.Feggcount, c.Flstages, c.Fdomstage, c.Fadultact, c.Labspecies, c.Llarvcount, c.Lpupcount, c.Leggcount, c.Ldomstage, c.Comments, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Processed, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.landingcount.bob.go b/db/dbinfo/fieldseeker.landingcount.bob.go deleted file mode 100644 index 49f70d17..00000000 --- a/db/dbinfo/fieldseeker.landingcount.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerLandingcounts = Table[ - fieldseekerLandingcountColumns, - fieldseekerLandingcountIndexes, - fieldseekerLandingcountForeignKeys, - fieldseekerLandingcountUniques, - fieldseekerLandingcountChecks, -]{ - Schema: "fieldseeker", - Name: "landingcount", - Columns: fieldseekerLandingcountColumns{}, - - Comment: "", -} - -type fieldseekerLandingcountColumns struct{} - -func (c fieldseekerLandingcountColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerLandingcountIndexes struct{} - -func (i fieldseekerLandingcountIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerLandingcountForeignKeys struct{} - -func (f fieldseekerLandingcountForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerLandingcountUniques struct{} - -func (u fieldseekerLandingcountUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerLandingcountChecks struct{} - -func (c fieldseekerLandingcountChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.landingcountlocation.bob.go b/db/dbinfo/fieldseeker.landingcountlocation.bob.go deleted file mode 100644 index 9c7a0e17..00000000 --- a/db/dbinfo/fieldseeker.landingcountlocation.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerLandingcountlocations = Table[ - fieldseekerLandingcountlocationColumns, - fieldseekerLandingcountlocationIndexes, - fieldseekerLandingcountlocationForeignKeys, - fieldseekerLandingcountlocationUniques, - fieldseekerLandingcountlocationChecks, -]{ - Schema: "fieldseeker", - Name: "landingcountlocation", - Columns: fieldseekerLandingcountlocationColumns{}, - - Comment: "", -} - -type fieldseekerLandingcountlocationColumns struct{} - -func (c fieldseekerLandingcountlocationColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerLandingcountlocationIndexes struct{} - -func (i fieldseekerLandingcountlocationIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerLandingcountlocationForeignKeys struct{} - -func (f fieldseekerLandingcountlocationForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerLandingcountlocationUniques struct{} - -func (u fieldseekerLandingcountlocationUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerLandingcountlocationChecks struct{} - -func (c fieldseekerLandingcountlocationChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.linelocation.bob.go b/db/dbinfo/fieldseeker.linelocation.bob.go index f78cbbfc..5e830622 100644 --- a/db/dbinfo/fieldseeker.linelocation.bob.go +++ b/db/dbinfo/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -447,6 +447,15 @@ var FieldseekerLinelocations = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerLinelocationIndexes{ LinelocationPkey: index{ @@ -458,10 +467,15 @@ var FieldseekerLinelocations = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -469,7 +483,7 @@ var FieldseekerLinelocations = Table[ }, PrimaryKey: &constraint{ Name: "linelocation_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -525,11 +539,12 @@ type fieldseekerLinelocationColumns struct { Editor column Jurisdiction column ShapeLength column + Version column } func (c fieldseekerLinelocationColumns) AsSlice() []column { return []column{ - c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Acres, c.Nextactiondatescheduled, c.Larvinspectinterval, c.LengthFT, c.WidthFT, c.Zone2, c.Locationnumber, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Lastinspectdate, c.Lastinspectbreeding, c.Lastinspectavglarvae, c.Lastinspectavgpupae, c.Lastinspectlstages, c.Lastinspectactiontaken, c.Lastinspectfieldspecies, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Hectares, c.Lastinspectactivity, c.Lasttreatactivity, c.LengthMeters, c.WidthMeters, c.Lastinspectconditions, c.Waterorigin, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.ShapeLength, + c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Acres, c.Nextactiondatescheduled, c.Larvinspectinterval, c.LengthFT, c.WidthFT, c.Zone2, c.Locationnumber, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Lastinspectdate, c.Lastinspectbreeding, c.Lastinspectavglarvae, c.Lastinspectavgpupae, c.Lastinspectlstages, c.Lastinspectactiontaken, c.Lastinspectfieldspecies, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Hectares, c.Lastinspectactivity, c.Lasttreatactivity, c.LengthMeters, c.WidthMeters, c.Lastinspectconditions, c.Waterorigin, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.ShapeLength, c.Version, } } diff --git a/db/dbinfo/fieldseeker.locationtracking.bob.go b/db/dbinfo/fieldseeker.locationtracking.bob.go index 908efc56..fbb1aea0 100644 --- a/db/dbinfo/fieldseeker.locationtracking.bob.go +++ b/db/dbinfo/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -123,6 +123,15 @@ var FieldseekerLocationtrackings = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerLocationtrackingIndexes{ LocationtrackingPkey: index{ @@ -134,10 +143,15 @@ var FieldseekerLocationtrackings = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -145,7 +159,7 @@ var FieldseekerLocationtrackings = Table[ }, PrimaryKey: &constraint{ Name: "locationtracking_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -165,11 +179,12 @@ type fieldseekerLocationtrackingColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerLocationtrackingColumns) AsSlice() []column { return []column{ - c.Objectid, c.Accuracy, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Globalid, c.Fieldtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.Accuracy, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Globalid, c.Fieldtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.mosquitoinspection.bob.go b/db/dbinfo/fieldseeker.mosquitoinspection.bob.go index fad15fa5..13bb1456 100644 --- a/db/dbinfo/fieldseeker.mosquitoinspection.bob.go +++ b/db/dbinfo/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -528,6 +528,15 @@ var FieldseekerMosquitoinspections = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerMosquitoinspectionIndexes{ MosquitoinspectionPkey: index{ @@ -539,10 +548,15 @@ var FieldseekerMosquitoinspections = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -550,7 +564,7 @@ var FieldseekerMosquitoinspections = Table[ }, PrimaryKey: &constraint{ Name: "mosquitoinspection_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -615,11 +629,12 @@ type fieldseekerMosquitoinspectionColumns struct { Vmcomments column Adminaction column Ptaid column + Version column } func (c fieldseekerMosquitoinspectionColumns) AsSlice() []column { return []column{ - c.Objectid, c.Numdips, c.Activity, c.Breeding, c.Totlarvae, c.Totpupae, c.Eggs, c.Posdips, c.Adultact, c.Lstages, c.Domstage, c.Actiontaken, c.Comments, c.Avetemp, c.Windspeed, c.Raingauge, c.Startdatetime, c.Enddatetime, c.Winddir, c.Avglarvae, c.Avgpupae, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Recordstatus, c.Zone2, c.Personalcontact, c.Tirecount, c.Cbcount, c.Containercount, c.Fieldspecies, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.Srid, c.Fieldtech, c.Larvaepresent, c.Pupaepresent, c.Sdid, c.Sitecond, c.Positivecontainercount, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.Visualmonitoring, c.Vmcomments, c.Adminaction, c.Ptaid, + c.Objectid, c.Numdips, c.Activity, c.Breeding, c.Totlarvae, c.Totpupae, c.Eggs, c.Posdips, c.Adultact, c.Lstages, c.Domstage, c.Actiontaken, c.Comments, c.Avetemp, c.Windspeed, c.Raingauge, c.Startdatetime, c.Enddatetime, c.Winddir, c.Avglarvae, c.Avgpupae, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Recordstatus, c.Zone2, c.Personalcontact, c.Tirecount, c.Cbcount, c.Containercount, c.Fieldspecies, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.Srid, c.Fieldtech, c.Larvaepresent, c.Pupaepresent, c.Sdid, c.Sitecond, c.Positivecontainercount, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.Visualmonitoring, c.Vmcomments, c.Adminaction, c.Ptaid, c.Version, } } diff --git a/db/dbinfo/fieldseeker.pointlocation.bob.go b/db/dbinfo/fieldseeker.pointlocation.bob.go index dbd6a41a..793707d2 100644 --- a/db/dbinfo/fieldseeker.pointlocation.bob.go +++ b/db/dbinfo/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -411,6 +411,15 @@ var FieldseekerPointlocations = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerPointlocationIndexes{ PointlocationPkey: index{ @@ -422,10 +431,15 @@ var FieldseekerPointlocations = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -433,7 +447,7 @@ var FieldseekerPointlocations = Table[ }, PrimaryKey: &constraint{ Name: "pointlocation_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -485,11 +499,12 @@ type fieldseekerPointlocationColumns struct { DeactivateReason column Scalarpriority column Sourcestatus column + Version column } func (c fieldseekerPointlocationColumns) AsSlice() []column { return []column{ - c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Nextactiondatescheduled, c.Larvinspectinterval, c.Zone2, c.Locationnumber, c.Globalid, c.Stype, c.Lastinspectdate, c.Lastinspectbreeding, c.Lastinspectavglarvae, c.Lastinspectavgpupae, c.Lastinspectlstages, c.Lastinspectactiontaken, c.Lastinspectfieldspecies, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Lastinspectactivity, c.Lasttreatactivity, c.Lastinspectconditions, c.Waterorigin, c.X, c.Y, c.Assignedtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.DeactivateReason, c.Scalarpriority, c.Sourcestatus, + c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Nextactiondatescheduled, c.Larvinspectinterval, c.Zone2, c.Locationnumber, c.Globalid, c.Stype, c.Lastinspectdate, c.Lastinspectbreeding, c.Lastinspectavglarvae, c.Lastinspectavgpupae, c.Lastinspectlstages, c.Lastinspectactiontaken, c.Lastinspectfieldspecies, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Lastinspectactivity, c.Lasttreatactivity, c.Lastinspectconditions, c.Waterorigin, c.X, c.Y, c.Assignedtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.DeactivateReason, c.Scalarpriority, c.Sourcestatus, c.Version, } } diff --git a/db/dbinfo/fieldseeker.polygonlocation.bob.go b/db/dbinfo/fieldseeker.polygonlocation.bob.go index 20a63625..fb5ce2f7 100644 --- a/db/dbinfo/fieldseeker.polygonlocation.bob.go +++ b/db/dbinfo/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -393,6 +393,15 @@ var FieldseekerPolygonlocations = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerPolygonlocationIndexes{ PolygonlocationPkey: index{ @@ -404,10 +413,15 @@ var FieldseekerPolygonlocations = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -415,7 +429,7 @@ var FieldseekerPolygonlocations = Table[ }, PrimaryKey: &constraint{ Name: "polygonlocation_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -465,11 +479,12 @@ type fieldseekerPolygonlocationColumns struct { Jurisdiction column ShapeArea column ShapeLength column + Version column } func (c fieldseekerPolygonlocationColumns) AsSlice() []column { return []column{ - c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Acres, c.Nextactiondatescheduled, c.Larvinspectinterval, c.Zone2, c.Locationnumber, c.Globalid, c.Lastinspectdate, c.Lastinspectbreeding, c.Lastinspectavglarvae, c.Lastinspectavgpupae, c.Lastinspectlstages, c.Lastinspectactiontaken, c.Lastinspectfieldspecies, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Hectares, c.Lastinspectactivity, c.Lasttreatactivity, c.Lastinspectconditions, c.Waterorigin, c.Filter, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.ShapeArea, c.ShapeLength, + c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Acres, c.Nextactiondatescheduled, c.Larvinspectinterval, c.Zone2, c.Locationnumber, c.Globalid, c.Lastinspectdate, c.Lastinspectbreeding, c.Lastinspectavglarvae, c.Lastinspectavgpupae, c.Lastinspectlstages, c.Lastinspectactiontaken, c.Lastinspectfieldspecies, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Hectares, c.Lastinspectactivity, c.Lasttreatactivity, c.Lastinspectconditions, c.Waterorigin, c.Filter, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.ShapeArea, c.ShapeLength, c.Version, } } diff --git a/db/dbinfo/fieldseeker.pool.bob.go b/db/dbinfo/fieldseeker.pool.bob.go index c562e8bf..151d487e 100644 --- a/db/dbinfo/fieldseeker.pool.bob.go +++ b/db/dbinfo/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -267,6 +267,15 @@ var FieldseekerPools = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerPoolIndexes{ PoolPkey: index{ @@ -278,10 +287,15 @@ var FieldseekerPools = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -289,7 +303,7 @@ var FieldseekerPools = Table[ }, PrimaryKey: &constraint{ Name: "pool_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -325,11 +339,12 @@ type fieldseekerPoolColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerPoolColumns) AsSlice() []column { return []column{ - c.Objectid, c.TrapdataID, c.Datesent, c.Survtech, c.Datetested, c.Testtech, c.Comments, c.Sampleid, c.Processed, c.LabID, c.Testmethod, c.Diseasetested, c.Diseasepos, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Lab, c.Poolyear, c.Gatewaysync, c.Vectorsurvcollectionid, c.Vectorsurvpoolid, c.Vectorsurvtrapdataid, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.TrapdataID, c.Datesent, c.Survtech, c.Datetested, c.Testtech, c.Comments, c.Sampleid, c.Processed, c.LabID, c.Testmethod, c.Diseasetested, c.Diseasepos, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Lab, c.Poolyear, c.Gatewaysync, c.Vectorsurvcollectionid, c.Vectorsurvpoolid, c.Vectorsurvtrapdataid, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.poolbuffer.bob.go b/db/dbinfo/fieldseeker.poolbuffer.bob.go deleted file mode 100644 index 2cde8886..00000000 --- a/db/dbinfo/fieldseeker.poolbuffer.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerPoolbuffers = Table[ - fieldseekerPoolbufferColumns, - fieldseekerPoolbufferIndexes, - fieldseekerPoolbufferForeignKeys, - fieldseekerPoolbufferUniques, - fieldseekerPoolbufferChecks, -]{ - Schema: "fieldseeker", - Name: "poolbuffer", - Columns: fieldseekerPoolbufferColumns{}, - - Comment: "", -} - -type fieldseekerPoolbufferColumns struct{} - -func (c fieldseekerPoolbufferColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerPoolbufferIndexes struct{} - -func (i fieldseekerPoolbufferIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerPoolbufferForeignKeys struct{} - -func (f fieldseekerPoolbufferForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerPoolbufferUniques struct{} - -func (u fieldseekerPoolbufferUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerPoolbufferChecks struct{} - -func (c fieldseekerPoolbufferChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.pooldetail.bob.go b/db/dbinfo/fieldseeker.pooldetail.bob.go index af87223a..5438c502 100644 --- a/db/dbinfo/fieldseeker.pooldetail.bob.go +++ b/db/dbinfo/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -141,6 +141,15 @@ var FieldseekerPooldetails = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerPooldetailIndexes{ PooldetailPkey: index{ @@ -152,10 +161,15 @@ var FieldseekerPooldetails = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -163,7 +177,7 @@ var FieldseekerPooldetails = Table[ }, PrimaryKey: &constraint{ Name: "pooldetail_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -185,11 +199,12 @@ type fieldseekerPooldetailColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerPooldetailColumns) AsSlice() []column { return []column{ - c.Objectid, c.TrapdataID, c.PoolID, c.Species, c.Females, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.TrapdataID, c.PoolID, c.Species, c.Females, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go b/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go index ca97f867..02669c9f 100644 --- a/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -312,6 +312,15 @@ var FieldseekerProposedtreatmentareas = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerProposedtreatmentareaIndexes{ ProposedtreatmentareaPkey: index{ @@ -323,10 +332,15 @@ var FieldseekerProposedtreatmentareas = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -334,7 +348,7 @@ var FieldseekerProposedtreatmentareas = Table[ }, PrimaryKey: &constraint{ Name: "proposedtreatmentarea_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -375,11 +389,12 @@ type fieldseekerProposedtreatmentareaColumns struct { Targetspecies column ShapeArea column ShapeLength column + Version column } func (c fieldseekerProposedtreatmentareaColumns) AsSlice() []column { return []column{ - c.Objectid, c.Method, c.Comments, c.Zone, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Zone2, c.Completeddate, c.Completedby, c.Completed, c.Issprayroute, c.Name, c.Acres, c.Globalid, c.Exported, c.Targetproduct, c.Targetapprate, c.Hectares, c.Lasttreatactivity, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Priority, c.Duedate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Targetspecies, c.ShapeArea, c.ShapeLength, + c.Objectid, c.Method, c.Comments, c.Zone, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Zone2, c.Completeddate, c.Completedby, c.Completed, c.Issprayroute, c.Name, c.Acres, c.Globalid, c.Exported, c.Targetproduct, c.Targetapprate, c.Hectares, c.Lasttreatactivity, c.Lasttreatdate, c.Lasttreatproduct, c.Lasttreatqty, c.Lasttreatqtyunit, c.Priority, c.Duedate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Targetspecies, c.ShapeArea, c.ShapeLength, c.Version, } } diff --git a/db/dbinfo/fieldseeker.qalarvcount.bob.go b/db/dbinfo/fieldseeker.qalarvcount.bob.go deleted file mode 100644 index 889e2986..00000000 --- a/db/dbinfo/fieldseeker.qalarvcount.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerQalarvcounts = Table[ - fieldseekerQalarvcountColumns, - fieldseekerQalarvcountIndexes, - fieldseekerQalarvcountForeignKeys, - fieldseekerQalarvcountUniques, - fieldseekerQalarvcountChecks, -]{ - Schema: "fieldseeker", - Name: "qalarvcount", - Columns: fieldseekerQalarvcountColumns{}, - - Comment: "", -} - -type fieldseekerQalarvcountColumns struct{} - -func (c fieldseekerQalarvcountColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerQalarvcountIndexes struct{} - -func (i fieldseekerQalarvcountIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerQalarvcountForeignKeys struct{} - -func (f fieldseekerQalarvcountForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerQalarvcountUniques struct{} - -func (u fieldseekerQalarvcountUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerQalarvcountChecks struct{} - -func (c fieldseekerQalarvcountChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go b/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go index 030de2d2..310a1e52 100644 --- a/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go +++ b/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -573,6 +573,15 @@ var FieldseekerQamosquitoinspections = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerQamosquitoinspectionIndexes{ QamosquitoinspectionPkey: index{ @@ -584,10 +593,15 @@ var FieldseekerQamosquitoinspections = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -595,7 +609,7 @@ var FieldseekerQamosquitoinspections = Table[ }, PrimaryKey: &constraint{ Name: "qamosquitoinspection_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -665,11 +679,12 @@ type fieldseekerQamosquitoinspectionColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerQamosquitoinspectionColumns) AsSlice() []column { return []column{ - c.Objectid, c.Posdips, c.Actiontaken, c.Comments, c.Avetemp, c.Windspeed, c.Raingauge, c.Globalid, c.Startdatetime, c.Enddatetime, c.Winddir, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Recordstatus, c.Zone2, c.LR, c.Negdips, c.Totalacres, c.Acresbreeding, c.Fish, c.Sitetype, c.Breedingpotential, c.Movingwater, c.Nowaterever, c.Mosquitohabitat, c.Habvalue1, c.Habvalue1percent, c.Habvalue2, c.Habvalue2percent, c.Potential, c.Larvaepresent, c.Larvaeinsidetreatedarea, c.Larvaeoutsidetreatedarea, c.Larvaereason, c.Aquaticorganisms, c.Vegetation, c.Sourcereduction, c.Waterpresent, c.Watermovement1, c.Watermovement1percent, c.Watermovement2, c.Watermovement2percent, c.Soilconditions, c.Waterduration, c.Watersource, c.Waterconditions, c.Adultactivity, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Fieldtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.Posdips, c.Actiontaken, c.Comments, c.Avetemp, c.Windspeed, c.Raingauge, c.Globalid, c.Startdatetime, c.Enddatetime, c.Winddir, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Recordstatus, c.Zone2, c.LR, c.Negdips, c.Totalacres, c.Acresbreeding, c.Fish, c.Sitetype, c.Breedingpotential, c.Movingwater, c.Nowaterever, c.Mosquitohabitat, c.Habvalue1, c.Habvalue1percent, c.Habvalue2, c.Habvalue2percent, c.Potential, c.Larvaepresent, c.Larvaeinsidetreatedarea, c.Larvaeoutsidetreatedarea, c.Larvaereason, c.Aquaticorganisms, c.Vegetation, c.Sourcereduction, c.Waterpresent, c.Watermovement1, c.Watermovement1percent, c.Watermovement2, c.Watermovement2percent, c.Soilconditions, c.Waterduration, c.Watersource, c.Waterconditions, c.Adultactivity, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Fieldtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.qaproductobservation.bob.go b/db/dbinfo/fieldseeker.qaproductobservation.bob.go deleted file mode 100644 index 840b6ba0..00000000 --- a/db/dbinfo/fieldseeker.qaproductobservation.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerQaproductobservations = Table[ - fieldseekerQaproductobservationColumns, - fieldseekerQaproductobservationIndexes, - fieldseekerQaproductobservationForeignKeys, - fieldseekerQaproductobservationUniques, - fieldseekerQaproductobservationChecks, -]{ - Schema: "fieldseeker", - Name: "qaproductobservation", - Columns: fieldseekerQaproductobservationColumns{}, - - Comment: "", -} - -type fieldseekerQaproductobservationColumns struct{} - -func (c fieldseekerQaproductobservationColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerQaproductobservationIndexes struct{} - -func (i fieldseekerQaproductobservationIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerQaproductobservationForeignKeys struct{} - -func (f fieldseekerQaproductobservationForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerQaproductobservationUniques struct{} - -func (u fieldseekerQaproductobservationUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerQaproductobservationChecks struct{} - -func (c fieldseekerQaproductobservationChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.restrictedarea.bob.go b/db/dbinfo/fieldseeker.restrictedarea.bob.go deleted file mode 100644 index d349a586..00000000 --- a/db/dbinfo/fieldseeker.restrictedarea.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerRestrictedareas = Table[ - fieldseekerRestrictedareaColumns, - fieldseekerRestrictedareaIndexes, - fieldseekerRestrictedareaForeignKeys, - fieldseekerRestrictedareaUniques, - fieldseekerRestrictedareaChecks, -]{ - Schema: "fieldseeker", - Name: "restrictedarea", - Columns: fieldseekerRestrictedareaColumns{}, - - Comment: "", -} - -type fieldseekerRestrictedareaColumns struct{} - -func (c fieldseekerRestrictedareaColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerRestrictedareaIndexes struct{} - -func (i fieldseekerRestrictedareaIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerRestrictedareaForeignKeys struct{} - -func (f fieldseekerRestrictedareaForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerRestrictedareaUniques struct{} - -func (u fieldseekerRestrictedareaUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerRestrictedareaChecks struct{} - -func (c fieldseekerRestrictedareaChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.rodentinspection.bob.go b/db/dbinfo/fieldseeker.rodentinspection.bob.go deleted file mode 100644 index 4dd91691..00000000 --- a/db/dbinfo/fieldseeker.rodentinspection.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerRodentinspections = Table[ - fieldseekerRodentinspectionColumns, - fieldseekerRodentinspectionIndexes, - fieldseekerRodentinspectionForeignKeys, - fieldseekerRodentinspectionUniques, - fieldseekerRodentinspectionChecks, -]{ - Schema: "fieldseeker", - Name: "rodentinspection", - Columns: fieldseekerRodentinspectionColumns{}, - - Comment: "", -} - -type fieldseekerRodentinspectionColumns struct{} - -func (c fieldseekerRodentinspectionColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerRodentinspectionIndexes struct{} - -func (i fieldseekerRodentinspectionIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerRodentinspectionForeignKeys struct{} - -func (f fieldseekerRodentinspectionForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerRodentinspectionUniques struct{} - -func (u fieldseekerRodentinspectionUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerRodentinspectionChecks struct{} - -func (c fieldseekerRodentinspectionChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.rodentlocation.bob.go b/db/dbinfo/fieldseeker.rodentlocation.bob.go index 1b4b3029..196997c1 100644 --- a/db/dbinfo/fieldseeker.rodentlocation.bob.go +++ b/db/dbinfo/fieldseeker.rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -15,15 +15,6 @@ var FieldseekerRodentlocations = Table[ Schema: "fieldseeker", Name: "rodentlocation", Columns: fieldseekerRodentlocationColumns{ - OrganizationID: column{ - Name: "organization_id", - DBType: "integer", - Default: "", - Comment: "", - Nullable: false, - Generated: false, - AutoIncr: false, - }, Objectid: column{ Name: "objectid", DBType: "bigint", @@ -294,6 +285,15 @@ var FieldseekerRodentlocations = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerRodentlocationIndexes{ RodentlocationPkey: index{ @@ -305,10 +305,15 @@ var FieldseekerRodentlocations = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -316,26 +321,14 @@ var FieldseekerRodentlocations = Table[ }, PrimaryKey: &constraint{ Name: "rodentlocation_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, - ForeignKeys: fieldseekerRodentlocationForeignKeys{ - FieldseekerRodentlocationRodentlocationOrganizationIDFkey: foreignKey{ - constraint: constraint{ - Name: "fieldseeker.rodentlocation.rodentlocation_organization_id_fkey", - Columns: []string{"organization_id"}, - Comment: "", - }, - ForeignTable: "organization", - ForeignColumns: []string{"id"}, - }, - }, Comment: "", } type fieldseekerRodentlocationColumns struct { - OrganizationID column Objectid column Locationname column Zone column @@ -366,11 +359,12 @@ type fieldseekerRodentlocationColumns struct { Editdate column Editor column Jurisdiction column + Version column } func (c fieldseekerRodentlocationColumns) AsSlice() []column { return []column{ - c.OrganizationID, c.Objectid, c.Locationname, c.Zone, c.Zone2, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Nextactiondatescheduled, c.Locationnumber, c.Lastinspectdate, c.Lastinspectspecies, c.Lastinspectaction, c.Lastinspectconditions, c.Lastinspectrodentevidence, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, + c.Objectid, c.Locationname, c.Zone, c.Zone2, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Symbology, c.Externalid, c.Nextactiondatescheduled, c.Locationnumber, c.Lastinspectdate, c.Lastinspectspecies, c.Lastinspectaction, c.Lastinspectconditions, c.Lastinspectrodentevidence, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Jurisdiction, c.Version, } } @@ -384,14 +378,10 @@ func (i fieldseekerRodentlocationIndexes) AsSlice() []index { } } -type fieldseekerRodentlocationForeignKeys struct { - FieldseekerRodentlocationRodentlocationOrganizationIDFkey foreignKey -} +type fieldseekerRodentlocationForeignKeys struct{} func (f fieldseekerRodentlocationForeignKeys) AsSlice() []foreignKey { - return []foreignKey{ - f.FieldseekerRodentlocationRodentlocationOrganizationIDFkey, - } + return []foreignKey{} } type fieldseekerRodentlocationUniques struct{} diff --git a/db/dbinfo/fieldseeker.samplecollection.bob.go b/db/dbinfo/fieldseeker.samplecollection.bob.go index 67de6dbc..89955c26 100644 --- a/db/dbinfo/fieldseeker.samplecollection.bob.go +++ b/db/dbinfo/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -429,6 +429,15 @@ var FieldseekerSamplecollections = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerSamplecollectionIndexes{ SamplecollectionPkey: index{ @@ -440,10 +449,15 @@ var FieldseekerSamplecollections = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -451,7 +465,7 @@ var FieldseekerSamplecollections = Table[ }, PrimaryKey: &constraint{ Name: "samplecollection_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -505,11 +519,12 @@ type fieldseekerSamplecollectionColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerSamplecollectionColumns) AsSlice() []column { return []column{ - c.Objectid, c.LocID, c.Startdatetime, c.Enddatetime, c.Sitecond, c.Sampleid, c.Survtech, c.Datesent, c.Datetested, c.Testtech, c.Comments, c.Processed, c.Sampletype, c.Samplecond, c.Species, c.Sex, c.Avetemp, c.Windspeed, c.Winddir, c.Raingauge, c.Activity, c.Testmethod, c.Diseasetested, c.Diseasepos, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Recordstatus, c.Zone2, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Lab, c.Fieldtech, c.Flockid, c.Samplecount, c.Chickenid, c.Gatewaysync, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.LocID, c.Startdatetime, c.Enddatetime, c.Sitecond, c.Sampleid, c.Survtech, c.Datesent, c.Datetested, c.Testtech, c.Comments, c.Processed, c.Sampletype, c.Samplecond, c.Species, c.Sex, c.Avetemp, c.Windspeed, c.Winddir, c.Raingauge, c.Activity, c.Testmethod, c.Diseasetested, c.Diseasepos, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Recordstatus, c.Zone2, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Lab, c.Fieldtech, c.Flockid, c.Samplecount, c.Chickenid, c.Gatewaysync, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.samplelocation.bob.go b/db/dbinfo/fieldseeker.samplelocation.bob.go index 44c878b3..c1a66e37 100644 --- a/db/dbinfo/fieldseeker.samplelocation.bob.go +++ b/db/dbinfo/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -231,6 +231,15 @@ var FieldseekerSamplelocations = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerSamplelocationIndexes{ SamplelocationPkey: index{ @@ -242,10 +251,15 @@ var FieldseekerSamplelocations = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -253,7 +267,7 @@ var FieldseekerSamplelocations = Table[ }, PrimaryKey: &constraint{ Name: "samplelocation_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -285,11 +299,12 @@ type fieldseekerSamplelocationColumns struct { Creator column Editdate column Editor column + Version column } func (c fieldseekerSamplelocationColumns) AsSlice() []column { return []column{ - c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Externalid, c.Nextactiondatescheduled, c.Zone2, c.Locationnumber, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Gatewaysync, c.Creationdate, c.Creator, c.Editdate, c.Editor, + c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Externalid, c.Nextactiondatescheduled, c.Zone2, c.Locationnumber, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Gatewaysync, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Version, } } diff --git a/db/dbinfo/fieldseeker.servicerequest.bob.go b/db/dbinfo/fieldseeker.servicerequest.bob.go index f3db45aa..c9d3db31 100644 --- a/db/dbinfo/fieldseeker.servicerequest.bob.go +++ b/db/dbinfo/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -789,6 +789,15 @@ var FieldseekerServicerequests = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerServicerequestIndexes{ ServicerequestPkey: index{ @@ -800,10 +809,15 @@ var FieldseekerServicerequests = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -811,7 +825,7 @@ var FieldseekerServicerequests = Table[ }, PrimaryKey: &constraint{ Name: "servicerequest_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -905,11 +919,12 @@ type fieldseekerServicerequestColumns struct { Notificationtimestamp column Zone column Zone2 column + Version column } func (c fieldseekerServicerequestColumns) AsSlice() []column { return []column{ - c.Objectid, c.Recdatetime, c.Source, c.Entrytech, c.Priority, c.Supervisor, c.Assignedtech, c.Status, c.Clranon, c.Clrfname, c.Clrphone1, c.Clrphone2, c.Clremail, c.Clrcompany, c.Clraddr1, c.Clraddr2, c.Clrcity, c.Clrstate, c.Clrzip, c.Clrother, c.Clrcontpref, c.Reqcompany, c.Reqaddr1, c.Reqaddr2, c.Reqcity, c.Reqstate, c.Reqzip, c.Reqcrossst, c.Reqsubdiv, c.Reqmapgrid, c.Reqpermission, c.Reqtarget, c.Reqdescr, c.Reqnotesfortech, c.Reqnotesforcust, c.Reqfldnotes, c.Reqprogramactions, c.Datetimeclosed, c.Techclosed, c.SRNumber, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Accepted, c.Accepteddate, c.Rejectedby, c.Rejecteddate, c.Rejectedreason, c.Duedate, c.Acceptedby, c.Comments, c.Estcompletedate, c.Nextaction, c.Recordstatus, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Firstresponsedate, c.Responsedaycount, c.Allowed, c.Xvalue, c.Yvalue, c.Validx, c.Validy, c.Externalid, c.Externalerror, c.Pointlocid, c.Notified, c.Notifieddate, c.Scheduled, c.Scheduleddate, c.Dog, c.SchedulePeriod, c.ScheduleNotes, c.Spanish, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Issuesreported, c.Jurisdiction, c.Notificationtimestamp, c.Zone, c.Zone2, + c.Objectid, c.Recdatetime, c.Source, c.Entrytech, c.Priority, c.Supervisor, c.Assignedtech, c.Status, c.Clranon, c.Clrfname, c.Clrphone1, c.Clrphone2, c.Clremail, c.Clrcompany, c.Clraddr1, c.Clraddr2, c.Clrcity, c.Clrstate, c.Clrzip, c.Clrother, c.Clrcontpref, c.Reqcompany, c.Reqaddr1, c.Reqaddr2, c.Reqcity, c.Reqstate, c.Reqzip, c.Reqcrossst, c.Reqsubdiv, c.Reqmapgrid, c.Reqpermission, c.Reqtarget, c.Reqdescr, c.Reqnotesfortech, c.Reqnotesforcust, c.Reqfldnotes, c.Reqprogramactions, c.Datetimeclosed, c.Techclosed, c.SRNumber, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Accepted, c.Accepteddate, c.Rejectedby, c.Rejecteddate, c.Rejectedreason, c.Duedate, c.Acceptedby, c.Comments, c.Estcompletedate, c.Nextaction, c.Recordstatus, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Firstresponsedate, c.Responsedaycount, c.Allowed, c.Xvalue, c.Yvalue, c.Validx, c.Validy, c.Externalid, c.Externalerror, c.Pointlocid, c.Notified, c.Notifieddate, c.Scheduled, c.Scheduleddate, c.Dog, c.SchedulePeriod, c.ScheduleNotes, c.Spanish, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Issuesreported, c.Jurisdiction, c.Notificationtimestamp, c.Zone, c.Zone2, c.Version, } } diff --git a/db/dbinfo/fieldseeker.speciesabundance.bob.go b/db/dbinfo/fieldseeker.speciesabundance.bob.go index c492caac..5eeda013 100644 --- a/db/dbinfo/fieldseeker.speciesabundance.bob.go +++ b/db/dbinfo/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -276,6 +276,15 @@ var FieldseekerSpeciesabundances = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerSpeciesabundanceIndexes{ SpeciesabundancePkey: index{ @@ -287,10 +296,15 @@ var FieldseekerSpeciesabundances = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -298,7 +312,7 @@ var FieldseekerSpeciesabundances = Table[ }, PrimaryKey: &constraint{ Name: "speciesabundance_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -335,11 +349,12 @@ type fieldseekerSpeciesabundanceColumns struct { R8score column H3R7 column H3R8 column + Version column } func (c fieldseekerSpeciesabundanceColumns) AsSlice() []column { return []column{ - c.Objectid, c.TrapdataID, c.Species, c.Males, c.Unknown, c.Bloodedfem, c.Gravidfem, c.Larvae, c.Poolstogen, c.Processed, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Pupae, c.Eggs, c.Females, c.Total, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Yearweek, c.Globalzscore, c.R7score, c.R8score, c.H3R7, c.H3R8, + c.Objectid, c.TrapdataID, c.Species, c.Males, c.Unknown, c.Bloodedfem, c.Gravidfem, c.Larvae, c.Poolstogen, c.Processed, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Pupae, c.Eggs, c.Females, c.Total, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Yearweek, c.Globalzscore, c.R7score, c.R8score, c.H3R7, c.H3R8, c.Version, } } diff --git a/db/dbinfo/fieldseeker.stormdrain.bob.go b/db/dbinfo/fieldseeker.stormdrain.bob.go index 1ea5ae48..ba71f49c 100644 --- a/db/dbinfo/fieldseeker.stormdrain.bob.go +++ b/db/dbinfo/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -186,6 +186,15 @@ var FieldseekerStormdrains = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerStormdrainIndexes{ StormdrainPkey: index{ @@ -197,10 +206,15 @@ var FieldseekerStormdrains = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -208,7 +222,7 @@ var FieldseekerStormdrains = Table[ }, PrimaryKey: &constraint{ Name: "stormdrain_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -235,11 +249,12 @@ type fieldseekerStormdrainColumns struct { Editor column Type column Jurisdiction column + Version column } func (c fieldseekerStormdrainColumns) AsSlice() []column { return []column{ - c.Objectid, c.Nexttreatmentdate, c.Lasttreatdate, c.Lastaction, c.Symbology, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Laststatus, c.Zone, c.Zone2, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Type, c.Jurisdiction, + c.Objectid, c.Nexttreatmentdate, c.Lasttreatdate, c.Lastaction, c.Symbology, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Laststatus, c.Zone, c.Zone2, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Type, c.Jurisdiction, c.Version, } } diff --git a/db/dbinfo/fieldseeker.timecard.bob.go b/db/dbinfo/fieldseeker.timecard.bob.go index dd44e5c3..bc461b84 100644 --- a/db/dbinfo/fieldseeker.timecard.bob.go +++ b/db/dbinfo/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -267,6 +267,15 @@ var FieldseekerTimecards = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerTimecardIndexes{ TimecardPkey: index{ @@ -278,10 +287,15 @@ var FieldseekerTimecards = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -289,7 +303,7 @@ var FieldseekerTimecards = Table[ }, PrimaryKey: &constraint{ Name: "timecard_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -325,11 +339,12 @@ type fieldseekerTimecardColumns struct { Editdate column Editor column Rodentlocid column + Version column } func (c fieldseekerTimecardColumns) AsSlice() []column { return []column{ - c.Objectid, c.Activity, c.Startdatetime, c.Enddatetime, c.Comments, c.Externalid, c.Equiptype, c.Locationname, c.Zone, c.Zone2, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.Lclocid, c.Samplelocid, c.Srid, c.Traplocid, c.Fieldtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Rodentlocid, + c.Objectid, c.Activity, c.Startdatetime, c.Enddatetime, c.Comments, c.Externalid, c.Equiptype, c.Locationname, c.Zone, c.Zone2, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.Lclocid, c.Samplelocid, c.Srid, c.Traplocid, c.Fieldtech, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Rodentlocid, c.Version, } } diff --git a/db/dbinfo/fieldseeker.tracklog.bob.go b/db/dbinfo/fieldseeker.tracklog.bob.go deleted file mode 100644 index 9cf01dd3..00000000 --- a/db/dbinfo/fieldseeker.tracklog.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerTracklogs = Table[ - fieldseekerTracklogColumns, - fieldseekerTracklogIndexes, - fieldseekerTracklogForeignKeys, - fieldseekerTracklogUniques, - fieldseekerTracklogChecks, -]{ - Schema: "fieldseeker", - Name: "tracklog", - Columns: fieldseekerTracklogColumns{}, - - Comment: "", -} - -type fieldseekerTracklogColumns struct{} - -func (c fieldseekerTracklogColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerTracklogIndexes struct{} - -func (i fieldseekerTracklogIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerTracklogForeignKeys struct{} - -func (f fieldseekerTracklogForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerTracklogUniques struct{} - -func (u fieldseekerTracklogUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerTracklogChecks struct{} - -func (c fieldseekerTracklogChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.trapdata.bob.go b/db/dbinfo/fieldseeker.trapdata.bob.go index 54e45fac..56bfac88 100644 --- a/db/dbinfo/fieldseeker.trapdata.bob.go +++ b/db/dbinfo/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -393,6 +393,15 @@ var FieldseekerTrapdata = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerTrapdatumIndexes{ TrapdataPkey: index{ @@ -404,10 +413,15 @@ var FieldseekerTrapdata = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -415,7 +429,7 @@ var FieldseekerTrapdata = Table[ }, PrimaryKey: &constraint{ Name: "trapdata_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -465,11 +479,12 @@ type fieldseekerTrapdatumColumns struct { Editdate column Editor column Lure column + Version column } func (c fieldseekerTrapdatumColumns) AsSlice() []column { return []column{ - c.Objectid, c.Traptype, c.Trapactivitytype, c.Startdatetime, c.Enddatetime, c.Comments, c.Idbytech, c.Sortbytech, c.Processed, c.Sitecond, c.Locationname, c.Recordstatus, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Trapcondition, c.Trapnights, c.Zone, c.Zone2, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Srid, c.Fieldtech, c.Gatewaysync, c.LocID, c.Voltage, c.Winddir, c.Windspeed, c.Avetemp, c.Raingauge, c.LR, c.Field, c.Vectorsurvtrapdataid, c.Vectorsurvtraplocationid, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Lure, + c.Objectid, c.Traptype, c.Trapactivitytype, c.Startdatetime, c.Enddatetime, c.Comments, c.Idbytech, c.Sortbytech, c.Processed, c.Sitecond, c.Locationname, c.Recordstatus, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Trapcondition, c.Trapnights, c.Zone, c.Zone2, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Srid, c.Fieldtech, c.Gatewaysync, c.LocID, c.Voltage, c.Winddir, c.Windspeed, c.Avetemp, c.Raingauge, c.LR, c.Field, c.Vectorsurvtrapdataid, c.Vectorsurvtraplocationid, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Lure, c.Version, } } diff --git a/db/dbinfo/fieldseeker.traplocation.bob.go b/db/dbinfo/fieldseeker.traplocation.bob.go index dfef8f49..7729e2be 100644 --- a/db/dbinfo/fieldseeker.traplocation.bob.go +++ b/db/dbinfo/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -285,6 +285,15 @@ var FieldseekerTraplocations = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerTraplocationIndexes{ TraplocationPkey: index{ @@ -296,10 +305,15 @@ var FieldseekerTraplocations = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -307,7 +321,7 @@ var FieldseekerTraplocations = Table[ }, PrimaryKey: &constraint{ Name: "traplocation_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -345,11 +359,12 @@ type fieldseekerTraplocationColumns struct { Editor column H3R7 column H3R8 column + Version column } func (c fieldseekerTraplocationColumns) AsSlice() []column { return []column{ - c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Externalid, c.Nextactiondatescheduled, c.Zone2, c.Locationnumber, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Gatewaysync, c.Route, c.SetDow, c.RouteOrder, c.Vectorsurvsiteid, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.H3R7, c.H3R8, + c.Objectid, c.Name, c.Zone, c.Habitat, c.Priority, c.Usetype, c.Active, c.Description, c.Accessdesc, c.Comments, c.Externalid, c.Nextactiondatescheduled, c.Zone2, c.Locationnumber, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Gatewaysync, c.Route, c.SetDow, c.RouteOrder, c.Vectorsurvsiteid, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.H3R7, c.H3R8, c.Version, } } diff --git a/db/dbinfo/fieldseeker.treatment.bob.go b/db/dbinfo/fieldseeker.treatment.bob.go index b4289faa..edec06c9 100644 --- a/db/dbinfo/fieldseeker.treatment.bob.go +++ b/db/dbinfo/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -501,6 +501,15 @@ var FieldseekerTreatments = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerTreatmentIndexes{ TreatmentPkey: index{ @@ -512,10 +521,15 @@ var FieldseekerTreatments = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -523,7 +537,7 @@ var FieldseekerTreatments = Table[ }, PrimaryKey: &constraint{ Name: "treatment_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -585,11 +599,12 @@ type fieldseekerTreatmentColumns struct { Editdate column Editor column Targetspecies column + Version column } func (c fieldseekerTreatmentColumns) AsSlice() []column { return []column{ - c.Objectid, c.Activity, c.Treatarea, c.Areaunit, c.Product, c.Qty, c.Qtyunit, c.Method, c.Equiptype, c.Comments, c.Avetemp, c.Windspeed, c.Winddir, c.Raingauge, c.Startdatetime, c.Enddatetime, c.InspID, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Warningoverride, c.Recordstatus, c.Zone2, c.Treatacres, c.Tirecount, c.Cbcount, c.Containercount, c.Globalid, c.Treatmentlength, c.Treatmenthours, c.Treatmentlengthunits, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.Srid, c.Sdid, c.Barrierrouteid, c.Ulvrouteid, c.Fieldtech, c.Ptaid, c.Flowrate, c.Habitat, c.Treathectares, c.Invloc, c.TempSitecond, c.Sitecond, c.Totalcostprodcut, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Targetspecies, + c.Objectid, c.Activity, c.Treatarea, c.Areaunit, c.Product, c.Qty, c.Qtyunit, c.Method, c.Equiptype, c.Comments, c.Avetemp, c.Windspeed, c.Winddir, c.Raingauge, c.Startdatetime, c.Enddatetime, c.InspID, c.Reviewed, c.Reviewedby, c.Revieweddate, c.Locationname, c.Zone, c.Warningoverride, c.Recordstatus, c.Zone2, c.Treatacres, c.Tirecount, c.Cbcount, c.Containercount, c.Globalid, c.Treatmentlength, c.Treatmenthours, c.Treatmentlengthunits, c.Linelocid, c.Pointlocid, c.Polygonlocid, c.Srid, c.Sdid, c.Barrierrouteid, c.Ulvrouteid, c.Fieldtech, c.Ptaid, c.Flowrate, c.Habitat, c.Treathectares, c.Invloc, c.TempSitecond, c.Sitecond, c.Totalcostprodcut, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.Targetspecies, c.Version, } } diff --git a/db/dbinfo/fieldseeker.treatmentarea.bob.go b/db/dbinfo/fieldseeker.treatmentarea.bob.go index 667fa34c..2a254faf 100644 --- a/db/dbinfo/fieldseeker.treatmentarea.bob.go +++ b/db/dbinfo/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -177,6 +177,15 @@ var FieldseekerTreatmentareas = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerTreatmentareaIndexes{ TreatmentareaPkey: index{ @@ -188,10 +197,15 @@ var FieldseekerTreatmentareas = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -199,7 +213,7 @@ var FieldseekerTreatmentareas = Table[ }, PrimaryKey: &constraint{ Name: "treatmentarea_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -225,11 +239,12 @@ type fieldseekerTreatmentareaColumns struct { Editor column ShapeArea column ShapeLength column + Version column } func (c fieldseekerTreatmentareaColumns) AsSlice() []column { return []column{ - c.Objectid, c.TreatID, c.SessionID, c.Treatdate, c.Comments, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Notified, c.Type, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.ShapeArea, c.ShapeLength, + c.Objectid, c.TreatID, c.SessionID, c.Treatdate, c.Comments, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Notified, c.Type, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.ShapeArea, c.ShapeLength, c.Version, } } diff --git a/db/dbinfo/fieldseeker.ulvsprayroute.bob.go b/db/dbinfo/fieldseeker.ulvsprayroute.bob.go deleted file mode 100644 index 7366fed5..00000000 --- a/db/dbinfo/fieldseeker.ulvsprayroute.bob.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -var FieldseekerUlvsprayroutes = Table[ - fieldseekerUlvsprayrouteColumns, - fieldseekerUlvsprayrouteIndexes, - fieldseekerUlvsprayrouteForeignKeys, - fieldseekerUlvsprayrouteUniques, - fieldseekerUlvsprayrouteChecks, -]{ - Schema: "fieldseeker", - Name: "ulvsprayroute", - Columns: fieldseekerUlvsprayrouteColumns{}, - - Comment: "", -} - -type fieldseekerUlvsprayrouteColumns struct{} - -func (c fieldseekerUlvsprayrouteColumns) AsSlice() []column { - return []column{} -} - -type fieldseekerUlvsprayrouteIndexes struct{} - -func (i fieldseekerUlvsprayrouteIndexes) AsSlice() []index { - return []index{} -} - -type fieldseekerUlvsprayrouteForeignKeys struct{} - -func (f fieldseekerUlvsprayrouteForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type fieldseekerUlvsprayrouteUniques struct{} - -func (u fieldseekerUlvsprayrouteUniques) AsSlice() []constraint { - return []constraint{} -} - -type fieldseekerUlvsprayrouteChecks struct{} - -func (c fieldseekerUlvsprayrouteChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/fieldseeker.zones.bob.go b/db/dbinfo/fieldseeker.zones.bob.go index a9cf7d04..e3770abb 100644 --- a/db/dbinfo/fieldseeker.zones.bob.go +++ b/db/dbinfo/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -141,6 +141,15 @@ var FieldseekerZones = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerZoneIndexes{ ZonesPkey: index{ @@ -152,10 +161,15 @@ var FieldseekerZones = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -163,7 +177,7 @@ var FieldseekerZones = Table[ }, PrimaryKey: &constraint{ Name: "zones_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -185,11 +199,12 @@ type fieldseekerZoneColumns struct { Editor column ShapeArea column ShapeLength column + Version column } func (c fieldseekerZoneColumns) AsSlice() []column { return []column{ - c.Objectid, c.Name, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Active, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.ShapeArea, c.ShapeLength, + c.Objectid, c.Name, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Active, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.ShapeArea, c.ShapeLength, c.Version, } } diff --git a/db/dbinfo/fieldseeker.zones2.bob.go b/db/dbinfo/fieldseeker.zones2.bob.go index ca012d59..c0ba77dd 100644 --- a/db/dbinfo/fieldseeker.zones2.bob.go +++ b/db/dbinfo/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo @@ -132,6 +132,15 @@ var FieldseekerZones2s = Table[ Generated: false, AutoIncr: false, }, + Version: column{ + Name: "version", + DBType: "integer", + Default: "1", + Comment: "Tracks version changes to the row. Increases when data is modified.", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: fieldseekerZones2Indexes{ Zones2Pkey: index{ @@ -143,10 +152,15 @@ var FieldseekerZones2s = Table[ Desc: null.FromCond(false, true), IsExpression: false, }, + { + Name: "version", + Desc: null.FromCond(false, true), + IsExpression: false, + }, }, Unique: true, Comment: "", - NullsFirst: []bool{false}, + NullsFirst: []bool{false, false}, NullsDistinct: false, Where: "", Include: []string{}, @@ -154,7 +168,7 @@ var FieldseekerZones2s = Table[ }, PrimaryKey: &constraint{ Name: "zones2_pkey", - Columns: []string{"objectid"}, + Columns: []string{"objectid", "version"}, Comment: "", }, @@ -175,11 +189,12 @@ type fieldseekerZones2Columns struct { Editor column ShapeArea column ShapeLength column + Version column } func (c fieldseekerZones2Columns) AsSlice() []column { return []column{ - c.Objectid, c.Name, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.ShapeArea, c.ShapeLength, + c.Objectid, c.Name, c.Globalid, c.CreatedUser, c.CreatedDate, c.LastEditedUser, c.LastEditedDate, c.Creationdate, c.Creator, c.Editdate, c.Editor, c.ShapeArea, c.ShapeLength, c.Version, } } diff --git a/db/dbinfo/fieldseeker_sync.bob.go b/db/dbinfo/fieldseeker_sync.bob.go index 7422cef9..f3b1b8f5 100644 --- a/db/dbinfo/fieldseeker_sync.bob.go +++ b/db/dbinfo/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_containerrelate.bob.go b/db/dbinfo/fs_containerrelate.bob.go index eef0ea58..be6b1380 100644 --- a/db/dbinfo/fs_containerrelate.bob.go +++ b/db/dbinfo/fs_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_fieldscoutinglog.bob.go b/db/dbinfo/fs_fieldscoutinglog.bob.go index 8b02eaf0..4ded1baf 100644 --- a/db/dbinfo/fs_fieldscoutinglog.bob.go +++ b/db/dbinfo/fs_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_habitatrelate.bob.go b/db/dbinfo/fs_habitatrelate.bob.go index 38dce854..b7bdc903 100644 --- a/db/dbinfo/fs_habitatrelate.bob.go +++ b/db/dbinfo/fs_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_inspectionsample.bob.go b/db/dbinfo/fs_inspectionsample.bob.go index 20fd01e4..0e503d3f 100644 --- a/db/dbinfo/fs_inspectionsample.bob.go +++ b/db/dbinfo/fs_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_inspectionsampledetail.bob.go b/db/dbinfo/fs_inspectionsampledetail.bob.go index 894f9d35..5a903c84 100644 --- a/db/dbinfo/fs_inspectionsampledetail.bob.go +++ b/db/dbinfo/fs_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_linelocation.bob.go b/db/dbinfo/fs_linelocation.bob.go index 4a6ac196..96abf326 100644 --- a/db/dbinfo/fs_linelocation.bob.go +++ b/db/dbinfo/fs_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_locationtracking.bob.go b/db/dbinfo/fs_locationtracking.bob.go index 18ec8312..4a28fd12 100644 --- a/db/dbinfo/fs_locationtracking.bob.go +++ b/db/dbinfo/fs_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_mosquitoinspection.bob.go b/db/dbinfo/fs_mosquitoinspection.bob.go index 410c1ce7..2fab369e 100644 --- a/db/dbinfo/fs_mosquitoinspection.bob.go +++ b/db/dbinfo/fs_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_pointlocation.bob.go b/db/dbinfo/fs_pointlocation.bob.go index 0d10f351..09532922 100644 --- a/db/dbinfo/fs_pointlocation.bob.go +++ b/db/dbinfo/fs_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_polygonlocation.bob.go b/db/dbinfo/fs_polygonlocation.bob.go index 5c381545..0d0549ab 100644 --- a/db/dbinfo/fs_polygonlocation.bob.go +++ b/db/dbinfo/fs_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_pool.bob.go b/db/dbinfo/fs_pool.bob.go index bcbedcc4..2c490020 100644 --- a/db/dbinfo/fs_pool.bob.go +++ b/db/dbinfo/fs_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_pooldetail.bob.go b/db/dbinfo/fs_pooldetail.bob.go index debaf6db..7ae502cf 100644 --- a/db/dbinfo/fs_pooldetail.bob.go +++ b/db/dbinfo/fs_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_proposedtreatmentarea.bob.go b/db/dbinfo/fs_proposedtreatmentarea.bob.go index 34e57cf4..c68ac2d1 100644 --- a/db/dbinfo/fs_proposedtreatmentarea.bob.go +++ b/db/dbinfo/fs_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_qamosquitoinspection.bob.go b/db/dbinfo/fs_qamosquitoinspection.bob.go index e4356a11..9a6f43e5 100644 --- a/db/dbinfo/fs_qamosquitoinspection.bob.go +++ b/db/dbinfo/fs_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_rodentlocation.bob.go b/db/dbinfo/fs_rodentlocation.bob.go index a882d91c..df01594e 100644 --- a/db/dbinfo/fs_rodentlocation.bob.go +++ b/db/dbinfo/fs_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_samplecollection.bob.go b/db/dbinfo/fs_samplecollection.bob.go index 2bedeebe..2c1a9233 100644 --- a/db/dbinfo/fs_samplecollection.bob.go +++ b/db/dbinfo/fs_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_samplelocation.bob.go b/db/dbinfo/fs_samplelocation.bob.go index 0aac77ea..b49ea82a 100644 --- a/db/dbinfo/fs_samplelocation.bob.go +++ b/db/dbinfo/fs_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_servicerequest.bob.go b/db/dbinfo/fs_servicerequest.bob.go index 977350a4..dcad51e9 100644 --- a/db/dbinfo/fs_servicerequest.bob.go +++ b/db/dbinfo/fs_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_speciesabundance.bob.go b/db/dbinfo/fs_speciesabundance.bob.go index 1083b49f..e36a479f 100644 --- a/db/dbinfo/fs_speciesabundance.bob.go +++ b/db/dbinfo/fs_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_stormdrain.bob.go b/db/dbinfo/fs_stormdrain.bob.go index 30569d7c..3cd4f51d 100644 --- a/db/dbinfo/fs_stormdrain.bob.go +++ b/db/dbinfo/fs_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_timecard.bob.go b/db/dbinfo/fs_timecard.bob.go index 3432ad07..d240c0b8 100644 --- a/db/dbinfo/fs_timecard.bob.go +++ b/db/dbinfo/fs_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_trapdata.bob.go b/db/dbinfo/fs_trapdata.bob.go index dba6d914..36f61eec 100644 --- a/db/dbinfo/fs_trapdata.bob.go +++ b/db/dbinfo/fs_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_traplocation.bob.go b/db/dbinfo/fs_traplocation.bob.go index f1a9c6d9..b037287a 100644 --- a/db/dbinfo/fs_traplocation.bob.go +++ b/db/dbinfo/fs_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_treatment.bob.go b/db/dbinfo/fs_treatment.bob.go index 4a62f732..0007d2b1 100644 --- a/db/dbinfo/fs_treatment.bob.go +++ b/db/dbinfo/fs_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_treatmentarea.bob.go b/db/dbinfo/fs_treatmentarea.bob.go index 7b5a5817..a4a51ab3 100644 --- a/db/dbinfo/fs_treatmentarea.bob.go +++ b/db/dbinfo/fs_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_zones.bob.go b/db/dbinfo/fs_zones.bob.go index ebf92a70..43b67b62 100644 --- a/db/dbinfo/fs_zones.bob.go +++ b/db/dbinfo/fs_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fs_zones2.bob.go b/db/dbinfo/fs_zones2.bob.go index b6c5cb7b..072f99c1 100644 --- a/db/dbinfo/fs_zones2.bob.go +++ b/db/dbinfo/fs_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/geography_columns.bob.go b/db/dbinfo/geography_columns.bob.go index f4140c80..d25dd407 100644 --- a/db/dbinfo/geography_columns.bob.go +++ b/db/dbinfo/geography_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/geometry_columns.bob.go b/db/dbinfo/geometry_columns.bob.go index 7a594abf..b2dd56f7 100644 --- a/db/dbinfo/geometry_columns.bob.go +++ b/db/dbinfo/geometry_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/goose_db_version.bob.go b/db/dbinfo/goose_db_version.bob.go index 794a8304..2446c32d 100644 --- a/db/dbinfo/goose_db_version.bob.go +++ b/db/dbinfo/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/h3_aggregation.bob.go b/db/dbinfo/h3_aggregation.bob.go index 560aa8d5..40976a4e 100644 --- a/db/dbinfo/h3_aggregation.bob.go +++ b/db/dbinfo/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_containerrelate.bob.go b/db/dbinfo/history_containerrelate.bob.go index aa8a476b..4eee2159 100644 --- a/db/dbinfo/history_containerrelate.bob.go +++ b/db/dbinfo/history_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_fieldscoutinglog.bob.go b/db/dbinfo/history_fieldscoutinglog.bob.go index ccc5f997..8e3fc9ab 100644 --- a/db/dbinfo/history_fieldscoutinglog.bob.go +++ b/db/dbinfo/history_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_habitatrelate.bob.go b/db/dbinfo/history_habitatrelate.bob.go index 06678a43..6e6d3f2f 100644 --- a/db/dbinfo/history_habitatrelate.bob.go +++ b/db/dbinfo/history_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_inspectionsample.bob.go b/db/dbinfo/history_inspectionsample.bob.go index f8226a11..7153cea0 100644 --- a/db/dbinfo/history_inspectionsample.bob.go +++ b/db/dbinfo/history_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_inspectionsampledetail.bob.go b/db/dbinfo/history_inspectionsampledetail.bob.go index 1ab9932f..e05398f4 100644 --- a/db/dbinfo/history_inspectionsampledetail.bob.go +++ b/db/dbinfo/history_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_linelocation.bob.go b/db/dbinfo/history_linelocation.bob.go index 82f05b5c..4f8d80c8 100644 --- a/db/dbinfo/history_linelocation.bob.go +++ b/db/dbinfo/history_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_locationtracking.bob.go b/db/dbinfo/history_locationtracking.bob.go index 6841413b..29fe80b1 100644 --- a/db/dbinfo/history_locationtracking.bob.go +++ b/db/dbinfo/history_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_mosquitoinspection.bob.go b/db/dbinfo/history_mosquitoinspection.bob.go index bd02f9c7..c34a3072 100644 --- a/db/dbinfo/history_mosquitoinspection.bob.go +++ b/db/dbinfo/history_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_pointlocation.bob.go b/db/dbinfo/history_pointlocation.bob.go index f2f7e86a..010a294c 100644 --- a/db/dbinfo/history_pointlocation.bob.go +++ b/db/dbinfo/history_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_polygonlocation.bob.go b/db/dbinfo/history_polygonlocation.bob.go index 30c6f196..2b18ccfb 100644 --- a/db/dbinfo/history_polygonlocation.bob.go +++ b/db/dbinfo/history_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_pool.bob.go b/db/dbinfo/history_pool.bob.go index 18c1f87b..a19bfcc2 100644 --- a/db/dbinfo/history_pool.bob.go +++ b/db/dbinfo/history_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_pooldetail.bob.go b/db/dbinfo/history_pooldetail.bob.go index 9ca74073..4e9f5116 100644 --- a/db/dbinfo/history_pooldetail.bob.go +++ b/db/dbinfo/history_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_proposedtreatmentarea.bob.go b/db/dbinfo/history_proposedtreatmentarea.bob.go index b40925fc..e2d54a8a 100644 --- a/db/dbinfo/history_proposedtreatmentarea.bob.go +++ b/db/dbinfo/history_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_qamosquitoinspection.bob.go b/db/dbinfo/history_qamosquitoinspection.bob.go index ccf3ab6d..3c48e09e 100644 --- a/db/dbinfo/history_qamosquitoinspection.bob.go +++ b/db/dbinfo/history_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_rodentlocation.bob.go b/db/dbinfo/history_rodentlocation.bob.go index 9829f97e..14feb7fb 100644 --- a/db/dbinfo/history_rodentlocation.bob.go +++ b/db/dbinfo/history_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_samplecollection.bob.go b/db/dbinfo/history_samplecollection.bob.go index b02adb81..37d8c4f3 100644 --- a/db/dbinfo/history_samplecollection.bob.go +++ b/db/dbinfo/history_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_samplelocation.bob.go b/db/dbinfo/history_samplelocation.bob.go index ce4380b2..0422f402 100644 --- a/db/dbinfo/history_samplelocation.bob.go +++ b/db/dbinfo/history_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_servicerequest.bob.go b/db/dbinfo/history_servicerequest.bob.go index f04b99c0..6757c5a3 100644 --- a/db/dbinfo/history_servicerequest.bob.go +++ b/db/dbinfo/history_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_speciesabundance.bob.go b/db/dbinfo/history_speciesabundance.bob.go index a739c089..befabce4 100644 --- a/db/dbinfo/history_speciesabundance.bob.go +++ b/db/dbinfo/history_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_stormdrain.bob.go b/db/dbinfo/history_stormdrain.bob.go index 6f587d7d..312bb6d5 100644 --- a/db/dbinfo/history_stormdrain.bob.go +++ b/db/dbinfo/history_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_timecard.bob.go b/db/dbinfo/history_timecard.bob.go index ce42d572..feb4cd38 100644 --- a/db/dbinfo/history_timecard.bob.go +++ b/db/dbinfo/history_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_trapdata.bob.go b/db/dbinfo/history_trapdata.bob.go index b1c816a3..bb33dc63 100644 --- a/db/dbinfo/history_trapdata.bob.go +++ b/db/dbinfo/history_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_traplocation.bob.go b/db/dbinfo/history_traplocation.bob.go index 3c38f380..84d27014 100644 --- a/db/dbinfo/history_traplocation.bob.go +++ b/db/dbinfo/history_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_treatment.bob.go b/db/dbinfo/history_treatment.bob.go index 095b4e13..1cfb6398 100644 --- a/db/dbinfo/history_treatment.bob.go +++ b/db/dbinfo/history_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_treatmentarea.bob.go b/db/dbinfo/history_treatmentarea.bob.go index 3bba1751..7e9d0726 100644 --- a/db/dbinfo/history_treatmentarea.bob.go +++ b/db/dbinfo/history_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_zones.bob.go b/db/dbinfo/history_zones.bob.go index 8366a107..f9966ddf 100644 --- a/db/dbinfo/history_zones.bob.go +++ b/db/dbinfo/history_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/history_zones2.bob.go b/db/dbinfo/history_zones2.bob.go index 731b4068..78d2abd3 100644 --- a/db/dbinfo/history_zones2.bob.go +++ b/db/dbinfo/history_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/notification.bob.go b/db/dbinfo/notification.bob.go index 29ddb560..c639ebac 100644 --- a/db/dbinfo/notification.bob.go +++ b/db/dbinfo/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/oauth_token.bob.go b/db/dbinfo/oauth_token.bob.go index 5b051e10..96f6feee 100644 --- a/db/dbinfo/oauth_token.bob.go +++ b/db/dbinfo/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/organization.bob.go b/db/dbinfo/organization.bob.go index a1c9b3a0..c871abeb 100644 --- a/db/dbinfo/organization.bob.go +++ b/db/dbinfo/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/raster_columns.bob.go b/db/dbinfo/raster_columns.bob.go index 6c9fcd11..900b1aad 100644 --- a/db/dbinfo/raster_columns.bob.go +++ b/db/dbinfo/raster_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/raster_overviews.bob.go b/db/dbinfo/raster_overviews.bob.go index 3ba89bb3..2d8d2936 100644 --- a/db/dbinfo/raster_overviews.bob.go +++ b/db/dbinfo/raster_overviews.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/sessions.bob.go b/db/dbinfo/sessions.bob.go index 876a5667..91933caf 100644 --- a/db/dbinfo/sessions.bob.go +++ b/db/dbinfo/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/spatial_ref_sys.bob.go b/db/dbinfo/spatial_ref_sys.bob.go index 6315d501..b2282470 100644 --- a/db/dbinfo/spatial_ref_sys.bob.go +++ b/db/dbinfo/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/user_.bob.go b/db/dbinfo/user_.bob.go index 0e764208..8d0f10f4 100644 --- a/db/dbinfo/user_.bob.go +++ b/db/dbinfo/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/enums/enums.bob.go b/db/enums/enums.bob.go index 2572ffaf..6a003a0e 100644 --- a/db/enums/enums.bob.go +++ b/db/enums/enums.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package enums diff --git a/db/factory/bobfactory_context.bob.go b/db/factory/bobfactory_context.bob.go index c71a2cf0..c84f7772 100644 --- a/db/factory/bobfactory_context.bob.go +++ b/db/factory/bobfactory_context.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -8,18 +8,6 @@ import "context" type contextKey string var ( - // Relationship Contexts for fieldseeker.aerialsprayline - fieldseekerAerialspraylineWithParentsCascadingCtx = newContextual[bool]("fieldseekerAerialspraylineWithParentsCascading") - - // Relationship Contexts for fieldseeker.aerialspraysession - fieldseekerAerialspraysessionWithParentsCascadingCtx = newContextual[bool]("fieldseekerAerialspraysessionWithParentsCascading") - - // Relationship Contexts for fieldseeker.barrierspray - fieldseekerBarriersprayWithParentsCascadingCtx = newContextual[bool]("fieldseekerBarriersprayWithParentsCascading") - - // Relationship Contexts for fieldseeker.barriersprayroute - fieldseekerBarriersprayrouteWithParentsCascadingCtx = newContextual[bool]("fieldseekerBarriersprayrouteWithParentsCascading") - // Relationship Contexts for fieldseeker.containerrelate fieldseekerContainerrelateWithParentsCascadingCtx = newContextual[bool]("fieldseekerContainerrelateWithParentsCascading") @@ -35,12 +23,6 @@ var ( // Relationship Contexts for fieldseeker.inspectionsampledetail fieldseekerInspectionsampledetailWithParentsCascadingCtx = newContextual[bool]("fieldseekerInspectionsampledetailWithParentsCascading") - // Relationship Contexts for fieldseeker.landingcount - fieldseekerLandingcountWithParentsCascadingCtx = newContextual[bool]("fieldseekerLandingcountWithParentsCascading") - - // Relationship Contexts for fieldseeker.landingcountlocation - fieldseekerLandingcountlocationWithParentsCascadingCtx = newContextual[bool]("fieldseekerLandingcountlocationWithParentsCascading") - // Relationship Contexts for fieldseeker.linelocation fieldseekerLinelocationWithParentsCascadingCtx = newContextual[bool]("fieldseekerLinelocationWithParentsCascading") @@ -59,33 +41,17 @@ var ( // Relationship Contexts for fieldseeker.pool fieldseekerPoolWithParentsCascadingCtx = newContextual[bool]("fieldseekerPoolWithParentsCascading") - // Relationship Contexts for fieldseeker.poolbuffer - fieldseekerPoolbufferWithParentsCascadingCtx = newContextual[bool]("fieldseekerPoolbufferWithParentsCascading") - // Relationship Contexts for fieldseeker.pooldetail fieldseekerPooldetailWithParentsCascadingCtx = newContextual[bool]("fieldseekerPooldetailWithParentsCascading") // Relationship Contexts for fieldseeker.proposedtreatmentarea fieldseekerProposedtreatmentareaWithParentsCascadingCtx = newContextual[bool]("fieldseekerProposedtreatmentareaWithParentsCascading") - // Relationship Contexts for fieldseeker.qalarvcount - fieldseekerQalarvcountWithParentsCascadingCtx = newContextual[bool]("fieldseekerQalarvcountWithParentsCascading") - // Relationship Contexts for fieldseeker.qamosquitoinspection fieldseekerQamosquitoinspectionWithParentsCascadingCtx = newContextual[bool]("fieldseekerQamosquitoinspectionWithParentsCascading") - // Relationship Contexts for fieldseeker.qaproductobservation - fieldseekerQaproductobservationWithParentsCascadingCtx = newContextual[bool]("fieldseekerQaproductobservationWithParentsCascading") - - // Relationship Contexts for fieldseeker.restrictedarea - fieldseekerRestrictedareaWithParentsCascadingCtx = newContextual[bool]("fieldseekerRestrictedareaWithParentsCascading") - - // Relationship Contexts for fieldseeker.rodentinspection - fieldseekerRodentinspectionWithParentsCascadingCtx = newContextual[bool]("fieldseekerRodentinspectionWithParentsCascading") - // Relationship Contexts for fieldseeker.rodentlocation fieldseekerRodentlocationWithParentsCascadingCtx = newContextual[bool]("fieldseekerRodentlocationWithParentsCascading") - fieldseekerRodentlocationRelOrganizationCtx = newContextual[bool]("fieldseeker.rodentlocation.organization.fieldseeker.rodentlocation.rodentlocation_organization_id_fkey") // Relationship Contexts for fieldseeker.samplecollection fieldseekerSamplecollectionWithParentsCascadingCtx = newContextual[bool]("fieldseekerSamplecollectionWithParentsCascading") @@ -105,9 +71,6 @@ var ( // Relationship Contexts for fieldseeker.timecard fieldseekerTimecardWithParentsCascadingCtx = newContextual[bool]("fieldseekerTimecardWithParentsCascading") - // Relationship Contexts for fieldseeker.tracklog - fieldseekerTracklogWithParentsCascadingCtx = newContextual[bool]("fieldseekerTracklogWithParentsCascading") - // Relationship Contexts for fieldseeker.trapdata fieldseekerTrapdatumWithParentsCascadingCtx = newContextual[bool]("fieldseekerTrapdatumWithParentsCascading") @@ -120,9 +83,6 @@ var ( // Relationship Contexts for fieldseeker.treatmentarea fieldseekerTreatmentareaWithParentsCascadingCtx = newContextual[bool]("fieldseekerTreatmentareaWithParentsCascading") - // Relationship Contexts for fieldseeker.ulvsprayroute - fieldseekerUlvsprayrouteWithParentsCascadingCtx = newContextual[bool]("fieldseekerUlvsprayrouteWithParentsCascading") - // Relationship Contexts for fieldseeker.zones fieldseekerZoneWithParentsCascadingCtx = newContextual[bool]("fieldseekerZoneWithParentsCascading") @@ -372,7 +332,6 @@ var ( // Relationship Contexts for organization organizationWithParentsCascadingCtx = newContextual[bool]("organizationWithParentsCascading") - organizationRelRodentlocationsCtx = newContextual[bool]("fieldseeker.rodentlocation.organization.fieldseeker.rodentlocation.rodentlocation_organization_id_fkey") organizationRelFieldseekerSyncsCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey") organizationRelFSContainerrelatesCtx = newContextual[bool]("fs_containerrelate.organization.fs_containerrelate.fs_containerrelate_organization_id_fkey") organizationRelFSFieldscoutinglogsCtx = newContextual[bool]("fs_fieldscoutinglog.organization.fs_fieldscoutinglog.fs_fieldscoutinglog_organization_id_fkey") diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go index 5cb3bce5..b8f82b18 100644 --- a/db/factory/bobfactory_main.bob.go +++ b/db/factory/bobfactory_main.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -15,31 +15,20 @@ import ( ) type Factory struct { - baseFieldseekerAerialspraylineMods FieldseekerAerialspraylineModSlice - baseFieldseekerAerialspraysessionMods FieldseekerAerialspraysessionModSlice - baseFieldseekerBarriersprayMods FieldseekerBarriersprayModSlice - baseFieldseekerBarriersprayrouteMods FieldseekerBarriersprayrouteModSlice baseFieldseekerContainerrelateMods FieldseekerContainerrelateModSlice baseFieldseekerFieldscoutinglogMods FieldseekerFieldscoutinglogModSlice baseFieldseekerHabitatrelateMods FieldseekerHabitatrelateModSlice baseFieldseekerInspectionsampleMods FieldseekerInspectionsampleModSlice baseFieldseekerInspectionsampledetailMods FieldseekerInspectionsampledetailModSlice - baseFieldseekerLandingcountMods FieldseekerLandingcountModSlice - baseFieldseekerLandingcountlocationMods FieldseekerLandingcountlocationModSlice baseFieldseekerLinelocationMods FieldseekerLinelocationModSlice baseFieldseekerLocationtrackingMods FieldseekerLocationtrackingModSlice baseFieldseekerMosquitoinspectionMods FieldseekerMosquitoinspectionModSlice baseFieldseekerPointlocationMods FieldseekerPointlocationModSlice baseFieldseekerPolygonlocationMods FieldseekerPolygonlocationModSlice baseFieldseekerPoolMods FieldseekerPoolModSlice - baseFieldseekerPoolbufferMods FieldseekerPoolbufferModSlice baseFieldseekerPooldetailMods FieldseekerPooldetailModSlice baseFieldseekerProposedtreatmentareaMods FieldseekerProposedtreatmentareaModSlice - baseFieldseekerQalarvcountMods FieldseekerQalarvcountModSlice baseFieldseekerQamosquitoinspectionMods FieldseekerQamosquitoinspectionModSlice - baseFieldseekerQaproductobservationMods FieldseekerQaproductobservationModSlice - baseFieldseekerRestrictedareaMods FieldseekerRestrictedareaModSlice - baseFieldseekerRodentinspectionMods FieldseekerRodentinspectionModSlice baseFieldseekerRodentlocationMods FieldseekerRodentlocationModSlice baseFieldseekerSamplecollectionMods FieldseekerSamplecollectionModSlice baseFieldseekerSamplelocationMods FieldseekerSamplelocationModSlice @@ -47,12 +36,10 @@ type Factory struct { baseFieldseekerSpeciesabundanceMods FieldseekerSpeciesabundanceModSlice baseFieldseekerStormdrainMods FieldseekerStormdrainModSlice baseFieldseekerTimecardMods FieldseekerTimecardModSlice - baseFieldseekerTracklogMods FieldseekerTracklogModSlice baseFieldseekerTrapdatumMods FieldseekerTrapdatumModSlice baseFieldseekerTraplocationMods FieldseekerTraplocationModSlice baseFieldseekerTreatmentMods FieldseekerTreatmentModSlice baseFieldseekerTreatmentareaMods FieldseekerTreatmentareaModSlice - baseFieldseekerUlvsprayrouteMods FieldseekerUlvsprayrouteModSlice baseFieldseekerZoneMods FieldseekerZoneModSlice baseFieldseekerZones2Mods FieldseekerZones2ModSlice baseFieldseekerSyncMods FieldseekerSyncModSlice @@ -128,94 +115,6 @@ func New() *Factory { return &Factory{} } -func (f *Factory) NewFieldseekerAerialsprayline(mods ...FieldseekerAerialspraylineMod) *FieldseekerAerialspraylineTemplate { - return f.NewFieldseekerAerialspraylineWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerAerialspraylineWithContext(ctx context.Context, mods ...FieldseekerAerialspraylineMod) *FieldseekerAerialspraylineTemplate { - o := &FieldseekerAerialspraylineTemplate{f: f} - - if f != nil { - f.baseFieldseekerAerialspraylineMods.Apply(ctx, o) - } - - FieldseekerAerialspraylineModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerAerialsprayline(m *models.FieldseekerAerialsprayline) *FieldseekerAerialspraylineTemplate { - o := &FieldseekerAerialspraylineTemplate{f: f, alreadyPersisted: true} - - return o -} - -func (f *Factory) NewFieldseekerAerialspraysession(mods ...FieldseekerAerialspraysessionMod) *FieldseekerAerialspraysessionTemplate { - return f.NewFieldseekerAerialspraysessionWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerAerialspraysessionWithContext(ctx context.Context, mods ...FieldseekerAerialspraysessionMod) *FieldseekerAerialspraysessionTemplate { - o := &FieldseekerAerialspraysessionTemplate{f: f} - - if f != nil { - f.baseFieldseekerAerialspraysessionMods.Apply(ctx, o) - } - - FieldseekerAerialspraysessionModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerAerialspraysession(m *models.FieldseekerAerialspraysession) *FieldseekerAerialspraysessionTemplate { - o := &FieldseekerAerialspraysessionTemplate{f: f, alreadyPersisted: true} - - return o -} - -func (f *Factory) NewFieldseekerBarrierspray(mods ...FieldseekerBarriersprayMod) *FieldseekerBarriersprayTemplate { - return f.NewFieldseekerBarriersprayWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerBarriersprayWithContext(ctx context.Context, mods ...FieldseekerBarriersprayMod) *FieldseekerBarriersprayTemplate { - o := &FieldseekerBarriersprayTemplate{f: f} - - if f != nil { - f.baseFieldseekerBarriersprayMods.Apply(ctx, o) - } - - FieldseekerBarriersprayModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerBarrierspray(m *models.FieldseekerBarrierspray) *FieldseekerBarriersprayTemplate { - o := &FieldseekerBarriersprayTemplate{f: f, alreadyPersisted: true} - - return o -} - -func (f *Factory) NewFieldseekerBarriersprayroute(mods ...FieldseekerBarriersprayrouteMod) *FieldseekerBarriersprayrouteTemplate { - return f.NewFieldseekerBarriersprayrouteWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerBarriersprayrouteWithContext(ctx context.Context, mods ...FieldseekerBarriersprayrouteMod) *FieldseekerBarriersprayrouteTemplate { - o := &FieldseekerBarriersprayrouteTemplate{f: f} - - if f != nil { - f.baseFieldseekerBarriersprayrouteMods.Apply(ctx, o) - } - - FieldseekerBarriersprayrouteModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerBarriersprayroute(m *models.FieldseekerBarriersprayroute) *FieldseekerBarriersprayrouteTemplate { - o := &FieldseekerBarriersprayrouteTemplate{f: f, alreadyPersisted: true} - - return o -} - func (f *Factory) NewFieldseekerContainerrelate(mods ...FieldseekerContainerrelateMod) *FieldseekerContainerrelateTemplate { return f.NewFieldseekerContainerrelateWithContext(context.Background(), mods...) } @@ -249,6 +148,7 @@ func (f *Factory) FromExistingFieldseekerContainerrelate(m *models.FieldseekerCo o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -283,6 +183,7 @@ func (f *Factory) FromExistingFieldseekerFieldscoutinglog(m *models.FieldseekerF o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -320,6 +221,7 @@ func (f *Factory) FromExistingFieldseekerHabitatrelate(m *models.FieldseekerHabi o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -357,6 +259,7 @@ func (f *Factory) FromExistingFieldseekerInspectionsample(m *models.FieldseekerI o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -407,50 +310,7 @@ func (f *Factory) FromExistingFieldseekerInspectionsampledetail(m *models.Fields o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } - - return o -} - -func (f *Factory) NewFieldseekerLandingcount(mods ...FieldseekerLandingcountMod) *FieldseekerLandingcountTemplate { - return f.NewFieldseekerLandingcountWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerLandingcountWithContext(ctx context.Context, mods ...FieldseekerLandingcountMod) *FieldseekerLandingcountTemplate { - o := &FieldseekerLandingcountTemplate{f: f} - - if f != nil { - f.baseFieldseekerLandingcountMods.Apply(ctx, o) - } - - FieldseekerLandingcountModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerLandingcount(m *models.FieldseekerLandingcount) *FieldseekerLandingcountTemplate { - o := &FieldseekerLandingcountTemplate{f: f, alreadyPersisted: true} - - return o -} - -func (f *Factory) NewFieldseekerLandingcountlocation(mods ...FieldseekerLandingcountlocationMod) *FieldseekerLandingcountlocationTemplate { - return f.NewFieldseekerLandingcountlocationWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerLandingcountlocationWithContext(ctx context.Context, mods ...FieldseekerLandingcountlocationMod) *FieldseekerLandingcountlocationTemplate { - o := &FieldseekerLandingcountlocationTemplate{f: f} - - if f != nil { - f.baseFieldseekerLandingcountlocationMods.Apply(ctx, o) - } - - FieldseekerLandingcountlocationModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerLandingcountlocation(m *models.FieldseekerLandingcountlocation) *FieldseekerLandingcountlocationTemplate { - o := &FieldseekerLandingcountlocationTemplate{f: f, alreadyPersisted: true} + o.Version = func() int32 { return m.Version } return o } @@ -528,6 +388,7 @@ func (f *Factory) FromExistingFieldseekerLinelocation(m *models.FieldseekerLinel o.Editor = func() null.Val[string] { return m.Editor } o.Jurisdiction = func() null.Val[string] { return m.Jurisdiction } o.ShapeLength = func() null.Val[float64] { return m.ShapeLength } + o.Version = func() int32 { return m.Version } return o } @@ -563,6 +424,7 @@ func (f *Factory) FromExistingFieldseekerLocationtracking(m *models.FieldseekerL o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -651,6 +513,7 @@ func (f *Factory) FromExistingFieldseekerMosquitoinspection(m *models.Fieldseeke return m.Adminaction } o.Ptaid = func() null.Val[uuid.UUID] { return m.Ptaid } + o.Version = func() int32 { return m.Version } return o } @@ -728,6 +591,7 @@ func (f *Factory) FromExistingFieldseekerPointlocation(m *models.FieldseekerPoin } o.Scalarpriority = func() null.Val[int32] { return m.Scalarpriority } o.Sourcestatus = func() null.Val[string] { return m.Sourcestatus } + o.Version = func() int32 { return m.Version } return o } @@ -799,6 +663,7 @@ func (f *Factory) FromExistingFieldseekerPolygonlocation(m *models.FieldseekerPo o.Jurisdiction = func() null.Val[string] { return m.Jurisdiction } o.ShapeArea = func() null.Val[float64] { return m.ShapeArea } o.ShapeLength = func() null.Val[float64] { return m.ShapeLength } + o.Version = func() int32 { return m.Version } return o } @@ -856,28 +721,7 @@ func (f *Factory) FromExistingFieldseekerPool(m *models.FieldseekerPool) *Fields o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } - - return o -} - -func (f *Factory) NewFieldseekerPoolbuffer(mods ...FieldseekerPoolbufferMod) *FieldseekerPoolbufferTemplate { - return f.NewFieldseekerPoolbufferWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerPoolbufferWithContext(ctx context.Context, mods ...FieldseekerPoolbufferMod) *FieldseekerPoolbufferTemplate { - o := &FieldseekerPoolbufferTemplate{f: f} - - if f != nil { - f.baseFieldseekerPoolbufferMods.Apply(ctx, o) - } - - FieldseekerPoolbufferModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerPoolbuffer(m *models.FieldseekerPoolbuffer) *FieldseekerPoolbufferTemplate { - o := &FieldseekerPoolbufferTemplate{f: f, alreadyPersisted: true} + o.Version = func() int32 { return m.Version } return o } @@ -915,6 +759,7 @@ func (f *Factory) FromExistingFieldseekerPooldetail(m *models.FieldseekerPooldet o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -971,28 +816,7 @@ func (f *Factory) FromExistingFieldseekerProposedtreatmentarea(m *models.Fieldse o.Targetspecies = func() null.Val[string] { return m.Targetspecies } o.ShapeArea = func() null.Val[float64] { return m.ShapeArea } o.ShapeLength = func() null.Val[float64] { return m.ShapeLength } - - return o -} - -func (f *Factory) NewFieldseekerQalarvcount(mods ...FieldseekerQalarvcountMod) *FieldseekerQalarvcountTemplate { - return f.NewFieldseekerQalarvcountWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerQalarvcountWithContext(ctx context.Context, mods ...FieldseekerQalarvcountMod) *FieldseekerQalarvcountTemplate { - o := &FieldseekerQalarvcountTemplate{f: f} - - if f != nil { - f.baseFieldseekerQalarvcountMods.Apply(ctx, o) - } - - FieldseekerQalarvcountModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerQalarvcount(m *models.FieldseekerQalarvcount) *FieldseekerQalarvcountTemplate { - o := &FieldseekerQalarvcountTemplate{f: f, alreadyPersisted: true} + o.Version = func() int32 { return m.Version } return o } @@ -1082,72 +906,7 @@ func (f *Factory) FromExistingFieldseekerQamosquitoinspection(m *models.Fieldsee o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } - - return o -} - -func (f *Factory) NewFieldseekerQaproductobservation(mods ...FieldseekerQaproductobservationMod) *FieldseekerQaproductobservationTemplate { - return f.NewFieldseekerQaproductobservationWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerQaproductobservationWithContext(ctx context.Context, mods ...FieldseekerQaproductobservationMod) *FieldseekerQaproductobservationTemplate { - o := &FieldseekerQaproductobservationTemplate{f: f} - - if f != nil { - f.baseFieldseekerQaproductobservationMods.Apply(ctx, o) - } - - FieldseekerQaproductobservationModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerQaproductobservation(m *models.FieldseekerQaproductobservation) *FieldseekerQaproductobservationTemplate { - o := &FieldseekerQaproductobservationTemplate{f: f, alreadyPersisted: true} - - return o -} - -func (f *Factory) NewFieldseekerRestrictedarea(mods ...FieldseekerRestrictedareaMod) *FieldseekerRestrictedareaTemplate { - return f.NewFieldseekerRestrictedareaWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerRestrictedareaWithContext(ctx context.Context, mods ...FieldseekerRestrictedareaMod) *FieldseekerRestrictedareaTemplate { - o := &FieldseekerRestrictedareaTemplate{f: f} - - if f != nil { - f.baseFieldseekerRestrictedareaMods.Apply(ctx, o) - } - - FieldseekerRestrictedareaModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerRestrictedarea(m *models.FieldseekerRestrictedarea) *FieldseekerRestrictedareaTemplate { - o := &FieldseekerRestrictedareaTemplate{f: f, alreadyPersisted: true} - - return o -} - -func (f *Factory) NewFieldseekerRodentinspection(mods ...FieldseekerRodentinspectionMod) *FieldseekerRodentinspectionTemplate { - return f.NewFieldseekerRodentinspectionWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerRodentinspectionWithContext(ctx context.Context, mods ...FieldseekerRodentinspectionMod) *FieldseekerRodentinspectionTemplate { - o := &FieldseekerRodentinspectionTemplate{f: f} - - if f != nil { - f.baseFieldseekerRodentinspectionMods.Apply(ctx, o) - } - - FieldseekerRodentinspectionModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerRodentinspection(m *models.FieldseekerRodentinspection) *FieldseekerRodentinspectionTemplate { - o := &FieldseekerRodentinspectionTemplate{f: f, alreadyPersisted: true} + o.Version = func() int32 { return m.Version } return o } @@ -1171,7 +930,6 @@ func (f *Factory) NewFieldseekerRodentlocationWithContext(ctx context.Context, m func (f *Factory) FromExistingFieldseekerRodentlocation(m *models.FieldseekerRodentlocation) *FieldseekerRodentlocationTemplate { o := &FieldseekerRodentlocationTemplate{f: f, alreadyPersisted: true} - o.OrganizationID = func() int32 { return m.OrganizationID } o.Objectid = func() int64 { return m.Objectid } o.Locationname = func() null.Val[string] { return m.Locationname } o.Zone = func() null.Val[string] { return m.Zone } @@ -1202,11 +960,7 @@ func (f *Factory) FromExistingFieldseekerRodentlocation(m *models.FieldseekerRod o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } o.Jurisdiction = func() null.Val[string] { return m.Jurisdiction } - - ctx := context.Background() - if m.R.Organization != nil { - FieldseekerRodentlocationMods.WithExistingOrganization(m.R.Organization).Apply(ctx, o) - } + o.Version = func() int32 { return m.Version } return o } @@ -1276,6 +1030,7 @@ func (f *Factory) FromExistingFieldseekerSamplecollection(m *models.FieldseekerS o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -1323,6 +1078,7 @@ func (f *Factory) FromExistingFieldseekerSamplelocation(m *models.FieldseekerSam o.Creator = func() null.Val[string] { return m.Creator } o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } + o.Version = func() int32 { return m.Version } return o } @@ -1446,6 +1202,7 @@ func (f *Factory) FromExistingFieldseekerServicerequest(m *models.FieldseekerSer o.Notificationtimestamp = func() null.Val[string] { return m.Notificationtimestamp } o.Zone = func() null.Val[string] { return m.Zone } o.Zone2 = func() null.Val[string] { return m.Zone2 } + o.Version = func() int32 { return m.Version } return o } @@ -1498,6 +1255,7 @@ func (f *Factory) FromExistingFieldseekerSpeciesabundance(m *models.FieldseekerS o.R8score = func() null.Val[float64] { return m.R8score } o.H3R7 = func() null.Val[string] { return m.H3R7 } o.H3R8 = func() null.Val[string] { return m.H3R8 } + o.Version = func() int32 { return m.Version } return o } @@ -1540,6 +1298,7 @@ func (f *Factory) FromExistingFieldseekerStormdrain(m *models.FieldseekerStormdr o.Editor = func() null.Val[string] { return m.Editor } o.Type = func() null.Val[string] { return m.Type } o.Jurisdiction = func() null.Val[string] { return m.Jurisdiction } + o.Version = func() int32 { return m.Version } return o } @@ -1593,28 +1352,7 @@ func (f *Factory) FromExistingFieldseekerTimecard(m *models.FieldseekerTimecard) o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } o.Rodentlocid = func() null.Val[uuid.UUID] { return m.Rodentlocid } - - return o -} - -func (f *Factory) NewFieldseekerTracklog(mods ...FieldseekerTracklogMod) *FieldseekerTracklogTemplate { - return f.NewFieldseekerTracklogWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerTracklogWithContext(ctx context.Context, mods ...FieldseekerTracklogMod) *FieldseekerTracklogTemplate { - o := &FieldseekerTracklogTemplate{f: f} - - if f != nil { - f.baseFieldseekerTracklogMods.Apply(ctx, o) - } - - FieldseekerTracklogModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerTracklog(m *models.FieldseekerTracklog) *FieldseekerTracklogTemplate { - o := &FieldseekerTracklogTemplate{f: f, alreadyPersisted: true} + o.Version = func() int32 { return m.Version } return o } @@ -1684,6 +1422,7 @@ func (f *Factory) FromExistingFieldseekerTrapdatum(m *models.FieldseekerTrapdatu o.Lure = func() null.Val[enums.FieldseekerTrapdataTrapdataLure25fe542f077F4254868176e8f436354bEnu] { return m.Lure } + o.Version = func() int32 { return m.Version } return o } @@ -1745,6 +1484,7 @@ func (f *Factory) FromExistingFieldseekerTraplocation(m *models.FieldseekerTrapl o.Editor = func() null.Val[string] { return m.Editor } o.H3R7 = func() null.Val[string] { return m.H3R7 } o.H3R8 = func() null.Val[string] { return m.H3R8 } + o.Version = func() int32 { return m.Version } return o } @@ -1832,6 +1572,7 @@ func (f *Factory) FromExistingFieldseekerTreatment(m *models.FieldseekerTreatmen o.Editdate = func() null.Val[time.Time] { return m.Editdate } o.Editor = func() null.Val[string] { return m.Editor } o.Targetspecies = func() null.Val[string] { return m.Targetspecies } + o.Version = func() int32 { return m.Version } return o } @@ -1873,28 +1614,7 @@ func (f *Factory) FromExistingFieldseekerTreatmentarea(m *models.FieldseekerTrea o.Editor = func() null.Val[string] { return m.Editor } o.ShapeArea = func() null.Val[float64] { return m.ShapeArea } o.ShapeLength = func() null.Val[float64] { return m.ShapeLength } - - return o -} - -func (f *Factory) NewFieldseekerUlvsprayroute(mods ...FieldseekerUlvsprayrouteMod) *FieldseekerUlvsprayrouteTemplate { - return f.NewFieldseekerUlvsprayrouteWithContext(context.Background(), mods...) -} - -func (f *Factory) NewFieldseekerUlvsprayrouteWithContext(ctx context.Context, mods ...FieldseekerUlvsprayrouteMod) *FieldseekerUlvsprayrouteTemplate { - o := &FieldseekerUlvsprayrouteTemplate{f: f} - - if f != nil { - f.baseFieldseekerUlvsprayrouteMods.Apply(ctx, o) - } - - FieldseekerUlvsprayrouteModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingFieldseekerUlvsprayroute(m *models.FieldseekerUlvsprayroute) *FieldseekerUlvsprayrouteTemplate { - o := &FieldseekerUlvsprayrouteTemplate{f: f, alreadyPersisted: true} + o.Version = func() int32 { return m.Version } return o } @@ -1932,6 +1652,7 @@ func (f *Factory) FromExistingFieldseekerZone(m *models.FieldseekerZone) *Fields o.Editor = func() null.Val[string] { return m.Editor } o.ShapeArea = func() null.Val[float64] { return m.ShapeArea } o.ShapeLength = func() null.Val[float64] { return m.ShapeLength } + o.Version = func() int32 { return m.Version } return o } @@ -1968,6 +1689,7 @@ func (f *Factory) FromExistingFieldseekerZones2(m *models.FieldseekerZones2) *Fi o.Editor = func() null.Val[string] { return m.Editor } o.ShapeArea = func() null.Val[float64] { return m.ShapeArea } o.ShapeLength = func() null.Val[float64] { return m.ShapeLength } + o.Version = func() int32 { return m.Version } return o } @@ -5684,9 +5406,6 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization o.FieldseekerURL = func() null.Val[string] { return m.FieldseekerURL } ctx := context.Background() - if len(m.R.Rodentlocations) > 0 { - OrganizationMods.AddExistingRodentlocations(m.R.Rodentlocations...).Apply(ctx, o) - } if len(m.R.FieldseekerSyncs) > 0 { OrganizationMods.AddExistingFieldseekerSyncs(m.R.FieldseekerSyncs...).Apply(ctx, o) } @@ -6034,38 +5753,6 @@ func (f *Factory) FromExistingUser(m *models.User) *UserTemplate { return o } -func (f *Factory) ClearBaseFieldseekerAerialspraylineMods() { - f.baseFieldseekerAerialspraylineMods = nil -} - -func (f *Factory) AddBaseFieldseekerAerialspraylineMod(mods ...FieldseekerAerialspraylineMod) { - f.baseFieldseekerAerialspraylineMods = append(f.baseFieldseekerAerialspraylineMods, mods...) -} - -func (f *Factory) ClearBaseFieldseekerAerialspraysessionMods() { - f.baseFieldseekerAerialspraysessionMods = nil -} - -func (f *Factory) AddBaseFieldseekerAerialspraysessionMod(mods ...FieldseekerAerialspraysessionMod) { - f.baseFieldseekerAerialspraysessionMods = append(f.baseFieldseekerAerialspraysessionMods, mods...) -} - -func (f *Factory) ClearBaseFieldseekerBarriersprayMods() { - f.baseFieldseekerBarriersprayMods = nil -} - -func (f *Factory) AddBaseFieldseekerBarriersprayMod(mods ...FieldseekerBarriersprayMod) { - f.baseFieldseekerBarriersprayMods = append(f.baseFieldseekerBarriersprayMods, mods...) -} - -func (f *Factory) ClearBaseFieldseekerBarriersprayrouteMods() { - f.baseFieldseekerBarriersprayrouteMods = nil -} - -func (f *Factory) AddBaseFieldseekerBarriersprayrouteMod(mods ...FieldseekerBarriersprayrouteMod) { - f.baseFieldseekerBarriersprayrouteMods = append(f.baseFieldseekerBarriersprayrouteMods, mods...) -} - func (f *Factory) ClearBaseFieldseekerContainerrelateMods() { f.baseFieldseekerContainerrelateMods = nil } @@ -6106,22 +5793,6 @@ func (f *Factory) AddBaseFieldseekerInspectionsampledetailMod(mods ...Fieldseeke f.baseFieldseekerInspectionsampledetailMods = append(f.baseFieldseekerInspectionsampledetailMods, mods...) } -func (f *Factory) ClearBaseFieldseekerLandingcountMods() { - f.baseFieldseekerLandingcountMods = nil -} - -func (f *Factory) AddBaseFieldseekerLandingcountMod(mods ...FieldseekerLandingcountMod) { - f.baseFieldseekerLandingcountMods = append(f.baseFieldseekerLandingcountMods, mods...) -} - -func (f *Factory) ClearBaseFieldseekerLandingcountlocationMods() { - f.baseFieldseekerLandingcountlocationMods = nil -} - -func (f *Factory) AddBaseFieldseekerLandingcountlocationMod(mods ...FieldseekerLandingcountlocationMod) { - f.baseFieldseekerLandingcountlocationMods = append(f.baseFieldseekerLandingcountlocationMods, mods...) -} - func (f *Factory) ClearBaseFieldseekerLinelocationMods() { f.baseFieldseekerLinelocationMods = nil } @@ -6170,14 +5841,6 @@ func (f *Factory) AddBaseFieldseekerPoolMod(mods ...FieldseekerPoolMod) { f.baseFieldseekerPoolMods = append(f.baseFieldseekerPoolMods, mods...) } -func (f *Factory) ClearBaseFieldseekerPoolbufferMods() { - f.baseFieldseekerPoolbufferMods = nil -} - -func (f *Factory) AddBaseFieldseekerPoolbufferMod(mods ...FieldseekerPoolbufferMod) { - f.baseFieldseekerPoolbufferMods = append(f.baseFieldseekerPoolbufferMods, mods...) -} - func (f *Factory) ClearBaseFieldseekerPooldetailMods() { f.baseFieldseekerPooldetailMods = nil } @@ -6194,14 +5857,6 @@ func (f *Factory) AddBaseFieldseekerProposedtreatmentareaMod(mods ...Fieldseeker f.baseFieldseekerProposedtreatmentareaMods = append(f.baseFieldseekerProposedtreatmentareaMods, mods...) } -func (f *Factory) ClearBaseFieldseekerQalarvcountMods() { - f.baseFieldseekerQalarvcountMods = nil -} - -func (f *Factory) AddBaseFieldseekerQalarvcountMod(mods ...FieldseekerQalarvcountMod) { - f.baseFieldseekerQalarvcountMods = append(f.baseFieldseekerQalarvcountMods, mods...) -} - func (f *Factory) ClearBaseFieldseekerQamosquitoinspectionMods() { f.baseFieldseekerQamosquitoinspectionMods = nil } @@ -6210,30 +5865,6 @@ func (f *Factory) AddBaseFieldseekerQamosquitoinspectionMod(mods ...FieldseekerQ f.baseFieldseekerQamosquitoinspectionMods = append(f.baseFieldseekerQamosquitoinspectionMods, mods...) } -func (f *Factory) ClearBaseFieldseekerQaproductobservationMods() { - f.baseFieldseekerQaproductobservationMods = nil -} - -func (f *Factory) AddBaseFieldseekerQaproductobservationMod(mods ...FieldseekerQaproductobservationMod) { - f.baseFieldseekerQaproductobservationMods = append(f.baseFieldseekerQaproductobservationMods, mods...) -} - -func (f *Factory) ClearBaseFieldseekerRestrictedareaMods() { - f.baseFieldseekerRestrictedareaMods = nil -} - -func (f *Factory) AddBaseFieldseekerRestrictedareaMod(mods ...FieldseekerRestrictedareaMod) { - f.baseFieldseekerRestrictedareaMods = append(f.baseFieldseekerRestrictedareaMods, mods...) -} - -func (f *Factory) ClearBaseFieldseekerRodentinspectionMods() { - f.baseFieldseekerRodentinspectionMods = nil -} - -func (f *Factory) AddBaseFieldseekerRodentinspectionMod(mods ...FieldseekerRodentinspectionMod) { - f.baseFieldseekerRodentinspectionMods = append(f.baseFieldseekerRodentinspectionMods, mods...) -} - func (f *Factory) ClearBaseFieldseekerRodentlocationMods() { f.baseFieldseekerRodentlocationMods = nil } @@ -6290,14 +5921,6 @@ func (f *Factory) AddBaseFieldseekerTimecardMod(mods ...FieldseekerTimecardMod) f.baseFieldseekerTimecardMods = append(f.baseFieldseekerTimecardMods, mods...) } -func (f *Factory) ClearBaseFieldseekerTracklogMods() { - f.baseFieldseekerTracklogMods = nil -} - -func (f *Factory) AddBaseFieldseekerTracklogMod(mods ...FieldseekerTracklogMod) { - f.baseFieldseekerTracklogMods = append(f.baseFieldseekerTracklogMods, mods...) -} - func (f *Factory) ClearBaseFieldseekerTrapdatumMods() { f.baseFieldseekerTrapdatumMods = nil } @@ -6330,14 +5953,6 @@ func (f *Factory) AddBaseFieldseekerTreatmentareaMod(mods ...FieldseekerTreatmen f.baseFieldseekerTreatmentareaMods = append(f.baseFieldseekerTreatmentareaMods, mods...) } -func (f *Factory) ClearBaseFieldseekerUlvsprayrouteMods() { - f.baseFieldseekerUlvsprayrouteMods = nil -} - -func (f *Factory) AddBaseFieldseekerUlvsprayrouteMod(mods ...FieldseekerUlvsprayrouteMod) { - f.baseFieldseekerUlvsprayrouteMods = append(f.baseFieldseekerUlvsprayrouteMods, mods...) -} - func (f *Factory) ClearBaseFieldseekerZoneMods() { f.baseFieldseekerZoneMods = nil } diff --git a/db/factory/bobfactory_main.bob_test.go b/db/factory/bobfactory_main.bob_test.go index 54d3ae28..c1b37ac1 100644 --- a/db/factory/bobfactory_main.bob_test.go +++ b/db/factory/bobfactory_main.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/bobfactory_random.bob.go b/db/factory/bobfactory_random.bob.go index 214553a0..780e2fa0 100644 --- a/db/factory/bobfactory_random.bob.go +++ b/db/factory/bobfactory_random.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/bobfactory_random.bob_test.go b/db/factory/bobfactory_random.bob_test.go index 4d555f0e..6f602ab7 100644 --- a/db/factory/bobfactory_random.bob_test.go +++ b/db/factory/bobfactory_random.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.aerialsprayline.bob.go b/db/factory/fieldseeker.aerialsprayline.bob.go deleted file mode 100644 index 591d312e..00000000 --- a/db/factory/fieldseeker.aerialsprayline.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerAerialspraylineMod interface { - Apply(context.Context, *FieldseekerAerialspraylineTemplate) -} - -type FieldseekerAerialspraylineModFunc func(context.Context, *FieldseekerAerialspraylineTemplate) - -func (f FieldseekerAerialspraylineModFunc) Apply(ctx context.Context, n *FieldseekerAerialspraylineTemplate) { - f(ctx, n) -} - -type FieldseekerAerialspraylineModSlice []FieldseekerAerialspraylineMod - -func (mods FieldseekerAerialspraylineModSlice) Apply(ctx context.Context, n *FieldseekerAerialspraylineTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerAerialspraylineTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerAerialspraylineTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerAerialspraylineTemplate -func (o *FieldseekerAerialspraylineTemplate) Apply(ctx context.Context, mods ...FieldseekerAerialspraylineMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerAerialsprayline -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerAerialspraylineTemplate) setModelRels(o *models.FieldseekerAerialsprayline) {} - -// Build returns an *models.FieldseekerAerialsprayline -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerAerialspraylineTemplate.Create -func (o FieldseekerAerialspraylineTemplate) Build() *models.FieldseekerAerialsprayline { - m := &models.FieldseekerAerialsprayline{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerAerialspraylineSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerAerialspraylineTemplate.CreateMany -func (o FieldseekerAerialspraylineTemplate) BuildMany(number int) models.FieldseekerAerialspraylineSlice { - m := make(models.FieldseekerAerialspraylineSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerAerialsprayline has methods that act as mods for the FieldseekerAerialspraylineTemplate -var FieldseekerAerialspraylineMods fieldseekerAerialspraylineMods - -type fieldseekerAerialspraylineMods struct{} - -func (m fieldseekerAerialspraylineMods) RandomizeAllColumns(f *faker.Faker) FieldseekerAerialspraylineMod { - return FieldseekerAerialspraylineModSlice{} -} - -func (m fieldseekerAerialspraylineMods) WithParentsCascading() FieldseekerAerialspraylineMod { - return FieldseekerAerialspraylineModFunc(func(ctx context.Context, o *FieldseekerAerialspraylineTemplate) { - if isDone, _ := fieldseekerAerialspraylineWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerAerialspraylineWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.aerialspraysession.bob.go b/db/factory/fieldseeker.aerialspraysession.bob.go deleted file mode 100644 index 609838f6..00000000 --- a/db/factory/fieldseeker.aerialspraysession.bob.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerAerialspraysessionMod interface { - Apply(context.Context, *FieldseekerAerialspraysessionTemplate) -} - -type FieldseekerAerialspraysessionModFunc func(context.Context, *FieldseekerAerialspraysessionTemplate) - -func (f FieldseekerAerialspraysessionModFunc) Apply(ctx context.Context, n *FieldseekerAerialspraysessionTemplate) { - f(ctx, n) -} - -type FieldseekerAerialspraysessionModSlice []FieldseekerAerialspraysessionMod - -func (mods FieldseekerAerialspraysessionModSlice) Apply(ctx context.Context, n *FieldseekerAerialspraysessionTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerAerialspraysessionTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerAerialspraysessionTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerAerialspraysessionTemplate -func (o *FieldseekerAerialspraysessionTemplate) Apply(ctx context.Context, mods ...FieldseekerAerialspraysessionMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerAerialspraysession -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerAerialspraysessionTemplate) setModelRels(o *models.FieldseekerAerialspraysession) { -} - -// Build returns an *models.FieldseekerAerialspraysession -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerAerialspraysessionTemplate.Create -func (o FieldseekerAerialspraysessionTemplate) Build() *models.FieldseekerAerialspraysession { - m := &models.FieldseekerAerialspraysession{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerAerialspraysessionSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerAerialspraysessionTemplate.CreateMany -func (o FieldseekerAerialspraysessionTemplate) BuildMany(number int) models.FieldseekerAerialspraysessionSlice { - m := make(models.FieldseekerAerialspraysessionSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerAerialspraysession has methods that act as mods for the FieldseekerAerialspraysessionTemplate -var FieldseekerAerialspraysessionMods fieldseekerAerialspraysessionMods - -type fieldseekerAerialspraysessionMods struct{} - -func (m fieldseekerAerialspraysessionMods) RandomizeAllColumns(f *faker.Faker) FieldseekerAerialspraysessionMod { - return FieldseekerAerialspraysessionModSlice{} -} - -func (m fieldseekerAerialspraysessionMods) WithParentsCascading() FieldseekerAerialspraysessionMod { - return FieldseekerAerialspraysessionModFunc(func(ctx context.Context, o *FieldseekerAerialspraysessionTemplate) { - if isDone, _ := fieldseekerAerialspraysessionWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerAerialspraysessionWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.barrierspray.bob.go b/db/factory/fieldseeker.barrierspray.bob.go deleted file mode 100644 index 2d595a8e..00000000 --- a/db/factory/fieldseeker.barrierspray.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerBarriersprayMod interface { - Apply(context.Context, *FieldseekerBarriersprayTemplate) -} - -type FieldseekerBarriersprayModFunc func(context.Context, *FieldseekerBarriersprayTemplate) - -func (f FieldseekerBarriersprayModFunc) Apply(ctx context.Context, n *FieldseekerBarriersprayTemplate) { - f(ctx, n) -} - -type FieldseekerBarriersprayModSlice []FieldseekerBarriersprayMod - -func (mods FieldseekerBarriersprayModSlice) Apply(ctx context.Context, n *FieldseekerBarriersprayTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerBarriersprayTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerBarriersprayTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerBarriersprayTemplate -func (o *FieldseekerBarriersprayTemplate) Apply(ctx context.Context, mods ...FieldseekerBarriersprayMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerBarrierspray -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerBarriersprayTemplate) setModelRels(o *models.FieldseekerBarrierspray) {} - -// Build returns an *models.FieldseekerBarrierspray -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerBarriersprayTemplate.Create -func (o FieldseekerBarriersprayTemplate) Build() *models.FieldseekerBarrierspray { - m := &models.FieldseekerBarrierspray{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerBarrierspraySlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerBarriersprayTemplate.CreateMany -func (o FieldseekerBarriersprayTemplate) BuildMany(number int) models.FieldseekerBarrierspraySlice { - m := make(models.FieldseekerBarrierspraySlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerBarrierspray has methods that act as mods for the FieldseekerBarriersprayTemplate -var FieldseekerBarriersprayMods fieldseekerBarriersprayMods - -type fieldseekerBarriersprayMods struct{} - -func (m fieldseekerBarriersprayMods) RandomizeAllColumns(f *faker.Faker) FieldseekerBarriersprayMod { - return FieldseekerBarriersprayModSlice{} -} - -func (m fieldseekerBarriersprayMods) WithParentsCascading() FieldseekerBarriersprayMod { - return FieldseekerBarriersprayModFunc(func(ctx context.Context, o *FieldseekerBarriersprayTemplate) { - if isDone, _ := fieldseekerBarriersprayWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerBarriersprayWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.barriersprayroute.bob.go b/db/factory/fieldseeker.barriersprayroute.bob.go deleted file mode 100644 index 183199c3..00000000 --- a/db/factory/fieldseeker.barriersprayroute.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerBarriersprayrouteMod interface { - Apply(context.Context, *FieldseekerBarriersprayrouteTemplate) -} - -type FieldseekerBarriersprayrouteModFunc func(context.Context, *FieldseekerBarriersprayrouteTemplate) - -func (f FieldseekerBarriersprayrouteModFunc) Apply(ctx context.Context, n *FieldseekerBarriersprayrouteTemplate) { - f(ctx, n) -} - -type FieldseekerBarriersprayrouteModSlice []FieldseekerBarriersprayrouteMod - -func (mods FieldseekerBarriersprayrouteModSlice) Apply(ctx context.Context, n *FieldseekerBarriersprayrouteTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerBarriersprayrouteTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerBarriersprayrouteTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerBarriersprayrouteTemplate -func (o *FieldseekerBarriersprayrouteTemplate) Apply(ctx context.Context, mods ...FieldseekerBarriersprayrouteMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerBarriersprayroute -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerBarriersprayrouteTemplate) setModelRels(o *models.FieldseekerBarriersprayroute) {} - -// Build returns an *models.FieldseekerBarriersprayroute -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerBarriersprayrouteTemplate.Create -func (o FieldseekerBarriersprayrouteTemplate) Build() *models.FieldseekerBarriersprayroute { - m := &models.FieldseekerBarriersprayroute{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerBarriersprayrouteSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerBarriersprayrouteTemplate.CreateMany -func (o FieldseekerBarriersprayrouteTemplate) BuildMany(number int) models.FieldseekerBarriersprayrouteSlice { - m := make(models.FieldseekerBarriersprayrouteSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerBarriersprayroute has methods that act as mods for the FieldseekerBarriersprayrouteTemplate -var FieldseekerBarriersprayrouteMods fieldseekerBarriersprayrouteMods - -type fieldseekerBarriersprayrouteMods struct{} - -func (m fieldseekerBarriersprayrouteMods) RandomizeAllColumns(f *faker.Faker) FieldseekerBarriersprayrouteMod { - return FieldseekerBarriersprayrouteModSlice{} -} - -func (m fieldseekerBarriersprayrouteMods) WithParentsCascading() FieldseekerBarriersprayrouteMod { - return FieldseekerBarriersprayrouteModFunc(func(ctx context.Context, o *FieldseekerBarriersprayrouteTemplate) { - if isDone, _ := fieldseekerBarriersprayrouteWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerBarriersprayrouteWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.containerrelate.bob.go b/db/factory/fieldseeker.containerrelate.bob.go index f32d9186..d15d8601 100644 --- a/db/factory/fieldseeker.containerrelate.bob.go +++ b/db/factory/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -53,6 +53,7 @@ type FieldseekerContainerrelateTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -131,6 +132,10 @@ func (o FieldseekerContainerrelateTemplate) BuildSetter() *models.FieldseekerCon val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -195,6 +200,9 @@ func (o FieldseekerContainerrelateTemplate) Build() *models.FieldseekerContainer if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -329,6 +337,7 @@ func (m fieldseekerContainerrelateMods) RandomizeAllColumns(f *faker.Faker) Fiel FieldseekerContainerrelateMods.RandomCreator(f), FieldseekerContainerrelateMods.RandomEditdate(f), FieldseekerContainerrelateMods.RandomEditor(f), + FieldseekerContainerrelateMods.RandomVersion(f), } } @@ -1052,6 +1061,37 @@ func (m fieldseekerContainerrelateMods) RandomEditorNotNull(f *faker.Faker) Fiel }) } +// Set the model columns to this value +func (m fieldseekerContainerrelateMods) Version(val int32) FieldseekerContainerrelateMod { + return FieldseekerContainerrelateModFunc(func(_ context.Context, o *FieldseekerContainerrelateTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerContainerrelateMods) VersionFunc(f func() int32) FieldseekerContainerrelateMod { + return FieldseekerContainerrelateModFunc(func(_ context.Context, o *FieldseekerContainerrelateTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerContainerrelateMods) UnsetVersion() FieldseekerContainerrelateMod { + return FieldseekerContainerrelateModFunc(func(_ context.Context, o *FieldseekerContainerrelateTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerContainerrelateMods) RandomVersion(f *faker.Faker) FieldseekerContainerrelateMod { + return FieldseekerContainerrelateModFunc(func(_ context.Context, o *FieldseekerContainerrelateTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerContainerrelateMods) WithParentsCascading() FieldseekerContainerrelateMod { return FieldseekerContainerrelateModFunc(func(ctx context.Context, o *FieldseekerContainerrelateTemplate) { if isDone, _ := fieldseekerContainerrelateWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.fieldscoutinglog.bob.go b/db/factory/fieldseeker.fieldscoutinglog.bob.go index 05be827d..64283691 100644 --- a/db/factory/fieldseeker.fieldscoutinglog.bob.go +++ b/db/factory/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -50,6 +50,7 @@ type FieldseekerFieldscoutinglogTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -116,6 +117,10 @@ func (o FieldseekerFieldscoutinglogTemplate) BuildSetter() *models.FieldseekerFi val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -171,6 +176,9 @@ func (o FieldseekerFieldscoutinglogTemplate) Build() *models.FieldseekerFieldsco if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -302,6 +310,7 @@ func (m fieldseekerFieldscoutinglogMods) RandomizeAllColumns(f *faker.Faker) Fie FieldseekerFieldscoutinglogMods.RandomCreator(f), FieldseekerFieldscoutinglogMods.RandomEditdate(f), FieldseekerFieldscoutinglogMods.RandomEditor(f), + FieldseekerFieldscoutinglogMods.RandomVersion(f), } } @@ -866,6 +875,37 @@ func (m fieldseekerFieldscoutinglogMods) RandomEditorNotNull(f *faker.Faker) Fie }) } +// Set the model columns to this value +func (m fieldseekerFieldscoutinglogMods) Version(val int32) FieldseekerFieldscoutinglogMod { + return FieldseekerFieldscoutinglogModFunc(func(_ context.Context, o *FieldseekerFieldscoutinglogTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerFieldscoutinglogMods) VersionFunc(f func() int32) FieldseekerFieldscoutinglogMod { + return FieldseekerFieldscoutinglogModFunc(func(_ context.Context, o *FieldseekerFieldscoutinglogTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerFieldscoutinglogMods) UnsetVersion() FieldseekerFieldscoutinglogMod { + return FieldseekerFieldscoutinglogModFunc(func(_ context.Context, o *FieldseekerFieldscoutinglogTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerFieldscoutinglogMods) RandomVersion(f *faker.Faker) FieldseekerFieldscoutinglogMod { + return FieldseekerFieldscoutinglogModFunc(func(_ context.Context, o *FieldseekerFieldscoutinglogTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerFieldscoutinglogMods) WithParentsCascading() FieldseekerFieldscoutinglogMod { return FieldseekerFieldscoutinglogModFunc(func(ctx context.Context, o *FieldseekerFieldscoutinglogTemplate) { if isDone, _ := fieldseekerFieldscoutinglogWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.habitatrelate.bob.go b/db/factory/fieldseeker.habitatrelate.bob.go index 781d7ecd..a33fcbd8 100644 --- a/db/factory/fieldseeker.habitatrelate.bob.go +++ b/db/factory/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -51,6 +51,7 @@ type FieldseekerHabitatrelateTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -121,6 +122,10 @@ func (o FieldseekerHabitatrelateTemplate) BuildSetter() *models.FieldseekerHabit val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -179,6 +184,9 @@ func (o FieldseekerHabitatrelateTemplate) Build() *models.FieldseekerHabitatrela if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -311,6 +319,7 @@ func (m fieldseekerHabitatrelateMods) RandomizeAllColumns(f *faker.Faker) Fields FieldseekerHabitatrelateMods.RandomCreator(f), FieldseekerHabitatrelateMods.RandomEditdate(f), FieldseekerHabitatrelateMods.RandomEditor(f), + FieldseekerHabitatrelateMods.RandomVersion(f), } } @@ -930,6 +939,37 @@ func (m fieldseekerHabitatrelateMods) RandomEditorNotNull(f *faker.Faker) Fields }) } +// Set the model columns to this value +func (m fieldseekerHabitatrelateMods) Version(val int32) FieldseekerHabitatrelateMod { + return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerHabitatrelateMods) VersionFunc(f func() int32) FieldseekerHabitatrelateMod { + return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerHabitatrelateMods) UnsetVersion() FieldseekerHabitatrelateMod { + return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerHabitatrelateMods) RandomVersion(f *faker.Faker) FieldseekerHabitatrelateMod { + return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerHabitatrelateMods) WithParentsCascading() FieldseekerHabitatrelateMod { return FieldseekerHabitatrelateModFunc(func(ctx context.Context, o *FieldseekerHabitatrelateTemplate) { if isDone, _ := fieldseekerHabitatrelateWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.inspectionsample.bob.go b/db/factory/fieldseeker.inspectionsample.bob.go index 7f384371..9788f79f 100644 --- a/db/factory/fieldseeker.inspectionsample.bob.go +++ b/db/factory/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -53,6 +53,7 @@ type FieldseekerInspectionsampleTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -131,6 +132,10 @@ func (o FieldseekerInspectionsampleTemplate) BuildSetter() *models.FieldseekerIn val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -195,6 +200,9 @@ func (o FieldseekerInspectionsampleTemplate) Build() *models.FieldseekerInspecti if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -329,6 +337,7 @@ func (m fieldseekerInspectionsampleMods) RandomizeAllColumns(f *faker.Faker) Fie FieldseekerInspectionsampleMods.RandomCreator(f), FieldseekerInspectionsampleMods.RandomEditdate(f), FieldseekerInspectionsampleMods.RandomEditor(f), + FieldseekerInspectionsampleMods.RandomVersion(f), } } @@ -1052,6 +1061,37 @@ func (m fieldseekerInspectionsampleMods) RandomEditorNotNull(f *faker.Faker) Fie }) } +// Set the model columns to this value +func (m fieldseekerInspectionsampleMods) Version(val int32) FieldseekerInspectionsampleMod { + return FieldseekerInspectionsampleModFunc(func(_ context.Context, o *FieldseekerInspectionsampleTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerInspectionsampleMods) VersionFunc(f func() int32) FieldseekerInspectionsampleMod { + return FieldseekerInspectionsampleModFunc(func(_ context.Context, o *FieldseekerInspectionsampleTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerInspectionsampleMods) UnsetVersion() FieldseekerInspectionsampleMod { + return FieldseekerInspectionsampleModFunc(func(_ context.Context, o *FieldseekerInspectionsampleTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerInspectionsampleMods) RandomVersion(f *faker.Faker) FieldseekerInspectionsampleMod { + return FieldseekerInspectionsampleModFunc(func(_ context.Context, o *FieldseekerInspectionsampleTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerInspectionsampleMods) WithParentsCascading() FieldseekerInspectionsampleMod { return FieldseekerInspectionsampleModFunc(func(ctx context.Context, o *FieldseekerInspectionsampleTemplate) { if isDone, _ := fieldseekerInspectionsampleWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.inspectionsampledetail.bob.go b/db/factory/fieldseeker.inspectionsampledetail.bob.go index 57948659..1eedba3e 100644 --- a/db/factory/fieldseeker.inspectionsampledetail.bob.go +++ b/db/factory/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -64,6 +64,7 @@ type FieldseekerInspectionsampledetailTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -187,6 +188,10 @@ func (o FieldseekerInspectionsampledetailTemplate) BuildSetter() *models.Fieldse val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -284,6 +289,9 @@ func (o FieldseekerInspectionsampledetailTemplate) Build() *models.FieldseekerIn if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -429,6 +437,7 @@ func (m fieldseekerInspectionsampledetailMods) RandomizeAllColumns(f *faker.Fake FieldseekerInspectionsampledetailMods.RandomCreator(f), FieldseekerInspectionsampledetailMods.RandomEditdate(f), FieldseekerInspectionsampledetailMods.RandomEditor(f), + FieldseekerInspectionsampledetailMods.RandomVersion(f), } } @@ -1735,6 +1744,37 @@ func (m fieldseekerInspectionsampledetailMods) RandomEditorNotNull(f *faker.Fake }) } +// Set the model columns to this value +func (m fieldseekerInspectionsampledetailMods) Version(val int32) FieldseekerInspectionsampledetailMod { + return FieldseekerInspectionsampledetailModFunc(func(_ context.Context, o *FieldseekerInspectionsampledetailTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerInspectionsampledetailMods) VersionFunc(f func() int32) FieldseekerInspectionsampledetailMod { + return FieldseekerInspectionsampledetailModFunc(func(_ context.Context, o *FieldseekerInspectionsampledetailTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerInspectionsampledetailMods) UnsetVersion() FieldseekerInspectionsampledetailMod { + return FieldseekerInspectionsampledetailModFunc(func(_ context.Context, o *FieldseekerInspectionsampledetailTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerInspectionsampledetailMods) RandomVersion(f *faker.Faker) FieldseekerInspectionsampledetailMod { + return FieldseekerInspectionsampledetailModFunc(func(_ context.Context, o *FieldseekerInspectionsampledetailTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerInspectionsampledetailMods) WithParentsCascading() FieldseekerInspectionsampledetailMod { return FieldseekerInspectionsampledetailModFunc(func(ctx context.Context, o *FieldseekerInspectionsampledetailTemplate) { if isDone, _ := fieldseekerInspectionsampledetailWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.landingcount.bob.go b/db/factory/fieldseeker.landingcount.bob.go deleted file mode 100644 index cbf8b09f..00000000 --- a/db/factory/fieldseeker.landingcount.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerLandingcountMod interface { - Apply(context.Context, *FieldseekerLandingcountTemplate) -} - -type FieldseekerLandingcountModFunc func(context.Context, *FieldseekerLandingcountTemplate) - -func (f FieldseekerLandingcountModFunc) Apply(ctx context.Context, n *FieldseekerLandingcountTemplate) { - f(ctx, n) -} - -type FieldseekerLandingcountModSlice []FieldseekerLandingcountMod - -func (mods FieldseekerLandingcountModSlice) Apply(ctx context.Context, n *FieldseekerLandingcountTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerLandingcountTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerLandingcountTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerLandingcountTemplate -func (o *FieldseekerLandingcountTemplate) Apply(ctx context.Context, mods ...FieldseekerLandingcountMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerLandingcount -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerLandingcountTemplate) setModelRels(o *models.FieldseekerLandingcount) {} - -// Build returns an *models.FieldseekerLandingcount -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerLandingcountTemplate.Create -func (o FieldseekerLandingcountTemplate) Build() *models.FieldseekerLandingcount { - m := &models.FieldseekerLandingcount{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerLandingcountSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerLandingcountTemplate.CreateMany -func (o FieldseekerLandingcountTemplate) BuildMany(number int) models.FieldseekerLandingcountSlice { - m := make(models.FieldseekerLandingcountSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerLandingcount has methods that act as mods for the FieldseekerLandingcountTemplate -var FieldseekerLandingcountMods fieldseekerLandingcountMods - -type fieldseekerLandingcountMods struct{} - -func (m fieldseekerLandingcountMods) RandomizeAllColumns(f *faker.Faker) FieldseekerLandingcountMod { - return FieldseekerLandingcountModSlice{} -} - -func (m fieldseekerLandingcountMods) WithParentsCascading() FieldseekerLandingcountMod { - return FieldseekerLandingcountModFunc(func(ctx context.Context, o *FieldseekerLandingcountTemplate) { - if isDone, _ := fieldseekerLandingcountWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerLandingcountWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.landingcountlocation.bob.go b/db/factory/fieldseeker.landingcountlocation.bob.go deleted file mode 100644 index e69f3146..00000000 --- a/db/factory/fieldseeker.landingcountlocation.bob.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerLandingcountlocationMod interface { - Apply(context.Context, *FieldseekerLandingcountlocationTemplate) -} - -type FieldseekerLandingcountlocationModFunc func(context.Context, *FieldseekerLandingcountlocationTemplate) - -func (f FieldseekerLandingcountlocationModFunc) Apply(ctx context.Context, n *FieldseekerLandingcountlocationTemplate) { - f(ctx, n) -} - -type FieldseekerLandingcountlocationModSlice []FieldseekerLandingcountlocationMod - -func (mods FieldseekerLandingcountlocationModSlice) Apply(ctx context.Context, n *FieldseekerLandingcountlocationTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerLandingcountlocationTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerLandingcountlocationTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerLandingcountlocationTemplate -func (o *FieldseekerLandingcountlocationTemplate) Apply(ctx context.Context, mods ...FieldseekerLandingcountlocationMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerLandingcountlocation -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerLandingcountlocationTemplate) setModelRels(o *models.FieldseekerLandingcountlocation) { -} - -// Build returns an *models.FieldseekerLandingcountlocation -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerLandingcountlocationTemplate.Create -func (o FieldseekerLandingcountlocationTemplate) Build() *models.FieldseekerLandingcountlocation { - m := &models.FieldseekerLandingcountlocation{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerLandingcountlocationSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerLandingcountlocationTemplate.CreateMany -func (o FieldseekerLandingcountlocationTemplate) BuildMany(number int) models.FieldseekerLandingcountlocationSlice { - m := make(models.FieldseekerLandingcountlocationSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerLandingcountlocation has methods that act as mods for the FieldseekerLandingcountlocationTemplate -var FieldseekerLandingcountlocationMods fieldseekerLandingcountlocationMods - -type fieldseekerLandingcountlocationMods struct{} - -func (m fieldseekerLandingcountlocationMods) RandomizeAllColumns(f *faker.Faker) FieldseekerLandingcountlocationMod { - return FieldseekerLandingcountlocationModSlice{} -} - -func (m fieldseekerLandingcountlocationMods) WithParentsCascading() FieldseekerLandingcountlocationMod { - return FieldseekerLandingcountlocationModFunc(func(ctx context.Context, o *FieldseekerLandingcountlocationTemplate) { - if isDone, _ := fieldseekerLandingcountlocationWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerLandingcountlocationWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.linelocation.bob.go b/db/factory/fieldseeker.linelocation.bob.go index fd2fd5f0..a2f9461f 100644 --- a/db/factory/fieldseeker.linelocation.bob.go +++ b/db/factory/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -87,6 +87,7 @@ type FieldseekerLinelocationTemplate struct { Editor func() null.Val[string] Jurisdiction func() null.Val[string] ShapeLength func() null.Val[float64] + Version func() int32 f *Factory @@ -301,6 +302,10 @@ func (o FieldseekerLinelocationTemplate) BuildSetter() *models.FieldseekerLinelo val := o.ShapeLength() m.ShapeLength = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -467,6 +472,9 @@ func (o FieldseekerLinelocationTemplate) Build() *models.FieldseekerLinelocation if o.ShapeLength != nil { m.ShapeLength = o.ShapeLength() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -635,6 +643,7 @@ func (m fieldseekerLinelocationMods) RandomizeAllColumns(f *faker.Faker) Fieldse FieldseekerLinelocationMods.RandomEditor(f), FieldseekerLinelocationMods.RandomJurisdiction(f), FieldseekerLinelocationMods.RandomShapeLength(f), + FieldseekerLinelocationMods.RandomVersion(f), } } @@ -3164,6 +3173,37 @@ func (m fieldseekerLinelocationMods) RandomShapeLengthNotNull(f *faker.Faker) Fi }) } +// Set the model columns to this value +func (m fieldseekerLinelocationMods) Version(val int32) FieldseekerLinelocationMod { + return FieldseekerLinelocationModFunc(func(_ context.Context, o *FieldseekerLinelocationTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerLinelocationMods) VersionFunc(f func() int32) FieldseekerLinelocationMod { + return FieldseekerLinelocationModFunc(func(_ context.Context, o *FieldseekerLinelocationTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerLinelocationMods) UnsetVersion() FieldseekerLinelocationMod { + return FieldseekerLinelocationModFunc(func(_ context.Context, o *FieldseekerLinelocationTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerLinelocationMods) RandomVersion(f *faker.Faker) FieldseekerLinelocationMod { + return FieldseekerLinelocationModFunc(func(_ context.Context, o *FieldseekerLinelocationTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerLinelocationMods) WithParentsCascading() FieldseekerLinelocationMod { return FieldseekerLinelocationModFunc(func(ctx context.Context, o *FieldseekerLinelocationTemplate) { if isDone, _ := fieldseekerLinelocationWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.locationtracking.bob.go b/db/factory/fieldseeker.locationtracking.bob.go index d2879d76..80044e87 100644 --- a/db/factory/fieldseeker.locationtracking.bob.go +++ b/db/factory/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -50,6 +50,7 @@ type FieldseekerLocationtrackingTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -120,6 +121,10 @@ func (o FieldseekerLocationtrackingTemplate) BuildSetter() *models.FieldseekerLo val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -178,6 +183,9 @@ func (o FieldseekerLocationtrackingTemplate) Build() *models.FieldseekerLocation if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -310,6 +318,7 @@ func (m fieldseekerLocationtrackingMods) RandomizeAllColumns(f *faker.Faker) Fie FieldseekerLocationtrackingMods.RandomCreator(f), FieldseekerLocationtrackingMods.RandomEditdate(f), FieldseekerLocationtrackingMods.RandomEditor(f), + FieldseekerLocationtrackingMods.RandomVersion(f), } } @@ -927,6 +936,37 @@ func (m fieldseekerLocationtrackingMods) RandomEditorNotNull(f *faker.Faker) Fie }) } +// Set the model columns to this value +func (m fieldseekerLocationtrackingMods) Version(val int32) FieldseekerLocationtrackingMod { + return FieldseekerLocationtrackingModFunc(func(_ context.Context, o *FieldseekerLocationtrackingTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerLocationtrackingMods) VersionFunc(f func() int32) FieldseekerLocationtrackingMod { + return FieldseekerLocationtrackingModFunc(func(_ context.Context, o *FieldseekerLocationtrackingTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerLocationtrackingMods) UnsetVersion() FieldseekerLocationtrackingMod { + return FieldseekerLocationtrackingModFunc(func(_ context.Context, o *FieldseekerLocationtrackingTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerLocationtrackingMods) RandomVersion(f *faker.Faker) FieldseekerLocationtrackingMod { + return FieldseekerLocationtrackingModFunc(func(_ context.Context, o *FieldseekerLocationtrackingTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerLocationtrackingMods) WithParentsCascading() FieldseekerLocationtrackingMod { return FieldseekerLocationtrackingModFunc(func(ctx context.Context, o *FieldseekerLocationtrackingTemplate) { if isDone, _ := fieldseekerLocationtrackingWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.mosquitoinspection.bob.go b/db/factory/fieldseeker.mosquitoinspection.bob.go index bd3d4514..fb60e556 100644 --- a/db/factory/fieldseeker.mosquitoinspection.bob.go +++ b/db/factory/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -96,6 +96,7 @@ type FieldseekerMosquitoinspectionTemplate struct { Vmcomments func() null.Val[string] Adminaction func() null.Val[enums.FieldseekerMosquitoinspectionMosquitoinspectionAdminactionB74ae1bbC98B] Ptaid func() null.Val[uuid.UUID] + Version func() int32 f *Factory @@ -347,6 +348,10 @@ func (o FieldseekerMosquitoinspectionTemplate) BuildSetter() *models.Fieldseeker val := o.Ptaid() m.Ptaid = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -540,6 +545,9 @@ func (o FieldseekerMosquitoinspectionTemplate) Build() *models.FieldseekerMosqui if o.Ptaid != nil { m.Ptaid = o.Ptaid() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -717,6 +725,7 @@ func (m fieldseekerMosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) F FieldseekerMosquitoinspectionMods.RandomVmcomments(f), FieldseekerMosquitoinspectionMods.RandomAdminaction(f), FieldseekerMosquitoinspectionMods.RandomPtaid(f), + FieldseekerMosquitoinspectionMods.RandomVersion(f), } } @@ -3727,6 +3736,37 @@ func (m fieldseekerMosquitoinspectionMods) RandomPtaidNotNull(f *faker.Faker) Fi }) } +// Set the model columns to this value +func (m fieldseekerMosquitoinspectionMods) Version(val int32) FieldseekerMosquitoinspectionMod { + return FieldseekerMosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerMosquitoinspectionTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerMosquitoinspectionMods) VersionFunc(f func() int32) FieldseekerMosquitoinspectionMod { + return FieldseekerMosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerMosquitoinspectionTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerMosquitoinspectionMods) UnsetVersion() FieldseekerMosquitoinspectionMod { + return FieldseekerMosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerMosquitoinspectionTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerMosquitoinspectionMods) RandomVersion(f *faker.Faker) FieldseekerMosquitoinspectionMod { + return FieldseekerMosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerMosquitoinspectionTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerMosquitoinspectionMods) WithParentsCascading() FieldseekerMosquitoinspectionMod { return FieldseekerMosquitoinspectionModFunc(func(ctx context.Context, o *FieldseekerMosquitoinspectionTemplate) { if isDone, _ := fieldseekerMosquitoinspectionWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.pointlocation.bob.go b/db/factory/fieldseeker.pointlocation.bob.go index 66a07611..0f2047b4 100644 --- a/db/factory/fieldseeker.pointlocation.bob.go +++ b/db/factory/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -83,6 +83,7 @@ type FieldseekerPointlocationTemplate struct { DeactivateReason func() null.Val[enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489] Scalarpriority func() null.Val[int32] Sourcestatus func() null.Val[string] + Version func() int32 f *Factory @@ -281,6 +282,10 @@ func (o FieldseekerPointlocationTemplate) BuildSetter() *models.FieldseekerPoint val := o.Sourcestatus() m.Sourcestatus = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -435,6 +440,9 @@ func (o FieldseekerPointlocationTemplate) Build() *models.FieldseekerPointlocati if o.Sourcestatus != nil { m.Sourcestatus = o.Sourcestatus() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -599,6 +607,7 @@ func (m fieldseekerPointlocationMods) RandomizeAllColumns(f *faker.Faker) Fields FieldseekerPointlocationMods.RandomDeactivateReason(f), FieldseekerPointlocationMods.RandomScalarpriority(f), FieldseekerPointlocationMods.RandomSourcestatus(f), + FieldseekerPointlocationMods.RandomVersion(f), } } @@ -2920,6 +2929,37 @@ func (m fieldseekerPointlocationMods) RandomSourcestatusNotNull(f *faker.Faker) }) } +// Set the model columns to this value +func (m fieldseekerPointlocationMods) Version(val int32) FieldseekerPointlocationMod { + return FieldseekerPointlocationModFunc(func(_ context.Context, o *FieldseekerPointlocationTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerPointlocationMods) VersionFunc(f func() int32) FieldseekerPointlocationMod { + return FieldseekerPointlocationModFunc(func(_ context.Context, o *FieldseekerPointlocationTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerPointlocationMods) UnsetVersion() FieldseekerPointlocationMod { + return FieldseekerPointlocationModFunc(func(_ context.Context, o *FieldseekerPointlocationTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerPointlocationMods) RandomVersion(f *faker.Faker) FieldseekerPointlocationMod { + return FieldseekerPointlocationModFunc(func(_ context.Context, o *FieldseekerPointlocationTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerPointlocationMods) WithParentsCascading() FieldseekerPointlocationMod { return FieldseekerPointlocationModFunc(func(ctx context.Context, o *FieldseekerPointlocationTemplate) { if isDone, _ := fieldseekerPointlocationWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.polygonlocation.bob.go b/db/factory/fieldseeker.polygonlocation.bob.go index 50a49150..0ba7d2a8 100644 --- a/db/factory/fieldseeker.polygonlocation.bob.go +++ b/db/factory/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -81,6 +81,7 @@ type FieldseekerPolygonlocationTemplate struct { Jurisdiction func() null.Val[string] ShapeArea func() null.Val[float64] ShapeLength func() null.Val[float64] + Version func() int32 f *Factory @@ -271,6 +272,10 @@ func (o FieldseekerPolygonlocationTemplate) BuildSetter() *models.FieldseekerPol val := o.ShapeLength() m.ShapeLength = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -419,6 +424,9 @@ func (o FieldseekerPolygonlocationTemplate) Build() *models.FieldseekerPolygonlo if o.ShapeLength != nil { m.ShapeLength = o.ShapeLength() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -581,6 +589,7 @@ func (m fieldseekerPolygonlocationMods) RandomizeAllColumns(f *faker.Faker) Fiel FieldseekerPolygonlocationMods.RandomJurisdiction(f), FieldseekerPolygonlocationMods.RandomShapeArea(f), FieldseekerPolygonlocationMods.RandomShapeLength(f), + FieldseekerPolygonlocationMods.RandomVersion(f), } } @@ -2794,6 +2803,37 @@ func (m fieldseekerPolygonlocationMods) RandomShapeLengthNotNull(f *faker.Faker) }) } +// Set the model columns to this value +func (m fieldseekerPolygonlocationMods) Version(val int32) FieldseekerPolygonlocationMod { + return FieldseekerPolygonlocationModFunc(func(_ context.Context, o *FieldseekerPolygonlocationTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerPolygonlocationMods) VersionFunc(f func() int32) FieldseekerPolygonlocationMod { + return FieldseekerPolygonlocationModFunc(func(_ context.Context, o *FieldseekerPolygonlocationTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerPolygonlocationMods) UnsetVersion() FieldseekerPolygonlocationMod { + return FieldseekerPolygonlocationModFunc(func(_ context.Context, o *FieldseekerPolygonlocationTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerPolygonlocationMods) RandomVersion(f *faker.Faker) FieldseekerPolygonlocationMod { + return FieldseekerPolygonlocationModFunc(func(_ context.Context, o *FieldseekerPolygonlocationTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerPolygonlocationMods) WithParentsCascading() FieldseekerPolygonlocationMod { return FieldseekerPolygonlocationModFunc(func(ctx context.Context, o *FieldseekerPolygonlocationTemplate) { if isDone, _ := fieldseekerPolygonlocationWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.pool.bob.go b/db/factory/fieldseeker.pool.bob.go index 377b06f8..47d55973 100644 --- a/db/factory/fieldseeker.pool.bob.go +++ b/db/factory/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -67,6 +67,7 @@ type FieldseekerPoolTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -201,6 +202,10 @@ func (o FieldseekerPoolTemplate) BuildSetter() *models.FieldseekerPoolSetter { val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -307,6 +312,9 @@ func (o FieldseekerPoolTemplate) Build() *models.FieldseekerPool { if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -455,6 +463,7 @@ func (m fieldseekerPoolMods) RandomizeAllColumns(f *faker.Faker) FieldseekerPool FieldseekerPoolMods.RandomCreator(f), FieldseekerPoolMods.RandomEditdate(f), FieldseekerPoolMods.RandomEditor(f), + FieldseekerPoolMods.RandomVersion(f), } } @@ -1922,6 +1931,37 @@ func (m fieldseekerPoolMods) RandomEditorNotNull(f *faker.Faker) FieldseekerPool }) } +// Set the model columns to this value +func (m fieldseekerPoolMods) Version(val int32) FieldseekerPoolMod { + return FieldseekerPoolModFunc(func(_ context.Context, o *FieldseekerPoolTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerPoolMods) VersionFunc(f func() int32) FieldseekerPoolMod { + return FieldseekerPoolModFunc(func(_ context.Context, o *FieldseekerPoolTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerPoolMods) UnsetVersion() FieldseekerPoolMod { + return FieldseekerPoolModFunc(func(_ context.Context, o *FieldseekerPoolTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerPoolMods) RandomVersion(f *faker.Faker) FieldseekerPoolMod { + return FieldseekerPoolModFunc(func(_ context.Context, o *FieldseekerPoolTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerPoolMods) WithParentsCascading() FieldseekerPoolMod { return FieldseekerPoolModFunc(func(ctx context.Context, o *FieldseekerPoolTemplate) { if isDone, _ := fieldseekerPoolWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.poolbuffer.bob.go b/db/factory/fieldseeker.poolbuffer.bob.go deleted file mode 100644 index 67703794..00000000 --- a/db/factory/fieldseeker.poolbuffer.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerPoolbufferMod interface { - Apply(context.Context, *FieldseekerPoolbufferTemplate) -} - -type FieldseekerPoolbufferModFunc func(context.Context, *FieldseekerPoolbufferTemplate) - -func (f FieldseekerPoolbufferModFunc) Apply(ctx context.Context, n *FieldseekerPoolbufferTemplate) { - f(ctx, n) -} - -type FieldseekerPoolbufferModSlice []FieldseekerPoolbufferMod - -func (mods FieldseekerPoolbufferModSlice) Apply(ctx context.Context, n *FieldseekerPoolbufferTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerPoolbufferTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerPoolbufferTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerPoolbufferTemplate -func (o *FieldseekerPoolbufferTemplate) Apply(ctx context.Context, mods ...FieldseekerPoolbufferMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerPoolbuffer -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerPoolbufferTemplate) setModelRels(o *models.FieldseekerPoolbuffer) {} - -// Build returns an *models.FieldseekerPoolbuffer -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerPoolbufferTemplate.Create -func (o FieldseekerPoolbufferTemplate) Build() *models.FieldseekerPoolbuffer { - m := &models.FieldseekerPoolbuffer{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerPoolbufferSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerPoolbufferTemplate.CreateMany -func (o FieldseekerPoolbufferTemplate) BuildMany(number int) models.FieldseekerPoolbufferSlice { - m := make(models.FieldseekerPoolbufferSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerPoolbuffer has methods that act as mods for the FieldseekerPoolbufferTemplate -var FieldseekerPoolbufferMods fieldseekerPoolbufferMods - -type fieldseekerPoolbufferMods struct{} - -func (m fieldseekerPoolbufferMods) RandomizeAllColumns(f *faker.Faker) FieldseekerPoolbufferMod { - return FieldseekerPoolbufferModSlice{} -} - -func (m fieldseekerPoolbufferMods) WithParentsCascading() FieldseekerPoolbufferMod { - return FieldseekerPoolbufferModFunc(func(ctx context.Context, o *FieldseekerPoolbufferTemplate) { - if isDone, _ := fieldseekerPoolbufferWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerPoolbufferWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.pooldetail.bob.go b/db/factory/fieldseeker.pooldetail.bob.go index 419fc884..d1432a6b 100644 --- a/db/factory/fieldseeker.pooldetail.bob.go +++ b/db/factory/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -52,6 +52,7 @@ type FieldseekerPooldetailTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -130,6 +131,10 @@ func (o FieldseekerPooldetailTemplate) BuildSetter() *models.FieldseekerPooldeta val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -194,6 +199,9 @@ func (o FieldseekerPooldetailTemplate) Build() *models.FieldseekerPooldetail { if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -328,6 +336,7 @@ func (m fieldseekerPooldetailMods) RandomizeAllColumns(f *faker.Faker) Fieldseek FieldseekerPooldetailMods.RandomCreator(f), FieldseekerPooldetailMods.RandomEditdate(f), FieldseekerPooldetailMods.RandomEditor(f), + FieldseekerPooldetailMods.RandomVersion(f), } } @@ -1051,6 +1060,37 @@ func (m fieldseekerPooldetailMods) RandomEditorNotNull(f *faker.Faker) Fieldseek }) } +// Set the model columns to this value +func (m fieldseekerPooldetailMods) Version(val int32) FieldseekerPooldetailMod { + return FieldseekerPooldetailModFunc(func(_ context.Context, o *FieldseekerPooldetailTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerPooldetailMods) VersionFunc(f func() int32) FieldseekerPooldetailMod { + return FieldseekerPooldetailModFunc(func(_ context.Context, o *FieldseekerPooldetailTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerPooldetailMods) UnsetVersion() FieldseekerPooldetailMod { + return FieldseekerPooldetailModFunc(func(_ context.Context, o *FieldseekerPooldetailTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerPooldetailMods) RandomVersion(f *faker.Faker) FieldseekerPooldetailMod { + return FieldseekerPooldetailModFunc(func(_ context.Context, o *FieldseekerPooldetailTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerPooldetailMods) WithParentsCascading() FieldseekerPooldetailMod { return FieldseekerPooldetailModFunc(func(ctx context.Context, o *FieldseekerPooldetailTemplate) { if isDone, _ := fieldseekerPooldetailWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.proposedtreatmentarea.bob.go b/db/factory/fieldseeker.proposedtreatmentarea.bob.go index 56df2be5..b08302d9 100644 --- a/db/factory/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/factory/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -72,6 +72,7 @@ type FieldseekerProposedtreatmentareaTemplate struct { Targetspecies func() null.Val[string] ShapeArea func() null.Val[float64] ShapeLength func() null.Val[float64] + Version func() int32 f *Factory @@ -227,6 +228,10 @@ func (o FieldseekerProposedtreatmentareaTemplate) BuildSetter() *models.Fieldsee val := o.ShapeLength() m.ShapeLength = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -348,6 +353,9 @@ func (o FieldseekerProposedtreatmentareaTemplate) Build() *models.FieldseekerPro if o.ShapeLength != nil { m.ShapeLength = o.ShapeLength() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -501,6 +509,7 @@ func (m fieldseekerProposedtreatmentareaMods) RandomizeAllColumns(f *faker.Faker FieldseekerProposedtreatmentareaMods.RandomTargetspecies(f), FieldseekerProposedtreatmentareaMods.RandomShapeArea(f), FieldseekerProposedtreatmentareaMods.RandomShapeLength(f), + FieldseekerProposedtreatmentareaMods.RandomVersion(f), } } @@ -2231,6 +2240,37 @@ func (m fieldseekerProposedtreatmentareaMods) RandomShapeLengthNotNull(f *faker. }) } +// Set the model columns to this value +func (m fieldseekerProposedtreatmentareaMods) Version(val int32) FieldseekerProposedtreatmentareaMod { + return FieldseekerProposedtreatmentareaModFunc(func(_ context.Context, o *FieldseekerProposedtreatmentareaTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerProposedtreatmentareaMods) VersionFunc(f func() int32) FieldseekerProposedtreatmentareaMod { + return FieldseekerProposedtreatmentareaModFunc(func(_ context.Context, o *FieldseekerProposedtreatmentareaTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerProposedtreatmentareaMods) UnsetVersion() FieldseekerProposedtreatmentareaMod { + return FieldseekerProposedtreatmentareaModFunc(func(_ context.Context, o *FieldseekerProposedtreatmentareaTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerProposedtreatmentareaMods) RandomVersion(f *faker.Faker) FieldseekerProposedtreatmentareaMod { + return FieldseekerProposedtreatmentareaModFunc(func(_ context.Context, o *FieldseekerProposedtreatmentareaTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerProposedtreatmentareaMods) WithParentsCascading() FieldseekerProposedtreatmentareaMod { return FieldseekerProposedtreatmentareaModFunc(func(ctx context.Context, o *FieldseekerProposedtreatmentareaTemplate) { if isDone, _ := fieldseekerProposedtreatmentareaWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.qalarvcount.bob.go b/db/factory/fieldseeker.qalarvcount.bob.go deleted file mode 100644 index 56b02861..00000000 --- a/db/factory/fieldseeker.qalarvcount.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerQalarvcountMod interface { - Apply(context.Context, *FieldseekerQalarvcountTemplate) -} - -type FieldseekerQalarvcountModFunc func(context.Context, *FieldseekerQalarvcountTemplate) - -func (f FieldseekerQalarvcountModFunc) Apply(ctx context.Context, n *FieldseekerQalarvcountTemplate) { - f(ctx, n) -} - -type FieldseekerQalarvcountModSlice []FieldseekerQalarvcountMod - -func (mods FieldseekerQalarvcountModSlice) Apply(ctx context.Context, n *FieldseekerQalarvcountTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerQalarvcountTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerQalarvcountTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerQalarvcountTemplate -func (o *FieldseekerQalarvcountTemplate) Apply(ctx context.Context, mods ...FieldseekerQalarvcountMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerQalarvcount -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerQalarvcountTemplate) setModelRels(o *models.FieldseekerQalarvcount) {} - -// Build returns an *models.FieldseekerQalarvcount -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerQalarvcountTemplate.Create -func (o FieldseekerQalarvcountTemplate) Build() *models.FieldseekerQalarvcount { - m := &models.FieldseekerQalarvcount{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerQalarvcountSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerQalarvcountTemplate.CreateMany -func (o FieldseekerQalarvcountTemplate) BuildMany(number int) models.FieldseekerQalarvcountSlice { - m := make(models.FieldseekerQalarvcountSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerQalarvcount has methods that act as mods for the FieldseekerQalarvcountTemplate -var FieldseekerQalarvcountMods fieldseekerQalarvcountMods - -type fieldseekerQalarvcountMods struct{} - -func (m fieldseekerQalarvcountMods) RandomizeAllColumns(f *faker.Faker) FieldseekerQalarvcountMod { - return FieldseekerQalarvcountModSlice{} -} - -func (m fieldseekerQalarvcountMods) WithParentsCascading() FieldseekerQalarvcountMod { - return FieldseekerQalarvcountModFunc(func(ctx context.Context, o *FieldseekerQalarvcountTemplate) { - if isDone, _ := fieldseekerQalarvcountWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerQalarvcountWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.qamosquitoinspection.bob.go b/db/factory/fieldseeker.qamosquitoinspection.bob.go index 87d7b7e2..8e6afd61 100644 --- a/db/factory/fieldseeker.qamosquitoinspection.bob.go +++ b/db/factory/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -101,6 +101,7 @@ type FieldseekerQamosquitoinspectionTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -372,6 +373,10 @@ func (o FieldseekerQamosquitoinspectionTemplate) BuildSetter() *models.Fieldseek val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -580,6 +585,9 @@ func (o FieldseekerQamosquitoinspectionTemplate) Build() *models.FieldseekerQamo if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -762,6 +770,7 @@ func (m fieldseekerQamosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) FieldseekerQamosquitoinspectionMods.RandomCreator(f), FieldseekerQamosquitoinspectionMods.RandomEditdate(f), FieldseekerQamosquitoinspectionMods.RandomEditor(f), + FieldseekerQamosquitoinspectionMods.RandomVersion(f), } } @@ -4029,6 +4038,37 @@ func (m fieldseekerQamosquitoinspectionMods) RandomEditorNotNull(f *faker.Faker) }) } +// Set the model columns to this value +func (m fieldseekerQamosquitoinspectionMods) Version(val int32) FieldseekerQamosquitoinspectionMod { + return FieldseekerQamosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerQamosquitoinspectionTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerQamosquitoinspectionMods) VersionFunc(f func() int32) FieldseekerQamosquitoinspectionMod { + return FieldseekerQamosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerQamosquitoinspectionTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerQamosquitoinspectionMods) UnsetVersion() FieldseekerQamosquitoinspectionMod { + return FieldseekerQamosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerQamosquitoinspectionTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerQamosquitoinspectionMods) RandomVersion(f *faker.Faker) FieldseekerQamosquitoinspectionMod { + return FieldseekerQamosquitoinspectionModFunc(func(_ context.Context, o *FieldseekerQamosquitoinspectionTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerQamosquitoinspectionMods) WithParentsCascading() FieldseekerQamosquitoinspectionMod { return FieldseekerQamosquitoinspectionModFunc(func(ctx context.Context, o *FieldseekerQamosquitoinspectionTemplate) { if isDone, _ := fieldseekerQamosquitoinspectionWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.qaproductobservation.bob.go b/db/factory/fieldseeker.qaproductobservation.bob.go deleted file mode 100644 index 006d9e17..00000000 --- a/db/factory/fieldseeker.qaproductobservation.bob.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerQaproductobservationMod interface { - Apply(context.Context, *FieldseekerQaproductobservationTemplate) -} - -type FieldseekerQaproductobservationModFunc func(context.Context, *FieldseekerQaproductobservationTemplate) - -func (f FieldseekerQaproductobservationModFunc) Apply(ctx context.Context, n *FieldseekerQaproductobservationTemplate) { - f(ctx, n) -} - -type FieldseekerQaproductobservationModSlice []FieldseekerQaproductobservationMod - -func (mods FieldseekerQaproductobservationModSlice) Apply(ctx context.Context, n *FieldseekerQaproductobservationTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerQaproductobservationTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerQaproductobservationTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerQaproductobservationTemplate -func (o *FieldseekerQaproductobservationTemplate) Apply(ctx context.Context, mods ...FieldseekerQaproductobservationMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerQaproductobservation -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerQaproductobservationTemplate) setModelRels(o *models.FieldseekerQaproductobservation) { -} - -// Build returns an *models.FieldseekerQaproductobservation -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerQaproductobservationTemplate.Create -func (o FieldseekerQaproductobservationTemplate) Build() *models.FieldseekerQaproductobservation { - m := &models.FieldseekerQaproductobservation{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerQaproductobservationSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerQaproductobservationTemplate.CreateMany -func (o FieldseekerQaproductobservationTemplate) BuildMany(number int) models.FieldseekerQaproductobservationSlice { - m := make(models.FieldseekerQaproductobservationSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerQaproductobservation has methods that act as mods for the FieldseekerQaproductobservationTemplate -var FieldseekerQaproductobservationMods fieldseekerQaproductobservationMods - -type fieldseekerQaproductobservationMods struct{} - -func (m fieldseekerQaproductobservationMods) RandomizeAllColumns(f *faker.Faker) FieldseekerQaproductobservationMod { - return FieldseekerQaproductobservationModSlice{} -} - -func (m fieldseekerQaproductobservationMods) WithParentsCascading() FieldseekerQaproductobservationMod { - return FieldseekerQaproductobservationModFunc(func(ctx context.Context, o *FieldseekerQaproductobservationTemplate) { - if isDone, _ := fieldseekerQaproductobservationWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerQaproductobservationWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.restrictedarea.bob.go b/db/factory/fieldseeker.restrictedarea.bob.go deleted file mode 100644 index 184502a2..00000000 --- a/db/factory/fieldseeker.restrictedarea.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerRestrictedareaMod interface { - Apply(context.Context, *FieldseekerRestrictedareaTemplate) -} - -type FieldseekerRestrictedareaModFunc func(context.Context, *FieldseekerRestrictedareaTemplate) - -func (f FieldseekerRestrictedareaModFunc) Apply(ctx context.Context, n *FieldseekerRestrictedareaTemplate) { - f(ctx, n) -} - -type FieldseekerRestrictedareaModSlice []FieldseekerRestrictedareaMod - -func (mods FieldseekerRestrictedareaModSlice) Apply(ctx context.Context, n *FieldseekerRestrictedareaTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerRestrictedareaTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerRestrictedareaTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerRestrictedareaTemplate -func (o *FieldseekerRestrictedareaTemplate) Apply(ctx context.Context, mods ...FieldseekerRestrictedareaMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerRestrictedarea -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerRestrictedareaTemplate) setModelRels(o *models.FieldseekerRestrictedarea) {} - -// Build returns an *models.FieldseekerRestrictedarea -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerRestrictedareaTemplate.Create -func (o FieldseekerRestrictedareaTemplate) Build() *models.FieldseekerRestrictedarea { - m := &models.FieldseekerRestrictedarea{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerRestrictedareaSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerRestrictedareaTemplate.CreateMany -func (o FieldseekerRestrictedareaTemplate) BuildMany(number int) models.FieldseekerRestrictedareaSlice { - m := make(models.FieldseekerRestrictedareaSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerRestrictedarea has methods that act as mods for the FieldseekerRestrictedareaTemplate -var FieldseekerRestrictedareaMods fieldseekerRestrictedareaMods - -type fieldseekerRestrictedareaMods struct{} - -func (m fieldseekerRestrictedareaMods) RandomizeAllColumns(f *faker.Faker) FieldseekerRestrictedareaMod { - return FieldseekerRestrictedareaModSlice{} -} - -func (m fieldseekerRestrictedareaMods) WithParentsCascading() FieldseekerRestrictedareaMod { - return FieldseekerRestrictedareaModFunc(func(ctx context.Context, o *FieldseekerRestrictedareaTemplate) { - if isDone, _ := fieldseekerRestrictedareaWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerRestrictedareaWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.rodentinspection.bob.go b/db/factory/fieldseeker.rodentinspection.bob.go deleted file mode 100644 index 72d766a0..00000000 --- a/db/factory/fieldseeker.rodentinspection.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerRodentinspectionMod interface { - Apply(context.Context, *FieldseekerRodentinspectionTemplate) -} - -type FieldseekerRodentinspectionModFunc func(context.Context, *FieldseekerRodentinspectionTemplate) - -func (f FieldseekerRodentinspectionModFunc) Apply(ctx context.Context, n *FieldseekerRodentinspectionTemplate) { - f(ctx, n) -} - -type FieldseekerRodentinspectionModSlice []FieldseekerRodentinspectionMod - -func (mods FieldseekerRodentinspectionModSlice) Apply(ctx context.Context, n *FieldseekerRodentinspectionTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerRodentinspectionTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerRodentinspectionTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerRodentinspectionTemplate -func (o *FieldseekerRodentinspectionTemplate) Apply(ctx context.Context, mods ...FieldseekerRodentinspectionMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerRodentinspection -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerRodentinspectionTemplate) setModelRels(o *models.FieldseekerRodentinspection) {} - -// Build returns an *models.FieldseekerRodentinspection -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerRodentinspectionTemplate.Create -func (o FieldseekerRodentinspectionTemplate) Build() *models.FieldseekerRodentinspection { - m := &models.FieldseekerRodentinspection{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerRodentinspectionSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerRodentinspectionTemplate.CreateMany -func (o FieldseekerRodentinspectionTemplate) BuildMany(number int) models.FieldseekerRodentinspectionSlice { - m := make(models.FieldseekerRodentinspectionSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerRodentinspection has methods that act as mods for the FieldseekerRodentinspectionTemplate -var FieldseekerRodentinspectionMods fieldseekerRodentinspectionMods - -type fieldseekerRodentinspectionMods struct{} - -func (m fieldseekerRodentinspectionMods) RandomizeAllColumns(f *faker.Faker) FieldseekerRodentinspectionMod { - return FieldseekerRodentinspectionModSlice{} -} - -func (m fieldseekerRodentinspectionMods) WithParentsCascading() FieldseekerRodentinspectionMod { - return FieldseekerRodentinspectionModFunc(func(ctx context.Context, o *FieldseekerRodentinspectionTemplate) { - if isDone, _ := fieldseekerRodentinspectionWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerRodentinspectionWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.rodentlocation.bob.go b/db/factory/fieldseeker.rodentlocation.bob.go index d71b2423..e5218a2d 100644 --- a/db/factory/fieldseeker.rodentlocation.bob.go +++ b/db/factory/fieldseeker.rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -39,7 +39,6 @@ func (mods FieldseekerRodentlocationModSlice) Apply(ctx context.Context, n *Fiel // FieldseekerRodentlocationTemplate is an object representing the database table. // all columns are optional and should be set by mods type FieldseekerRodentlocationTemplate struct { - OrganizationID func() int32 Objectid func() int64 Locationname func() null.Val[string] Zone func() null.Val[string] @@ -70,21 +69,13 @@ type FieldseekerRodentlocationTemplate struct { Editdate func() null.Val[time.Time] Editor func() null.Val[string] Jurisdiction func() null.Val[string] + Version func() int32 - r fieldseekerRodentlocationR f *Factory alreadyPersisted bool } -type fieldseekerRodentlocationR struct { - Organization *fieldseekerRodentlocationROrganizationR -} - -type fieldseekerRodentlocationROrganizationR struct { - o *OrganizationTemplate -} - // Apply mods to the FieldseekerRodentlocationTemplate func (o *FieldseekerRodentlocationTemplate) Apply(ctx context.Context, mods ...FieldseekerRodentlocationMod) { for _, mod := range mods { @@ -94,24 +85,13 @@ func (o *FieldseekerRodentlocationTemplate) Apply(ctx context.Context, mods ...F // setModelRels creates and sets the relationships on *models.FieldseekerRodentlocation // according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerRodentlocationTemplate) setModelRels(o *models.FieldseekerRodentlocation) { - if t.r.Organization != nil { - rel := t.r.Organization.o.Build() - rel.R.Rodentlocations = append(rel.R.Rodentlocations, o) - o.OrganizationID = rel.ID // h2 - o.R.Organization = rel - } -} +func (t FieldseekerRodentlocationTemplate) setModelRels(o *models.FieldseekerRodentlocation) {} // BuildSetter returns an *models.FieldseekerRodentlocationSetter // this does nothing with the relationship templates func (o FieldseekerRodentlocationTemplate) BuildSetter() *models.FieldseekerRodentlocationSetter { m := &models.FieldseekerRodentlocationSetter{} - if o.OrganizationID != nil { - val := o.OrganizationID() - m.OrganizationID = omit.From(val) - } if o.Objectid != nil { val := o.Objectid() m.Objectid = omit.From(val) @@ -232,6 +212,10 @@ func (o FieldseekerRodentlocationTemplate) BuildSetter() *models.FieldseekerRode val := o.Jurisdiction() m.Jurisdiction = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -254,9 +238,6 @@ func (o FieldseekerRodentlocationTemplate) BuildManySetter(number int) []*models func (o FieldseekerRodentlocationTemplate) Build() *models.FieldseekerRodentlocation { m := &models.FieldseekerRodentlocation{} - if o.OrganizationID != nil { - m.OrganizationID = o.OrganizationID() - } if o.Objectid != nil { m.Objectid = o.Objectid() } @@ -347,6 +328,9 @@ func (o FieldseekerRodentlocationTemplate) Build() *models.FieldseekerRodentloca if o.Jurisdiction != nil { m.Jurisdiction = o.Jurisdiction() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -367,10 +351,6 @@ func (o FieldseekerRodentlocationTemplate) BuildMany(number int) models.Fieldsee } func ensureCreatableFieldseekerRodentlocation(m *models.FieldseekerRodentlocationSetter) { - if !(m.OrganizationID.IsValue()) { - val := random_int32(nil) - m.OrganizationID = omit.From(val) - } } // insertOptRels creates and inserts any optional the relationships on *models.FieldseekerRodentlocation @@ -389,30 +369,11 @@ func (o *FieldseekerRodentlocationTemplate) Create(ctx context.Context, exec bob opt := o.BuildSetter() ensureCreatableFieldseekerRodentlocation(opt) - if o.r.Organization == nil { - FieldseekerRodentlocationMods.WithNewOrganization().Apply(ctx, o) - } - - var rel0 *models.Organization - - if o.r.Organization.o.alreadyPersisted { - rel0 = o.r.Organization.o.Build() - } else { - rel0, err = o.r.Organization.o.Create(ctx, exec) - if err != nil { - return nil, err - } - } - - opt.OrganizationID = omit.From(rel0.ID) - m, err := models.FieldseekerRodentlocations.Insert(opt).One(ctx, exec) if err != nil { return nil, err } - m.R.Organization = rel0 - if err := o.insertOptRels(ctx, exec, m); err != nil { return nil, err } @@ -490,7 +451,6 @@ type fieldseekerRodentlocationMods struct{} func (m fieldseekerRodentlocationMods) RandomizeAllColumns(f *faker.Faker) FieldseekerRodentlocationMod { return FieldseekerRodentlocationModSlice{ - FieldseekerRodentlocationMods.RandomOrganizationID(f), FieldseekerRodentlocationMods.RandomObjectid(f), FieldseekerRodentlocationMods.RandomLocationname(f), FieldseekerRodentlocationMods.RandomZone(f), @@ -521,40 +481,10 @@ func (m fieldseekerRodentlocationMods) RandomizeAllColumns(f *faker.Faker) Field FieldseekerRodentlocationMods.RandomEditdate(f), FieldseekerRodentlocationMods.RandomEditor(f), FieldseekerRodentlocationMods.RandomJurisdiction(f), + FieldseekerRodentlocationMods.RandomVersion(f), } } -// Set the model columns to this value -func (m fieldseekerRodentlocationMods) OrganizationID(val int32) FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { - o.OrganizationID = func() int32 { return val } - }) -} - -// Set the Column from the function -func (m fieldseekerRodentlocationMods) OrganizationIDFunc(f func() int32) FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { - o.OrganizationID = f - }) -} - -// Clear any values for the column -func (m fieldseekerRodentlocationMods) UnsetOrganizationID() FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { - o.OrganizationID = nil - }) -} - -// Generates a random value for the column using the given faker -// if faker is nil, a default faker is used -func (m fieldseekerRodentlocationMods) RandomOrganizationID(f *faker.Faker) FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { - o.OrganizationID = func() int32 { - return random_int32(f) - } - }) -} - // Set the model columns to this value func (m fieldseekerRodentlocationMods) Objectid(val int64) FieldseekerRodentlocationMod { return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { @@ -2123,46 +2053,42 @@ func (m fieldseekerRodentlocationMods) RandomJurisdictionNotNull(f *faker.Faker) }) } +// Set the model columns to this value +func (m fieldseekerRodentlocationMods) Version(val int32) FieldseekerRodentlocationMod { + return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerRodentlocationMods) VersionFunc(f func() int32) FieldseekerRodentlocationMod { + return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerRodentlocationMods) UnsetVersion() FieldseekerRodentlocationMod { + return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerRodentlocationMods) RandomVersion(f *faker.Faker) FieldseekerRodentlocationMod { + return FieldseekerRodentlocationModFunc(func(_ context.Context, o *FieldseekerRodentlocationTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerRodentlocationMods) WithParentsCascading() FieldseekerRodentlocationMod { return FieldseekerRodentlocationModFunc(func(ctx context.Context, o *FieldseekerRodentlocationTemplate) { if isDone, _ := fieldseekerRodentlocationWithParentsCascadingCtx.Value(ctx); isDone { return } ctx = fieldseekerRodentlocationWithParentsCascadingCtx.WithValue(ctx, true) - { - - related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading()) - m.WithOrganization(related).Apply(ctx, o) - } - }) -} - -func (m fieldseekerRodentlocationMods) WithOrganization(rel *OrganizationTemplate) FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(ctx context.Context, o *FieldseekerRodentlocationTemplate) { - o.r.Organization = &fieldseekerRodentlocationROrganizationR{ - o: rel, - } - }) -} - -func (m fieldseekerRodentlocationMods) WithNewOrganization(mods ...OrganizationMod) FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(ctx context.Context, o *FieldseekerRodentlocationTemplate) { - related := o.f.NewOrganizationWithContext(ctx, mods...) - - m.WithOrganization(related).Apply(ctx, o) - }) -} - -func (m fieldseekerRodentlocationMods) WithExistingOrganization(em *models.Organization) FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(ctx context.Context, o *FieldseekerRodentlocationTemplate) { - o.r.Organization = &fieldseekerRodentlocationROrganizationR{ - o: o.f.FromExistingOrganization(em), - } - }) -} - -func (m fieldseekerRodentlocationMods) WithoutOrganization() FieldseekerRodentlocationMod { - return FieldseekerRodentlocationModFunc(func(ctx context.Context, o *FieldseekerRodentlocationTemplate) { - o.r.Organization = nil }) } diff --git a/db/factory/fieldseeker.samplecollection.bob.go b/db/factory/fieldseeker.samplecollection.bob.go index a4873006..2c8fcfeb 100644 --- a/db/factory/fieldseeker.samplecollection.bob.go +++ b/db/factory/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -85,6 +85,7 @@ type FieldseekerSamplecollectionTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -291,6 +292,10 @@ func (o FieldseekerSamplecollectionTemplate) BuildSetter() *models.FieldseekerSa val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -451,6 +456,9 @@ func (o FieldseekerSamplecollectionTemplate) Build() *models.FieldseekerSampleco if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -617,6 +625,7 @@ func (m fieldseekerSamplecollectionMods) RandomizeAllColumns(f *faker.Faker) Fie FieldseekerSamplecollectionMods.RandomCreator(f), FieldseekerSamplecollectionMods.RandomEditdate(f), FieldseekerSamplecollectionMods.RandomEditor(f), + FieldseekerSamplecollectionMods.RandomVersion(f), } } @@ -3036,6 +3045,37 @@ func (m fieldseekerSamplecollectionMods) RandomEditorNotNull(f *faker.Faker) Fie }) } +// Set the model columns to this value +func (m fieldseekerSamplecollectionMods) Version(val int32) FieldseekerSamplecollectionMod { + return FieldseekerSamplecollectionModFunc(func(_ context.Context, o *FieldseekerSamplecollectionTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerSamplecollectionMods) VersionFunc(f func() int32) FieldseekerSamplecollectionMod { + return FieldseekerSamplecollectionModFunc(func(_ context.Context, o *FieldseekerSamplecollectionTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerSamplecollectionMods) UnsetVersion() FieldseekerSamplecollectionMod { + return FieldseekerSamplecollectionModFunc(func(_ context.Context, o *FieldseekerSamplecollectionTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerSamplecollectionMods) RandomVersion(f *faker.Faker) FieldseekerSamplecollectionMod { + return FieldseekerSamplecollectionModFunc(func(_ context.Context, o *FieldseekerSamplecollectionTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerSamplecollectionMods) WithParentsCascading() FieldseekerSamplecollectionMod { return FieldseekerSamplecollectionModFunc(func(ctx context.Context, o *FieldseekerSamplecollectionTemplate) { if isDone, _ := fieldseekerSamplecollectionWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.samplelocation.bob.go b/db/factory/fieldseeker.samplelocation.bob.go index 39e9a567..85a8b725 100644 --- a/db/factory/fieldseeker.samplelocation.bob.go +++ b/db/factory/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -63,6 +63,7 @@ type FieldseekerSamplelocationTemplate struct { Creator func() null.Val[string] Editdate func() null.Val[time.Time] Editor func() null.Val[string] + Version func() int32 f *Factory @@ -181,6 +182,10 @@ func (o FieldseekerSamplelocationTemplate) BuildSetter() *models.FieldseekerSamp val := o.Editor() m.Editor = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -275,6 +280,9 @@ func (o FieldseekerSamplelocationTemplate) Build() *models.FieldseekerSampleloca if o.Editor != nil { m.Editor = o.Editor() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -419,6 +427,7 @@ func (m fieldseekerSamplelocationMods) RandomizeAllColumns(f *faker.Faker) Field FieldseekerSamplelocationMods.RandomCreator(f), FieldseekerSamplelocationMods.RandomEditdate(f), FieldseekerSamplelocationMods.RandomEditor(f), + FieldseekerSamplelocationMods.RandomVersion(f), } } @@ -1672,6 +1681,37 @@ func (m fieldseekerSamplelocationMods) RandomEditorNotNull(f *faker.Faker) Field }) } +// Set the model columns to this value +func (m fieldseekerSamplelocationMods) Version(val int32) FieldseekerSamplelocationMod { + return FieldseekerSamplelocationModFunc(func(_ context.Context, o *FieldseekerSamplelocationTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerSamplelocationMods) VersionFunc(f func() int32) FieldseekerSamplelocationMod { + return FieldseekerSamplelocationModFunc(func(_ context.Context, o *FieldseekerSamplelocationTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerSamplelocationMods) UnsetVersion() FieldseekerSamplelocationMod { + return FieldseekerSamplelocationModFunc(func(_ context.Context, o *FieldseekerSamplelocationTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerSamplelocationMods) RandomVersion(f *faker.Faker) FieldseekerSamplelocationMod { + return FieldseekerSamplelocationModFunc(func(_ context.Context, o *FieldseekerSamplelocationTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerSamplelocationMods) WithParentsCascading() FieldseekerSamplelocationMod { return FieldseekerSamplelocationModFunc(func(ctx context.Context, o *FieldseekerSamplelocationTemplate) { if isDone, _ := fieldseekerSamplelocationWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.servicerequest.bob.go b/db/factory/fieldseeker.servicerequest.bob.go index ae0696a2..77089555 100644 --- a/db/factory/fieldseeker.servicerequest.bob.go +++ b/db/factory/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -125,6 +125,7 @@ type FieldseekerServicerequestTemplate struct { Notificationtimestamp func() null.Val[string] Zone func() null.Val[string] Zone2 func() null.Val[string] + Version func() int32 f *Factory @@ -491,6 +492,10 @@ func (o FieldseekerServicerequestTemplate) BuildSetter() *models.FieldseekerServ val := o.Zone2() m.Zone2 = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -771,6 +776,9 @@ func (o FieldseekerServicerequestTemplate) Build() *models.FieldseekerServicereq if o.Zone2 != nil { m.Zone2 = o.Zone2() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -977,6 +985,7 @@ func (m fieldseekerServicerequestMods) RandomizeAllColumns(f *faker.Faker) Field FieldseekerServicerequestMods.RandomNotificationtimestamp(f), FieldseekerServicerequestMods.RandomZone(f), FieldseekerServicerequestMods.RandomZone2(f), + FieldseekerServicerequestMods.RandomVersion(f), } } @@ -5522,6 +5531,37 @@ func (m fieldseekerServicerequestMods) RandomZone2NotNull(f *faker.Faker) Fields }) } +// Set the model columns to this value +func (m fieldseekerServicerequestMods) Version(val int32) FieldseekerServicerequestMod { + return FieldseekerServicerequestModFunc(func(_ context.Context, o *FieldseekerServicerequestTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerServicerequestMods) VersionFunc(f func() int32) FieldseekerServicerequestMod { + return FieldseekerServicerequestModFunc(func(_ context.Context, o *FieldseekerServicerequestTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerServicerequestMods) UnsetVersion() FieldseekerServicerequestMod { + return FieldseekerServicerequestModFunc(func(_ context.Context, o *FieldseekerServicerequestTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerServicerequestMods) RandomVersion(f *faker.Faker) FieldseekerServicerequestMod { + return FieldseekerServicerequestModFunc(func(_ context.Context, o *FieldseekerServicerequestTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerServicerequestMods) WithParentsCascading() FieldseekerServicerequestMod { return FieldseekerServicerequestModFunc(func(ctx context.Context, o *FieldseekerServicerequestTemplate) { if isDone, _ := fieldseekerServicerequestWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.speciesabundance.bob.go b/db/factory/fieldseeker.speciesabundance.bob.go index ecb643de..d072413d 100644 --- a/db/factory/fieldseeker.speciesabundance.bob.go +++ b/db/factory/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -68,6 +68,7 @@ type FieldseekerSpeciesabundanceTemplate struct { R8score func() null.Val[float64] H3R7 func() null.Val[string] H3R8 func() null.Val[string] + Version func() int32 f *Factory @@ -206,6 +207,10 @@ func (o FieldseekerSpeciesabundanceTemplate) BuildSetter() *models.FieldseekerSp val := o.H3R8() m.H3R8 = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -315,6 +320,9 @@ func (o FieldseekerSpeciesabundanceTemplate) Build() *models.FieldseekerSpeciesa if o.H3R8 != nil { m.H3R8 = o.H3R8() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -464,6 +472,7 @@ func (m fieldseekerSpeciesabundanceMods) RandomizeAllColumns(f *faker.Faker) Fie FieldseekerSpeciesabundanceMods.RandomR8score(f), FieldseekerSpeciesabundanceMods.RandomH3R7(f), FieldseekerSpeciesabundanceMods.RandomH3R8(f), + FieldseekerSpeciesabundanceMods.RandomVersion(f), } } @@ -1982,6 +1991,37 @@ func (m fieldseekerSpeciesabundanceMods) RandomH3R8NotNull(f *faker.Faker) Field }) } +// Set the model columns to this value +func (m fieldseekerSpeciesabundanceMods) Version(val int32) FieldseekerSpeciesabundanceMod { + return FieldseekerSpeciesabundanceModFunc(func(_ context.Context, o *FieldseekerSpeciesabundanceTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerSpeciesabundanceMods) VersionFunc(f func() int32) FieldseekerSpeciesabundanceMod { + return FieldseekerSpeciesabundanceModFunc(func(_ context.Context, o *FieldseekerSpeciesabundanceTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerSpeciesabundanceMods) UnsetVersion() FieldseekerSpeciesabundanceMod { + return FieldseekerSpeciesabundanceModFunc(func(_ context.Context, o *FieldseekerSpeciesabundanceTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerSpeciesabundanceMods) RandomVersion(f *faker.Faker) FieldseekerSpeciesabundanceMod { + return FieldseekerSpeciesabundanceModFunc(func(_ context.Context, o *FieldseekerSpeciesabundanceTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerSpeciesabundanceMods) WithParentsCascading() FieldseekerSpeciesabundanceMod { return FieldseekerSpeciesabundanceModFunc(func(ctx context.Context, o *FieldseekerSpeciesabundanceTemplate) { if isDone, _ := fieldseekerSpeciesabundanceWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.stormdrain.bob.go b/db/factory/fieldseeker.stormdrain.bob.go index c0e69695..3c8640e3 100644 --- a/db/factory/fieldseeker.stormdrain.bob.go +++ b/db/factory/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -58,6 +58,7 @@ type FieldseekerStormdrainTemplate struct { Editor func() null.Val[string] Type func() null.Val[string] Jurisdiction func() null.Val[string] + Version func() int32 f *Factory @@ -156,6 +157,10 @@ func (o FieldseekerStormdrainTemplate) BuildSetter() *models.FieldseekerStormdra val := o.Jurisdiction() m.Jurisdiction = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -235,6 +240,9 @@ func (o FieldseekerStormdrainTemplate) Build() *models.FieldseekerStormdrain { if o.Jurisdiction != nil { m.Jurisdiction = o.Jurisdiction() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -374,6 +382,7 @@ func (m fieldseekerStormdrainMods) RandomizeAllColumns(f *faker.Faker) Fieldseek FieldseekerStormdrainMods.RandomEditor(f), FieldseekerStormdrainMods.RandomType(f), FieldseekerStormdrainMods.RandomJurisdiction(f), + FieldseekerStormdrainMods.RandomVersion(f), } } @@ -1362,6 +1371,37 @@ func (m fieldseekerStormdrainMods) RandomJurisdictionNotNull(f *faker.Faker) Fie }) } +// Set the model columns to this value +func (m fieldseekerStormdrainMods) Version(val int32) FieldseekerStormdrainMod { + return FieldseekerStormdrainModFunc(func(_ context.Context, o *FieldseekerStormdrainTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerStormdrainMods) VersionFunc(f func() int32) FieldseekerStormdrainMod { + return FieldseekerStormdrainModFunc(func(_ context.Context, o *FieldseekerStormdrainTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerStormdrainMods) UnsetVersion() FieldseekerStormdrainMod { + return FieldseekerStormdrainModFunc(func(_ context.Context, o *FieldseekerStormdrainTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerStormdrainMods) RandomVersion(f *faker.Faker) FieldseekerStormdrainMod { + return FieldseekerStormdrainModFunc(func(_ context.Context, o *FieldseekerStormdrainTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerStormdrainMods) WithParentsCascading() FieldseekerStormdrainMod { return FieldseekerStormdrainModFunc(func(ctx context.Context, o *FieldseekerStormdrainTemplate) { if isDone, _ := fieldseekerStormdrainWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.timecard.bob.go b/db/factory/fieldseeker.timecard.bob.go index 2c78c3b0..44427144 100644 --- a/db/factory/fieldseeker.timecard.bob.go +++ b/db/factory/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -67,6 +67,7 @@ type FieldseekerTimecardTemplate struct { Editdate func() null.Val[time.Time] Editor func() null.Val[string] Rodentlocid func() null.Val[uuid.UUID] + Version func() int32 f *Factory @@ -201,6 +202,10 @@ func (o FieldseekerTimecardTemplate) BuildSetter() *models.FieldseekerTimecardSe val := o.Rodentlocid() m.Rodentlocid = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -307,6 +312,9 @@ func (o FieldseekerTimecardTemplate) Build() *models.FieldseekerTimecard { if o.Rodentlocid != nil { m.Rodentlocid = o.Rodentlocid() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -455,6 +463,7 @@ func (m fieldseekerTimecardMods) RandomizeAllColumns(f *faker.Faker) Fieldseeker FieldseekerTimecardMods.RandomEditdate(f), FieldseekerTimecardMods.RandomEditor(f), FieldseekerTimecardMods.RandomRodentlocid(f), + FieldseekerTimecardMods.RandomVersion(f), } } @@ -1922,6 +1931,37 @@ func (m fieldseekerTimecardMods) RandomRodentlocidNotNull(f *faker.Faker) Fields }) } +// Set the model columns to this value +func (m fieldseekerTimecardMods) Version(val int32) FieldseekerTimecardMod { + return FieldseekerTimecardModFunc(func(_ context.Context, o *FieldseekerTimecardTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerTimecardMods) VersionFunc(f func() int32) FieldseekerTimecardMod { + return FieldseekerTimecardModFunc(func(_ context.Context, o *FieldseekerTimecardTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerTimecardMods) UnsetVersion() FieldseekerTimecardMod { + return FieldseekerTimecardModFunc(func(_ context.Context, o *FieldseekerTimecardTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerTimecardMods) RandomVersion(f *faker.Faker) FieldseekerTimecardMod { + return FieldseekerTimecardModFunc(func(_ context.Context, o *FieldseekerTimecardTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerTimecardMods) WithParentsCascading() FieldseekerTimecardMod { return FieldseekerTimecardModFunc(func(ctx context.Context, o *FieldseekerTimecardTemplate) { if isDone, _ := fieldseekerTimecardWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.tracklog.bob.go b/db/factory/fieldseeker.tracklog.bob.go deleted file mode 100644 index 377fa181..00000000 --- a/db/factory/fieldseeker.tracklog.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerTracklogMod interface { - Apply(context.Context, *FieldseekerTracklogTemplate) -} - -type FieldseekerTracklogModFunc func(context.Context, *FieldseekerTracklogTemplate) - -func (f FieldseekerTracklogModFunc) Apply(ctx context.Context, n *FieldseekerTracklogTemplate) { - f(ctx, n) -} - -type FieldseekerTracklogModSlice []FieldseekerTracklogMod - -func (mods FieldseekerTracklogModSlice) Apply(ctx context.Context, n *FieldseekerTracklogTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerTracklogTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerTracklogTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerTracklogTemplate -func (o *FieldseekerTracklogTemplate) Apply(ctx context.Context, mods ...FieldseekerTracklogMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerTracklog -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerTracklogTemplate) setModelRels(o *models.FieldseekerTracklog) {} - -// Build returns an *models.FieldseekerTracklog -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerTracklogTemplate.Create -func (o FieldseekerTracklogTemplate) Build() *models.FieldseekerTracklog { - m := &models.FieldseekerTracklog{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerTracklogSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerTracklogTemplate.CreateMany -func (o FieldseekerTracklogTemplate) BuildMany(number int) models.FieldseekerTracklogSlice { - m := make(models.FieldseekerTracklogSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerTracklog has methods that act as mods for the FieldseekerTracklogTemplate -var FieldseekerTracklogMods fieldseekerTracklogMods - -type fieldseekerTracklogMods struct{} - -func (m fieldseekerTracklogMods) RandomizeAllColumns(f *faker.Faker) FieldseekerTracklogMod { - return FieldseekerTracklogModSlice{} -} - -func (m fieldseekerTracklogMods) WithParentsCascading() FieldseekerTracklogMod { - return FieldseekerTracklogModFunc(func(ctx context.Context, o *FieldseekerTracklogTemplate) { - if isDone, _ := fieldseekerTracklogWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerTracklogWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.trapdata.bob.go b/db/factory/fieldseeker.trapdata.bob.go index 22c233d8..6d94b410 100644 --- a/db/factory/fieldseeker.trapdata.bob.go +++ b/db/factory/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -81,6 +81,7 @@ type FieldseekerTrapdatumTemplate struct { Editdate func() null.Val[time.Time] Editor func() null.Val[string] Lure func() null.Val[enums.FieldseekerTrapdataTrapdataLure25fe542f077F4254868176e8f436354bEnu] + Version func() int32 f *Factory @@ -271,6 +272,10 @@ func (o FieldseekerTrapdatumTemplate) BuildSetter() *models.FieldseekerTrapdatum val := o.Lure() m.Lure = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -419,6 +424,9 @@ func (o FieldseekerTrapdatumTemplate) Build() *models.FieldseekerTrapdatum { if o.Lure != nil { m.Lure = o.Lure() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -581,6 +589,7 @@ func (m fieldseekerTrapdatumMods) RandomizeAllColumns(f *faker.Faker) Fieldseeke FieldseekerTrapdatumMods.RandomEditdate(f), FieldseekerTrapdatumMods.RandomEditor(f), FieldseekerTrapdatumMods.RandomLure(f), + FieldseekerTrapdatumMods.RandomVersion(f), } } @@ -2788,6 +2797,37 @@ func (m fieldseekerTrapdatumMods) RandomLureNotNull(f *faker.Faker) FieldseekerT }) } +// Set the model columns to this value +func (m fieldseekerTrapdatumMods) Version(val int32) FieldseekerTrapdatumMod { + return FieldseekerTrapdatumModFunc(func(_ context.Context, o *FieldseekerTrapdatumTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerTrapdatumMods) VersionFunc(f func() int32) FieldseekerTrapdatumMod { + return FieldseekerTrapdatumModFunc(func(_ context.Context, o *FieldseekerTrapdatumTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerTrapdatumMods) UnsetVersion() FieldseekerTrapdatumMod { + return FieldseekerTrapdatumModFunc(func(_ context.Context, o *FieldseekerTrapdatumTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerTrapdatumMods) RandomVersion(f *faker.Faker) FieldseekerTrapdatumMod { + return FieldseekerTrapdatumModFunc(func(_ context.Context, o *FieldseekerTrapdatumTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerTrapdatumMods) WithParentsCascading() FieldseekerTrapdatumMod { return FieldseekerTrapdatumModFunc(func(ctx context.Context, o *FieldseekerTrapdatumTemplate) { if isDone, _ := fieldseekerTrapdatumWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.traplocation.bob.go b/db/factory/fieldseeker.traplocation.bob.go index 54ab3e35..d7bbea66 100644 --- a/db/factory/fieldseeker.traplocation.bob.go +++ b/db/factory/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -69,6 +69,7 @@ type FieldseekerTraplocationTemplate struct { Editor func() null.Val[string] H3R7 func() null.Val[string] H3R8 func() null.Val[string] + Version func() int32 f *Factory @@ -211,6 +212,10 @@ func (o FieldseekerTraplocationTemplate) BuildSetter() *models.FieldseekerTraplo val := o.H3R8() m.H3R8 = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -323,6 +328,9 @@ func (o FieldseekerTraplocationTemplate) Build() *models.FieldseekerTraplocation if o.H3R8 != nil { m.H3R8 = o.H3R8() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -473,6 +481,7 @@ func (m fieldseekerTraplocationMods) RandomizeAllColumns(f *faker.Faker) Fieldse FieldseekerTraplocationMods.RandomEditor(f), FieldseekerTraplocationMods.RandomH3R7(f), FieldseekerTraplocationMods.RandomH3R8(f), + FieldseekerTraplocationMods.RandomVersion(f), } } @@ -2050,6 +2059,37 @@ func (m fieldseekerTraplocationMods) RandomH3R8NotNull(f *faker.Faker) Fieldseek }) } +// Set the model columns to this value +func (m fieldseekerTraplocationMods) Version(val int32) FieldseekerTraplocationMod { + return FieldseekerTraplocationModFunc(func(_ context.Context, o *FieldseekerTraplocationTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerTraplocationMods) VersionFunc(f func() int32) FieldseekerTraplocationMod { + return FieldseekerTraplocationModFunc(func(_ context.Context, o *FieldseekerTraplocationTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerTraplocationMods) UnsetVersion() FieldseekerTraplocationMod { + return FieldseekerTraplocationModFunc(func(_ context.Context, o *FieldseekerTraplocationTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerTraplocationMods) RandomVersion(f *faker.Faker) FieldseekerTraplocationMod { + return FieldseekerTraplocationModFunc(func(_ context.Context, o *FieldseekerTraplocationTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerTraplocationMods) WithParentsCascading() FieldseekerTraplocationMod { return FieldseekerTraplocationModFunc(func(ctx context.Context, o *FieldseekerTraplocationTemplate) { if isDone, _ := fieldseekerTraplocationWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.treatment.bob.go b/db/factory/fieldseeker.treatment.bob.go index bd8e58a4..830f0a80 100644 --- a/db/factory/fieldseeker.treatment.bob.go +++ b/db/factory/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -93,6 +93,7 @@ type FieldseekerTreatmentTemplate struct { Editdate func() null.Val[time.Time] Editor func() null.Val[string] Targetspecies func() null.Val[string] + Version func() int32 f *Factory @@ -331,6 +332,10 @@ func (o FieldseekerTreatmentTemplate) BuildSetter() *models.FieldseekerTreatment val := o.Targetspecies() m.Targetspecies = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -515,6 +520,9 @@ func (o FieldseekerTreatmentTemplate) Build() *models.FieldseekerTreatment { if o.Targetspecies != nil { m.Targetspecies = o.Targetspecies() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -689,6 +697,7 @@ func (m fieldseekerTreatmentMods) RandomizeAllColumns(f *faker.Faker) Fieldseeke FieldseekerTreatmentMods.RandomEditdate(f), FieldseekerTreatmentMods.RandomEditor(f), FieldseekerTreatmentMods.RandomTargetspecies(f), + FieldseekerTreatmentMods.RandomVersion(f), } } @@ -3538,6 +3547,37 @@ func (m fieldseekerTreatmentMods) RandomTargetspeciesNotNull(f *faker.Faker) Fie }) } +// Set the model columns to this value +func (m fieldseekerTreatmentMods) Version(val int32) FieldseekerTreatmentMod { + return FieldseekerTreatmentModFunc(func(_ context.Context, o *FieldseekerTreatmentTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerTreatmentMods) VersionFunc(f func() int32) FieldseekerTreatmentMod { + return FieldseekerTreatmentModFunc(func(_ context.Context, o *FieldseekerTreatmentTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerTreatmentMods) UnsetVersion() FieldseekerTreatmentMod { + return FieldseekerTreatmentModFunc(func(_ context.Context, o *FieldseekerTreatmentTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerTreatmentMods) RandomVersion(f *faker.Faker) FieldseekerTreatmentMod { + return FieldseekerTreatmentModFunc(func(_ context.Context, o *FieldseekerTreatmentTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerTreatmentMods) WithParentsCascading() FieldseekerTreatmentMod { return FieldseekerTreatmentModFunc(func(ctx context.Context, o *FieldseekerTreatmentTemplate) { if isDone, _ := fieldseekerTreatmentWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.treatmentarea.bob.go b/db/factory/fieldseeker.treatmentarea.bob.go index 6bd5fa90..b2ae78f3 100644 --- a/db/factory/fieldseeker.treatmentarea.bob.go +++ b/db/factory/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -56,6 +56,7 @@ type FieldseekerTreatmentareaTemplate struct { Editor func() null.Val[string] ShapeArea func() null.Val[float64] ShapeLength func() null.Val[float64] + Version func() int32 f *Factory @@ -150,6 +151,10 @@ func (o FieldseekerTreatmentareaTemplate) BuildSetter() *models.FieldseekerTreat val := o.ShapeLength() m.ShapeLength = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -226,6 +231,9 @@ func (o FieldseekerTreatmentareaTemplate) Build() *models.FieldseekerTreatmentar if o.ShapeLength != nil { m.ShapeLength = o.ShapeLength() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -364,6 +372,7 @@ func (m fieldseekerTreatmentareaMods) RandomizeAllColumns(f *faker.Faker) Fields FieldseekerTreatmentareaMods.RandomEditor(f), FieldseekerTreatmentareaMods.RandomShapeArea(f), FieldseekerTreatmentareaMods.RandomShapeLength(f), + FieldseekerTreatmentareaMods.RandomVersion(f), } } @@ -1299,6 +1308,37 @@ func (m fieldseekerTreatmentareaMods) RandomShapeLengthNotNull(f *faker.Faker) F }) } +// Set the model columns to this value +func (m fieldseekerTreatmentareaMods) Version(val int32) FieldseekerTreatmentareaMod { + return FieldseekerTreatmentareaModFunc(func(_ context.Context, o *FieldseekerTreatmentareaTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerTreatmentareaMods) VersionFunc(f func() int32) FieldseekerTreatmentareaMod { + return FieldseekerTreatmentareaModFunc(func(_ context.Context, o *FieldseekerTreatmentareaTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerTreatmentareaMods) UnsetVersion() FieldseekerTreatmentareaMod { + return FieldseekerTreatmentareaModFunc(func(_ context.Context, o *FieldseekerTreatmentareaTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerTreatmentareaMods) RandomVersion(f *faker.Faker) FieldseekerTreatmentareaMod { + return FieldseekerTreatmentareaModFunc(func(_ context.Context, o *FieldseekerTreatmentareaTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerTreatmentareaMods) WithParentsCascading() FieldseekerTreatmentareaMod { return FieldseekerTreatmentareaModFunc(func(ctx context.Context, o *FieldseekerTreatmentareaTemplate) { if isDone, _ := fieldseekerTreatmentareaWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.ulvsprayroute.bob.go b/db/factory/fieldseeker.ulvsprayroute.bob.go deleted file mode 100644 index 9766a8a6..00000000 --- a/db/factory/fieldseeker.ulvsprayroute.bob.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - - models "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/jaswdr/faker/v2" -) - -type FieldseekerUlvsprayrouteMod interface { - Apply(context.Context, *FieldseekerUlvsprayrouteTemplate) -} - -type FieldseekerUlvsprayrouteModFunc func(context.Context, *FieldseekerUlvsprayrouteTemplate) - -func (f FieldseekerUlvsprayrouteModFunc) Apply(ctx context.Context, n *FieldseekerUlvsprayrouteTemplate) { - f(ctx, n) -} - -type FieldseekerUlvsprayrouteModSlice []FieldseekerUlvsprayrouteMod - -func (mods FieldseekerUlvsprayrouteModSlice) Apply(ctx context.Context, n *FieldseekerUlvsprayrouteTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// FieldseekerUlvsprayrouteTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type FieldseekerUlvsprayrouteTemplate struct { - f *Factory - - alreadyPersisted bool -} - -// Apply mods to the FieldseekerUlvsprayrouteTemplate -func (o *FieldseekerUlvsprayrouteTemplate) Apply(ctx context.Context, mods ...FieldseekerUlvsprayrouteMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.FieldseekerUlvsprayroute -// according to the relationships in the template. Nothing is inserted into the db -func (t FieldseekerUlvsprayrouteTemplate) setModelRels(o *models.FieldseekerUlvsprayroute) {} - -// Build returns an *models.FieldseekerUlvsprayroute -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerUlvsprayrouteTemplate.Create -func (o FieldseekerUlvsprayrouteTemplate) Build() *models.FieldseekerUlvsprayroute { - m := &models.FieldseekerUlvsprayroute{} - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.FieldseekerUlvsprayrouteSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use FieldseekerUlvsprayrouteTemplate.CreateMany -func (o FieldseekerUlvsprayrouteTemplate) BuildMany(number int) models.FieldseekerUlvsprayrouteSlice { - m := make(models.FieldseekerUlvsprayrouteSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -// FieldseekerUlvsprayroute has methods that act as mods for the FieldseekerUlvsprayrouteTemplate -var FieldseekerUlvsprayrouteMods fieldseekerUlvsprayrouteMods - -type fieldseekerUlvsprayrouteMods struct{} - -func (m fieldseekerUlvsprayrouteMods) RandomizeAllColumns(f *faker.Faker) FieldseekerUlvsprayrouteMod { - return FieldseekerUlvsprayrouteModSlice{} -} - -func (m fieldseekerUlvsprayrouteMods) WithParentsCascading() FieldseekerUlvsprayrouteMod { - return FieldseekerUlvsprayrouteModFunc(func(ctx context.Context, o *FieldseekerUlvsprayrouteTemplate) { - if isDone, _ := fieldseekerUlvsprayrouteWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = fieldseekerUlvsprayrouteWithParentsCascadingCtx.WithValue(ctx, true) - }) -} diff --git a/db/factory/fieldseeker.zones.bob.go b/db/factory/fieldseeker.zones.bob.go index 20aa804b..eccd682d 100644 --- a/db/factory/fieldseeker.zones.bob.go +++ b/db/factory/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -52,6 +52,7 @@ type FieldseekerZoneTemplate struct { Editor func() null.Val[string] ShapeArea func() null.Val[float64] ShapeLength func() null.Val[float64] + Version func() int32 f *Factory @@ -130,6 +131,10 @@ func (o FieldseekerZoneTemplate) BuildSetter() *models.FieldseekerZoneSetter { val := o.ShapeLength() m.ShapeLength = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -194,6 +199,9 @@ func (o FieldseekerZoneTemplate) Build() *models.FieldseekerZone { if o.ShapeLength != nil { m.ShapeLength = o.ShapeLength() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -328,6 +336,7 @@ func (m fieldseekerZoneMods) RandomizeAllColumns(f *faker.Faker) FieldseekerZone FieldseekerZoneMods.RandomEditor(f), FieldseekerZoneMods.RandomShapeArea(f), FieldseekerZoneMods.RandomShapeLength(f), + FieldseekerZoneMods.RandomVersion(f), } } @@ -1051,6 +1060,37 @@ func (m fieldseekerZoneMods) RandomShapeLengthNotNull(f *faker.Faker) Fieldseeke }) } +// Set the model columns to this value +func (m fieldseekerZoneMods) Version(val int32) FieldseekerZoneMod { + return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerZoneMods) VersionFunc(f func() int32) FieldseekerZoneMod { + return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerZoneMods) UnsetVersion() FieldseekerZoneMod { + return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerZoneMods) RandomVersion(f *faker.Faker) FieldseekerZoneMod { + return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerZoneMods) WithParentsCascading() FieldseekerZoneMod { return FieldseekerZoneModFunc(func(ctx context.Context, o *FieldseekerZoneTemplate) { if isDone, _ := fieldseekerZoneWithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker.zones2.bob.go b/db/factory/fieldseeker.zones2.bob.go index 3e55b9c4..ca848ce2 100644 --- a/db/factory/fieldseeker.zones2.bob.go +++ b/db/factory/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -51,6 +51,7 @@ type FieldseekerZones2Template struct { Editor func() null.Val[string] ShapeArea func() null.Val[float64] ShapeLength func() null.Val[float64] + Version func() int32 f *Factory @@ -125,6 +126,10 @@ func (o FieldseekerZones2Template) BuildSetter() *models.FieldseekerZones2Setter val := o.ShapeLength() m.ShapeLength = omitnull.FromNull(val) } + if o.Version != nil { + val := o.Version() + m.Version = omit.From(val) + } return m } @@ -186,6 +191,9 @@ func (o FieldseekerZones2Template) Build() *models.FieldseekerZones2 { if o.ShapeLength != nil { m.ShapeLength = o.ShapeLength() } + if o.Version != nil { + m.Version = o.Version() + } o.setModelRels(m) @@ -319,6 +327,7 @@ func (m fieldseekerZones2Mods) RandomizeAllColumns(f *faker.Faker) FieldseekerZo FieldseekerZones2Mods.RandomEditor(f), FieldseekerZones2Mods.RandomShapeArea(f), FieldseekerZones2Mods.RandomShapeLength(f), + FieldseekerZones2Mods.RandomVersion(f), } } @@ -989,6 +998,37 @@ func (m fieldseekerZones2Mods) RandomShapeLengthNotNull(f *faker.Faker) Fieldsee }) } +// Set the model columns to this value +func (m fieldseekerZones2Mods) Version(val int32) FieldseekerZones2Mod { + return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) { + o.Version = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m fieldseekerZones2Mods) VersionFunc(f func() int32) FieldseekerZones2Mod { + return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) { + o.Version = f + }) +} + +// Clear any values for the column +func (m fieldseekerZones2Mods) UnsetVersion() FieldseekerZones2Mod { + return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) { + o.Version = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m fieldseekerZones2Mods) RandomVersion(f *faker.Faker) FieldseekerZones2Mod { + return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) { + o.Version = func() int32 { + return random_int32(f) + } + }) +} + func (m fieldseekerZones2Mods) WithParentsCascading() FieldseekerZones2Mod { return FieldseekerZones2ModFunc(func(ctx context.Context, o *FieldseekerZones2Template) { if isDone, _ := fieldseekerZones2WithParentsCascadingCtx.Value(ctx); isDone { diff --git a/db/factory/fieldseeker_sync.bob.go b/db/factory/fieldseeker_sync.bob.go index 42c1edb1..7e567ea9 100644 --- a/db/factory/fieldseeker_sync.bob.go +++ b/db/factory/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_containerrelate.bob.go b/db/factory/fs_containerrelate.bob.go index f05d883e..e3dcbabc 100644 --- a/db/factory/fs_containerrelate.bob.go +++ b/db/factory/fs_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_fieldscoutinglog.bob.go b/db/factory/fs_fieldscoutinglog.bob.go index 0782e51d..10eed1f8 100644 --- a/db/factory/fs_fieldscoutinglog.bob.go +++ b/db/factory/fs_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_habitatrelate.bob.go b/db/factory/fs_habitatrelate.bob.go index f6545163..15c39b13 100644 --- a/db/factory/fs_habitatrelate.bob.go +++ b/db/factory/fs_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_inspectionsample.bob.go b/db/factory/fs_inspectionsample.bob.go index ee040bec..997258fe 100644 --- a/db/factory/fs_inspectionsample.bob.go +++ b/db/factory/fs_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_inspectionsampledetail.bob.go b/db/factory/fs_inspectionsampledetail.bob.go index 61dd286d..4d035fc5 100644 --- a/db/factory/fs_inspectionsampledetail.bob.go +++ b/db/factory/fs_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_linelocation.bob.go b/db/factory/fs_linelocation.bob.go index b2dd2b40..07162ea8 100644 --- a/db/factory/fs_linelocation.bob.go +++ b/db/factory/fs_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_locationtracking.bob.go b/db/factory/fs_locationtracking.bob.go index 8e4e7ce0..c7fd4eeb 100644 --- a/db/factory/fs_locationtracking.bob.go +++ b/db/factory/fs_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_mosquitoinspection.bob.go b/db/factory/fs_mosquitoinspection.bob.go index 00a17596..01edd168 100644 --- a/db/factory/fs_mosquitoinspection.bob.go +++ b/db/factory/fs_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_pointlocation.bob.go b/db/factory/fs_pointlocation.bob.go index 0488e432..8f9a74ea 100644 --- a/db/factory/fs_pointlocation.bob.go +++ b/db/factory/fs_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_polygonlocation.bob.go b/db/factory/fs_polygonlocation.bob.go index adaebfd8..455e0192 100644 --- a/db/factory/fs_polygonlocation.bob.go +++ b/db/factory/fs_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_pool.bob.go b/db/factory/fs_pool.bob.go index 65f67bec..c02da508 100644 --- a/db/factory/fs_pool.bob.go +++ b/db/factory/fs_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_pooldetail.bob.go b/db/factory/fs_pooldetail.bob.go index 38b42f4b..cb869810 100644 --- a/db/factory/fs_pooldetail.bob.go +++ b/db/factory/fs_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_proposedtreatmentarea.bob.go b/db/factory/fs_proposedtreatmentarea.bob.go index 60148e2c..6e14ff17 100644 --- a/db/factory/fs_proposedtreatmentarea.bob.go +++ b/db/factory/fs_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_qamosquitoinspection.bob.go b/db/factory/fs_qamosquitoinspection.bob.go index ffc68f34..caab70da 100644 --- a/db/factory/fs_qamosquitoinspection.bob.go +++ b/db/factory/fs_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_rodentlocation.bob.go b/db/factory/fs_rodentlocation.bob.go index af5fa7a5..735df29c 100644 --- a/db/factory/fs_rodentlocation.bob.go +++ b/db/factory/fs_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_samplecollection.bob.go b/db/factory/fs_samplecollection.bob.go index f2e261b3..a4f52d96 100644 --- a/db/factory/fs_samplecollection.bob.go +++ b/db/factory/fs_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_samplelocation.bob.go b/db/factory/fs_samplelocation.bob.go index 5c13c7a7..7e0ec224 100644 --- a/db/factory/fs_samplelocation.bob.go +++ b/db/factory/fs_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_servicerequest.bob.go b/db/factory/fs_servicerequest.bob.go index 872070c0..39e15cf1 100644 --- a/db/factory/fs_servicerequest.bob.go +++ b/db/factory/fs_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_speciesabundance.bob.go b/db/factory/fs_speciesabundance.bob.go index 4565c360..7f3103de 100644 --- a/db/factory/fs_speciesabundance.bob.go +++ b/db/factory/fs_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_stormdrain.bob.go b/db/factory/fs_stormdrain.bob.go index a5a1d35b..57cf8897 100644 --- a/db/factory/fs_stormdrain.bob.go +++ b/db/factory/fs_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_timecard.bob.go b/db/factory/fs_timecard.bob.go index f1e5de12..d15333d6 100644 --- a/db/factory/fs_timecard.bob.go +++ b/db/factory/fs_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_trapdata.bob.go b/db/factory/fs_trapdata.bob.go index 4e351412..a7c8d426 100644 --- a/db/factory/fs_trapdata.bob.go +++ b/db/factory/fs_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_traplocation.bob.go b/db/factory/fs_traplocation.bob.go index ba0ba928..20ae25a1 100644 --- a/db/factory/fs_traplocation.bob.go +++ b/db/factory/fs_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_treatment.bob.go b/db/factory/fs_treatment.bob.go index 320bda57..517602a3 100644 --- a/db/factory/fs_treatment.bob.go +++ b/db/factory/fs_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_treatmentarea.bob.go b/db/factory/fs_treatmentarea.bob.go index a6a9aabf..0400b54a 100644 --- a/db/factory/fs_treatmentarea.bob.go +++ b/db/factory/fs_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_zones.bob.go b/db/factory/fs_zones.bob.go index f6c6bb92..3da3b686 100644 --- a/db/factory/fs_zones.bob.go +++ b/db/factory/fs_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fs_zones2.bob.go b/db/factory/fs_zones2.bob.go index 94c7cf28..6f1bb999 100644 --- a/db/factory/fs_zones2.bob.go +++ b/db/factory/fs_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/geography_columns.bob.go b/db/factory/geography_columns.bob.go index a3f61ac2..6c5a7591 100644 --- a/db/factory/geography_columns.bob.go +++ b/db/factory/geography_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/geometry_columns.bob.go b/db/factory/geometry_columns.bob.go index 335ff162..548afabe 100644 --- a/db/factory/geometry_columns.bob.go +++ b/db/factory/geometry_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/goose_db_version.bob.go b/db/factory/goose_db_version.bob.go index aba4837f..3c3d1e4e 100644 --- a/db/factory/goose_db_version.bob.go +++ b/db/factory/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/h3_aggregation.bob.go b/db/factory/h3_aggregation.bob.go index b63d1ebf..3f132999 100644 --- a/db/factory/h3_aggregation.bob.go +++ b/db/factory/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_containerrelate.bob.go b/db/factory/history_containerrelate.bob.go index b928ca99..1a1fea0a 100644 --- a/db/factory/history_containerrelate.bob.go +++ b/db/factory/history_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_fieldscoutinglog.bob.go b/db/factory/history_fieldscoutinglog.bob.go index b5b37939..cf95ac0c 100644 --- a/db/factory/history_fieldscoutinglog.bob.go +++ b/db/factory/history_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_habitatrelate.bob.go b/db/factory/history_habitatrelate.bob.go index 3266ada4..b2e9e4c9 100644 --- a/db/factory/history_habitatrelate.bob.go +++ b/db/factory/history_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_inspectionsample.bob.go b/db/factory/history_inspectionsample.bob.go index 318f6f9a..da882997 100644 --- a/db/factory/history_inspectionsample.bob.go +++ b/db/factory/history_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_inspectionsampledetail.bob.go b/db/factory/history_inspectionsampledetail.bob.go index b1c6d975..e6ef5cb0 100644 --- a/db/factory/history_inspectionsampledetail.bob.go +++ b/db/factory/history_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_linelocation.bob.go b/db/factory/history_linelocation.bob.go index ed823697..bd157e6a 100644 --- a/db/factory/history_linelocation.bob.go +++ b/db/factory/history_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_locationtracking.bob.go b/db/factory/history_locationtracking.bob.go index 03593ee0..a0ae01f6 100644 --- a/db/factory/history_locationtracking.bob.go +++ b/db/factory/history_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_mosquitoinspection.bob.go b/db/factory/history_mosquitoinspection.bob.go index 9b1b8039..fe8f2fde 100644 --- a/db/factory/history_mosquitoinspection.bob.go +++ b/db/factory/history_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_pointlocation.bob.go b/db/factory/history_pointlocation.bob.go index 7d9f045f..1aa24d63 100644 --- a/db/factory/history_pointlocation.bob.go +++ b/db/factory/history_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_polygonlocation.bob.go b/db/factory/history_polygonlocation.bob.go index 01092e6b..1421cb39 100644 --- a/db/factory/history_polygonlocation.bob.go +++ b/db/factory/history_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_pool.bob.go b/db/factory/history_pool.bob.go index b70bc89d..1be3703f 100644 --- a/db/factory/history_pool.bob.go +++ b/db/factory/history_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_pooldetail.bob.go b/db/factory/history_pooldetail.bob.go index 61a7d99f..84e37b16 100644 --- a/db/factory/history_pooldetail.bob.go +++ b/db/factory/history_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_proposedtreatmentarea.bob.go b/db/factory/history_proposedtreatmentarea.bob.go index 52255ad2..7ba5b8c4 100644 --- a/db/factory/history_proposedtreatmentarea.bob.go +++ b/db/factory/history_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_qamosquitoinspection.bob.go b/db/factory/history_qamosquitoinspection.bob.go index 0430825c..3362ea3c 100644 --- a/db/factory/history_qamosquitoinspection.bob.go +++ b/db/factory/history_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_rodentlocation.bob.go b/db/factory/history_rodentlocation.bob.go index b31962da..2edebd48 100644 --- a/db/factory/history_rodentlocation.bob.go +++ b/db/factory/history_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_samplecollection.bob.go b/db/factory/history_samplecollection.bob.go index c521f0c4..4de79ef3 100644 --- a/db/factory/history_samplecollection.bob.go +++ b/db/factory/history_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_samplelocation.bob.go b/db/factory/history_samplelocation.bob.go index d0babd48..7b07f2b8 100644 --- a/db/factory/history_samplelocation.bob.go +++ b/db/factory/history_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_servicerequest.bob.go b/db/factory/history_servicerequest.bob.go index 473d6c55..11e3b85f 100644 --- a/db/factory/history_servicerequest.bob.go +++ b/db/factory/history_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_speciesabundance.bob.go b/db/factory/history_speciesabundance.bob.go index 24e57128..9d0d5951 100644 --- a/db/factory/history_speciesabundance.bob.go +++ b/db/factory/history_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_stormdrain.bob.go b/db/factory/history_stormdrain.bob.go index 922b59b1..b9674369 100644 --- a/db/factory/history_stormdrain.bob.go +++ b/db/factory/history_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_timecard.bob.go b/db/factory/history_timecard.bob.go index 8503404e..93f6ca54 100644 --- a/db/factory/history_timecard.bob.go +++ b/db/factory/history_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_trapdata.bob.go b/db/factory/history_trapdata.bob.go index 52f490fe..e5d7bb52 100644 --- a/db/factory/history_trapdata.bob.go +++ b/db/factory/history_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_traplocation.bob.go b/db/factory/history_traplocation.bob.go index 5aaf7d6f..95c6e849 100644 --- a/db/factory/history_traplocation.bob.go +++ b/db/factory/history_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_treatment.bob.go b/db/factory/history_treatment.bob.go index 8ee91950..7390eded 100644 --- a/db/factory/history_treatment.bob.go +++ b/db/factory/history_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_treatmentarea.bob.go b/db/factory/history_treatmentarea.bob.go index 84e0997f..3ea3b1db 100644 --- a/db/factory/history_treatmentarea.bob.go +++ b/db/factory/history_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_zones.bob.go b/db/factory/history_zones.bob.go index 9176010a..ede15e6d 100644 --- a/db/factory/history_zones.bob.go +++ b/db/factory/history_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/history_zones2.bob.go b/db/factory/history_zones2.bob.go index ba305e06..6a670c49 100644 --- a/db/factory/history_zones2.bob.go +++ b/db/factory/history_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/notification.bob.go b/db/factory/notification.bob.go index c709aa51..545c1d87 100644 --- a/db/factory/notification.bob.go +++ b/db/factory/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/oauth_token.bob.go b/db/factory/oauth_token.bob.go index 328b78ed..5e5076f1 100644 --- a/db/factory/oauth_token.bob.go +++ b/db/factory/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/organization.bob.go b/db/factory/organization.bob.go index 173b8602..b449b008 100644 --- a/db/factory/organization.bob.go +++ b/db/factory/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -49,7 +49,6 @@ type OrganizationTemplate struct { } type organizationR struct { - Rodentlocations []*organizationRRodentlocationsR FieldseekerSyncs []*organizationRFieldseekerSyncsR FSContainerrelates []*organizationRFSContainerrelatesR FSFieldscoutinglogs []*organizationRFSFieldscoutinglogsR @@ -109,10 +108,6 @@ type organizationR struct { User []*organizationRUserR } -type organizationRRodentlocationsR struct { - number int - o *FieldseekerRodentlocationTemplate -} type organizationRFieldseekerSyncsR struct { number int o *FieldseekerSyncTemplate @@ -352,19 +347,6 @@ func (o *OrganizationTemplate) Apply(ctx context.Context, mods ...OrganizationMo // setModelRels creates and sets the relationships on *models.Organization // according to the relationships in the template. Nothing is inserted into the db func (t OrganizationTemplate) setModelRels(o *models.Organization) { - if t.r.Rodentlocations != nil { - rel := models.FieldseekerRodentlocationSlice{} - for _, r := range t.r.Rodentlocations { - related := r.o.BuildMany(r.number) - for _, rel := range related { - rel.OrganizationID = o.ID // h2 - rel.R.Organization = o - } - rel = append(rel, related...) - } - o.R.Rodentlocations = rel - } - if t.r.FieldseekerSyncs != nil { rel := models.FieldseekerSyncSlice{} for _, r := range t.r.FieldseekerSyncs { @@ -1197,26 +1179,6 @@ func ensureCreatableOrganization(m *models.OrganizationSetter) { func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.Organization) error { var err error - isRodentlocationsDone, _ := organizationRelRodentlocationsCtx.Value(ctx) - if !isRodentlocationsDone && o.r.Rodentlocations != nil { - ctx = organizationRelRodentlocationsCtx.WithValue(ctx, true) - for _, r := range o.r.Rodentlocations { - if r.o.alreadyPersisted { - m.R.Rodentlocations = append(m.R.Rodentlocations, r.o.Build()) - } else { - rel0, err := r.o.CreateMany(ctx, exec, r.number) - if err != nil { - return err - } - - err = m.AttachRodentlocations(ctx, exec, rel0...) - if err != nil { - return err - } - } - } - } - isFieldseekerSyncsDone, _ := organizationRelFieldseekerSyncsCtx.Value(ctx) if !isFieldseekerSyncsDone && o.r.FieldseekerSyncs != nil { ctx = organizationRelFieldseekerSyncsCtx.WithValue(ctx, true) @@ -1224,12 +1186,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FieldseekerSyncs = append(m.R.FieldseekerSyncs, r.o.Build()) } else { - rel1, err := r.o.CreateMany(ctx, exec, r.number) + rel0, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFieldseekerSyncs(ctx, exec, rel1...) + err = m.AttachFieldseekerSyncs(ctx, exec, rel0...) if err != nil { return err } @@ -1244,12 +1206,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSContainerrelates = append(m.R.FSContainerrelates, r.o.Build()) } else { - rel2, err := r.o.CreateMany(ctx, exec, r.number) + rel1, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSContainerrelates(ctx, exec, rel2...) + err = m.AttachFSContainerrelates(ctx, exec, rel1...) if err != nil { return err } @@ -1264,12 +1226,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSFieldscoutinglogs = append(m.R.FSFieldscoutinglogs, r.o.Build()) } else { - rel3, err := r.o.CreateMany(ctx, exec, r.number) + rel2, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSFieldscoutinglogs(ctx, exec, rel3...) + err = m.AttachFSFieldscoutinglogs(ctx, exec, rel2...) if err != nil { return err } @@ -1284,12 +1246,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSHabitatrelates = append(m.R.FSHabitatrelates, r.o.Build()) } else { - rel4, err := r.o.CreateMany(ctx, exec, r.number) + rel3, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSHabitatrelates(ctx, exec, rel4...) + err = m.AttachFSHabitatrelates(ctx, exec, rel3...) if err != nil { return err } @@ -1304,12 +1266,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSInspectionsamples = append(m.R.FSInspectionsamples, r.o.Build()) } else { - rel5, err := r.o.CreateMany(ctx, exec, r.number) + rel4, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSInspectionsamples(ctx, exec, rel5...) + err = m.AttachFSInspectionsamples(ctx, exec, rel4...) if err != nil { return err } @@ -1324,12 +1286,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSInspectionsampledetails = append(m.R.FSInspectionsampledetails, r.o.Build()) } else { - rel6, err := r.o.CreateMany(ctx, exec, r.number) + rel5, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSInspectionsampledetails(ctx, exec, rel6...) + err = m.AttachFSInspectionsampledetails(ctx, exec, rel5...) if err != nil { return err } @@ -1344,12 +1306,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSLinelocations = append(m.R.FSLinelocations, r.o.Build()) } else { - rel7, err := r.o.CreateMany(ctx, exec, r.number) + rel6, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSLinelocations(ctx, exec, rel7...) + err = m.AttachFSLinelocations(ctx, exec, rel6...) if err != nil { return err } @@ -1364,12 +1326,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSLocationtrackings = append(m.R.FSLocationtrackings, r.o.Build()) } else { - rel8, err := r.o.CreateMany(ctx, exec, r.number) + rel7, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSLocationtrackings(ctx, exec, rel8...) + err = m.AttachFSLocationtrackings(ctx, exec, rel7...) if err != nil { return err } @@ -1384,12 +1346,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSMosquitoinspections = append(m.R.FSMosquitoinspections, r.o.Build()) } else { - rel9, err := r.o.CreateMany(ctx, exec, r.number) + rel8, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSMosquitoinspections(ctx, exec, rel9...) + err = m.AttachFSMosquitoinspections(ctx, exec, rel8...) if err != nil { return err } @@ -1404,12 +1366,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSPointlocations = append(m.R.FSPointlocations, r.o.Build()) } else { - rel10, err := r.o.CreateMany(ctx, exec, r.number) + rel9, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSPointlocations(ctx, exec, rel10...) + err = m.AttachFSPointlocations(ctx, exec, rel9...) if err != nil { return err } @@ -1424,12 +1386,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSPolygonlocations = append(m.R.FSPolygonlocations, r.o.Build()) } else { - rel11, err := r.o.CreateMany(ctx, exec, r.number) + rel10, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSPolygonlocations(ctx, exec, rel11...) + err = m.AttachFSPolygonlocations(ctx, exec, rel10...) if err != nil { return err } @@ -1444,12 +1406,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSPools = append(m.R.FSPools, r.o.Build()) } else { - rel12, err := r.o.CreateMany(ctx, exec, r.number) + rel11, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSPools(ctx, exec, rel12...) + err = m.AttachFSPools(ctx, exec, rel11...) if err != nil { return err } @@ -1464,12 +1426,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSPooldetails = append(m.R.FSPooldetails, r.o.Build()) } else { - rel13, err := r.o.CreateMany(ctx, exec, r.number) + rel12, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSPooldetails(ctx, exec, rel13...) + err = m.AttachFSPooldetails(ctx, exec, rel12...) if err != nil { return err } @@ -1484,12 +1446,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSProposedtreatmentareas = append(m.R.FSProposedtreatmentareas, r.o.Build()) } else { - rel14, err := r.o.CreateMany(ctx, exec, r.number) + rel13, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSProposedtreatmentareas(ctx, exec, rel14...) + err = m.AttachFSProposedtreatmentareas(ctx, exec, rel13...) if err != nil { return err } @@ -1504,12 +1466,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSQamosquitoinspections = append(m.R.FSQamosquitoinspections, r.o.Build()) } else { - rel15, err := r.o.CreateMany(ctx, exec, r.number) + rel14, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSQamosquitoinspections(ctx, exec, rel15...) + err = m.AttachFSQamosquitoinspections(ctx, exec, rel14...) if err != nil { return err } @@ -1524,12 +1486,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSRodentlocations = append(m.R.FSRodentlocations, r.o.Build()) } else { - rel16, err := r.o.CreateMany(ctx, exec, r.number) + rel15, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSRodentlocations(ctx, exec, rel16...) + err = m.AttachFSRodentlocations(ctx, exec, rel15...) if err != nil { return err } @@ -1544,12 +1506,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSSamplecollections = append(m.R.FSSamplecollections, r.o.Build()) } else { - rel17, err := r.o.CreateMany(ctx, exec, r.number) + rel16, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSSamplecollections(ctx, exec, rel17...) + err = m.AttachFSSamplecollections(ctx, exec, rel16...) if err != nil { return err } @@ -1564,12 +1526,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSSamplelocations = append(m.R.FSSamplelocations, r.o.Build()) } else { - rel18, err := r.o.CreateMany(ctx, exec, r.number) + rel17, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSSamplelocations(ctx, exec, rel18...) + err = m.AttachFSSamplelocations(ctx, exec, rel17...) if err != nil { return err } @@ -1584,12 +1546,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSServicerequests = append(m.R.FSServicerequests, r.o.Build()) } else { - rel19, err := r.o.CreateMany(ctx, exec, r.number) + rel18, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSServicerequests(ctx, exec, rel19...) + err = m.AttachFSServicerequests(ctx, exec, rel18...) if err != nil { return err } @@ -1604,12 +1566,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSSpeciesabundances = append(m.R.FSSpeciesabundances, r.o.Build()) } else { - rel20, err := r.o.CreateMany(ctx, exec, r.number) + rel19, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSSpeciesabundances(ctx, exec, rel20...) + err = m.AttachFSSpeciesabundances(ctx, exec, rel19...) if err != nil { return err } @@ -1624,12 +1586,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSStormdrains = append(m.R.FSStormdrains, r.o.Build()) } else { - rel21, err := r.o.CreateMany(ctx, exec, r.number) + rel20, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSStormdrains(ctx, exec, rel21...) + err = m.AttachFSStormdrains(ctx, exec, rel20...) if err != nil { return err } @@ -1644,12 +1606,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSTimecards = append(m.R.FSTimecards, r.o.Build()) } else { - rel22, err := r.o.CreateMany(ctx, exec, r.number) + rel21, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSTimecards(ctx, exec, rel22...) + err = m.AttachFSTimecards(ctx, exec, rel21...) if err != nil { return err } @@ -1664,12 +1626,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSTrapdata = append(m.R.FSTrapdata, r.o.Build()) } else { - rel23, err := r.o.CreateMany(ctx, exec, r.number) + rel22, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSTrapdata(ctx, exec, rel23...) + err = m.AttachFSTrapdata(ctx, exec, rel22...) if err != nil { return err } @@ -1684,12 +1646,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSTraplocations = append(m.R.FSTraplocations, r.o.Build()) } else { - rel24, err := r.o.CreateMany(ctx, exec, r.number) + rel23, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSTraplocations(ctx, exec, rel24...) + err = m.AttachFSTraplocations(ctx, exec, rel23...) if err != nil { return err } @@ -1704,12 +1666,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSTreatments = append(m.R.FSTreatments, r.o.Build()) } else { - rel25, err := r.o.CreateMany(ctx, exec, r.number) + rel24, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSTreatments(ctx, exec, rel25...) + err = m.AttachFSTreatments(ctx, exec, rel24...) if err != nil { return err } @@ -1724,12 +1686,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSTreatmentareas = append(m.R.FSTreatmentareas, r.o.Build()) } else { - rel26, err := r.o.CreateMany(ctx, exec, r.number) + rel25, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSTreatmentareas(ctx, exec, rel26...) + err = m.AttachFSTreatmentareas(ctx, exec, rel25...) if err != nil { return err } @@ -1744,12 +1706,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSZones = append(m.R.FSZones, r.o.Build()) } else { - rel27, err := r.o.CreateMany(ctx, exec, r.number) + rel26, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSZones(ctx, exec, rel27...) + err = m.AttachFSZones(ctx, exec, rel26...) if err != nil { return err } @@ -1764,12 +1726,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.FSZones2s = append(m.R.FSZones2s, r.o.Build()) } else { - rel28, err := r.o.CreateMany(ctx, exec, r.number) + rel27, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachFSZones2s(ctx, exec, rel28...) + err = m.AttachFSZones2s(ctx, exec, rel27...) if err != nil { return err } @@ -1784,12 +1746,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.H3Aggregations = append(m.R.H3Aggregations, r.o.Build()) } else { - rel29, err := r.o.CreateMany(ctx, exec, r.number) + rel28, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachH3Aggregations(ctx, exec, rel29...) + err = m.AttachH3Aggregations(ctx, exec, rel28...) if err != nil { return err } @@ -1804,12 +1766,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryContainerrelates = append(m.R.HistoryContainerrelates, r.o.Build()) } else { - rel30, err := r.o.CreateMany(ctx, exec, r.number) + rel29, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryContainerrelates(ctx, exec, rel30...) + err = m.AttachHistoryContainerrelates(ctx, exec, rel29...) if err != nil { return err } @@ -1824,12 +1786,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryFieldscoutinglogs = append(m.R.HistoryFieldscoutinglogs, r.o.Build()) } else { - rel31, err := r.o.CreateMany(ctx, exec, r.number) + rel30, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryFieldscoutinglogs(ctx, exec, rel31...) + err = m.AttachHistoryFieldscoutinglogs(ctx, exec, rel30...) if err != nil { return err } @@ -1844,12 +1806,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryHabitatrelates = append(m.R.HistoryHabitatrelates, r.o.Build()) } else { - rel32, err := r.o.CreateMany(ctx, exec, r.number) + rel31, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryHabitatrelates(ctx, exec, rel32...) + err = m.AttachHistoryHabitatrelates(ctx, exec, rel31...) if err != nil { return err } @@ -1864,12 +1826,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryInspectionsamples = append(m.R.HistoryInspectionsamples, r.o.Build()) } else { - rel33, err := r.o.CreateMany(ctx, exec, r.number) + rel32, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryInspectionsamples(ctx, exec, rel33...) + err = m.AttachHistoryInspectionsamples(ctx, exec, rel32...) if err != nil { return err } @@ -1884,12 +1846,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryInspectionsampledetails = append(m.R.HistoryInspectionsampledetails, r.o.Build()) } else { - rel34, err := r.o.CreateMany(ctx, exec, r.number) + rel33, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryInspectionsampledetails(ctx, exec, rel34...) + err = m.AttachHistoryInspectionsampledetails(ctx, exec, rel33...) if err != nil { return err } @@ -1904,12 +1866,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryLinelocations = append(m.R.HistoryLinelocations, r.o.Build()) } else { - rel35, err := r.o.CreateMany(ctx, exec, r.number) + rel34, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryLinelocations(ctx, exec, rel35...) + err = m.AttachHistoryLinelocations(ctx, exec, rel34...) if err != nil { return err } @@ -1924,12 +1886,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryLocationtrackings = append(m.R.HistoryLocationtrackings, r.o.Build()) } else { - rel36, err := r.o.CreateMany(ctx, exec, r.number) + rel35, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryLocationtrackings(ctx, exec, rel36...) + err = m.AttachHistoryLocationtrackings(ctx, exec, rel35...) if err != nil { return err } @@ -1944,12 +1906,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryMosquitoinspections = append(m.R.HistoryMosquitoinspections, r.o.Build()) } else { - rel37, err := r.o.CreateMany(ctx, exec, r.number) + rel36, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryMosquitoinspections(ctx, exec, rel37...) + err = m.AttachHistoryMosquitoinspections(ctx, exec, rel36...) if err != nil { return err } @@ -1964,12 +1926,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryPointlocations = append(m.R.HistoryPointlocations, r.o.Build()) } else { - rel38, err := r.o.CreateMany(ctx, exec, r.number) + rel37, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryPointlocations(ctx, exec, rel38...) + err = m.AttachHistoryPointlocations(ctx, exec, rel37...) if err != nil { return err } @@ -1984,12 +1946,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryPolygonlocations = append(m.R.HistoryPolygonlocations, r.o.Build()) } else { - rel39, err := r.o.CreateMany(ctx, exec, r.number) + rel38, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryPolygonlocations(ctx, exec, rel39...) + err = m.AttachHistoryPolygonlocations(ctx, exec, rel38...) if err != nil { return err } @@ -2004,12 +1966,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryPools = append(m.R.HistoryPools, r.o.Build()) } else { - rel40, err := r.o.CreateMany(ctx, exec, r.number) + rel39, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryPools(ctx, exec, rel40...) + err = m.AttachHistoryPools(ctx, exec, rel39...) if err != nil { return err } @@ -2024,12 +1986,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryPooldetails = append(m.R.HistoryPooldetails, r.o.Build()) } else { - rel41, err := r.o.CreateMany(ctx, exec, r.number) + rel40, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryPooldetails(ctx, exec, rel41...) + err = m.AttachHistoryPooldetails(ctx, exec, rel40...) if err != nil { return err } @@ -2044,12 +2006,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryProposedtreatmentareas = append(m.R.HistoryProposedtreatmentareas, r.o.Build()) } else { - rel42, err := r.o.CreateMany(ctx, exec, r.number) + rel41, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryProposedtreatmentareas(ctx, exec, rel42...) + err = m.AttachHistoryProposedtreatmentareas(ctx, exec, rel41...) if err != nil { return err } @@ -2064,12 +2026,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryQamosquitoinspections = append(m.R.HistoryQamosquitoinspections, r.o.Build()) } else { - rel43, err := r.o.CreateMany(ctx, exec, r.number) + rel42, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryQamosquitoinspections(ctx, exec, rel43...) + err = m.AttachHistoryQamosquitoinspections(ctx, exec, rel42...) if err != nil { return err } @@ -2084,12 +2046,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryRodentlocations = append(m.R.HistoryRodentlocations, r.o.Build()) } else { - rel44, err := r.o.CreateMany(ctx, exec, r.number) + rel43, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryRodentlocations(ctx, exec, rel44...) + err = m.AttachHistoryRodentlocations(ctx, exec, rel43...) if err != nil { return err } @@ -2104,12 +2066,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistorySamplecollections = append(m.R.HistorySamplecollections, r.o.Build()) } else { - rel45, err := r.o.CreateMany(ctx, exec, r.number) + rel44, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistorySamplecollections(ctx, exec, rel45...) + err = m.AttachHistorySamplecollections(ctx, exec, rel44...) if err != nil { return err } @@ -2124,12 +2086,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistorySamplelocations = append(m.R.HistorySamplelocations, r.o.Build()) } else { - rel46, err := r.o.CreateMany(ctx, exec, r.number) + rel45, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistorySamplelocations(ctx, exec, rel46...) + err = m.AttachHistorySamplelocations(ctx, exec, rel45...) if err != nil { return err } @@ -2144,12 +2106,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryServicerequests = append(m.R.HistoryServicerequests, r.o.Build()) } else { - rel47, err := r.o.CreateMany(ctx, exec, r.number) + rel46, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryServicerequests(ctx, exec, rel47...) + err = m.AttachHistoryServicerequests(ctx, exec, rel46...) if err != nil { return err } @@ -2164,12 +2126,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistorySpeciesabundances = append(m.R.HistorySpeciesabundances, r.o.Build()) } else { - rel48, err := r.o.CreateMany(ctx, exec, r.number) + rel47, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistorySpeciesabundances(ctx, exec, rel48...) + err = m.AttachHistorySpeciesabundances(ctx, exec, rel47...) if err != nil { return err } @@ -2184,12 +2146,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryStormdrains = append(m.R.HistoryStormdrains, r.o.Build()) } else { - rel49, err := r.o.CreateMany(ctx, exec, r.number) + rel48, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryStormdrains(ctx, exec, rel49...) + err = m.AttachHistoryStormdrains(ctx, exec, rel48...) if err != nil { return err } @@ -2204,12 +2166,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryTimecards = append(m.R.HistoryTimecards, r.o.Build()) } else { - rel50, err := r.o.CreateMany(ctx, exec, r.number) + rel49, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryTimecards(ctx, exec, rel50...) + err = m.AttachHistoryTimecards(ctx, exec, rel49...) if err != nil { return err } @@ -2224,12 +2186,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryTrapdata = append(m.R.HistoryTrapdata, r.o.Build()) } else { - rel51, err := r.o.CreateMany(ctx, exec, r.number) + rel50, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryTrapdata(ctx, exec, rel51...) + err = m.AttachHistoryTrapdata(ctx, exec, rel50...) if err != nil { return err } @@ -2244,12 +2206,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryTraplocations = append(m.R.HistoryTraplocations, r.o.Build()) } else { - rel52, err := r.o.CreateMany(ctx, exec, r.number) + rel51, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryTraplocations(ctx, exec, rel52...) + err = m.AttachHistoryTraplocations(ctx, exec, rel51...) if err != nil { return err } @@ -2264,12 +2226,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryTreatments = append(m.R.HistoryTreatments, r.o.Build()) } else { - rel53, err := r.o.CreateMany(ctx, exec, r.number) + rel52, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryTreatments(ctx, exec, rel53...) + err = m.AttachHistoryTreatments(ctx, exec, rel52...) if err != nil { return err } @@ -2284,12 +2246,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryTreatmentareas = append(m.R.HistoryTreatmentareas, r.o.Build()) } else { - rel54, err := r.o.CreateMany(ctx, exec, r.number) + rel53, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryTreatmentareas(ctx, exec, rel54...) + err = m.AttachHistoryTreatmentareas(ctx, exec, rel53...) if err != nil { return err } @@ -2304,12 +2266,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryZones = append(m.R.HistoryZones, r.o.Build()) } else { - rel55, err := r.o.CreateMany(ctx, exec, r.number) + rel54, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryZones(ctx, exec, rel55...) + err = m.AttachHistoryZones(ctx, exec, rel54...) if err != nil { return err } @@ -2324,12 +2286,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.HistoryZones2s = append(m.R.HistoryZones2s, r.o.Build()) } else { - rel56, err := r.o.CreateMany(ctx, exec, r.number) + rel55, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachHistoryZones2s(ctx, exec, rel56...) + err = m.AttachHistoryZones2s(ctx, exec, rel55...) if err != nil { return err } @@ -2344,12 +2306,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.User = append(m.R.User, r.o.Build()) } else { - rel57, err := r.o.CreateMany(ctx, exec, r.number) + rel56, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachUser(ctx, exec, rel57...) + err = m.AttachUser(ctx, exec, rel56...) if err != nil { return err } @@ -2709,54 +2671,6 @@ func (m organizationMods) WithParentsCascading() OrganizationMod { }) } -func (m organizationMods) WithRodentlocations(number int, related *FieldseekerRodentlocationTemplate) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - o.r.Rodentlocations = []*organizationRRodentlocationsR{{ - number: number, - o: related, - }} - }) -} - -func (m organizationMods) WithNewRodentlocations(number int, mods ...FieldseekerRodentlocationMod) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - related := o.f.NewFieldseekerRodentlocationWithContext(ctx, mods...) - m.WithRodentlocations(number, related).Apply(ctx, o) - }) -} - -func (m organizationMods) AddRodentlocations(number int, related *FieldseekerRodentlocationTemplate) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - o.r.Rodentlocations = append(o.r.Rodentlocations, &organizationRRodentlocationsR{ - number: number, - o: related, - }) - }) -} - -func (m organizationMods) AddNewRodentlocations(number int, mods ...FieldseekerRodentlocationMod) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - related := o.f.NewFieldseekerRodentlocationWithContext(ctx, mods...) - m.AddRodentlocations(number, related).Apply(ctx, o) - }) -} - -func (m organizationMods) AddExistingRodentlocations(existingModels ...*models.FieldseekerRodentlocation) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - for _, em := range existingModels { - o.r.Rodentlocations = append(o.r.Rodentlocations, &organizationRRodentlocationsR{ - o: o.f.FromExistingFieldseekerRodentlocation(em), - }) - } - }) -} - -func (m organizationMods) WithoutRodentlocations() OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - o.r.Rodentlocations = nil - }) -} - func (m organizationMods) WithFieldseekerSyncs(number int, related *FieldseekerSyncTemplate) OrganizationMod { return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { o.r.FieldseekerSyncs = []*organizationRFieldseekerSyncsR{{ diff --git a/db/factory/raster_columns.bob.go b/db/factory/raster_columns.bob.go index a8ad209e..46263218 100644 --- a/db/factory/raster_columns.bob.go +++ b/db/factory/raster_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/raster_overviews.bob.go b/db/factory/raster_overviews.bob.go index b2d44703..6cf5e80e 100644 --- a/db/factory/raster_overviews.bob.go +++ b/db/factory/raster_overviews.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/sessions.bob.go b/db/factory/sessions.bob.go index fb459f1d..b6578f6e 100644 --- a/db/factory/sessions.bob.go +++ b/db/factory/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/spatial_ref_sys.bob.go b/db/factory/spatial_ref_sys.bob.go index 73ce16e4..08ae3011 100644 --- a/db/factory/spatial_ref_sys.bob.go +++ b/db/factory/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/user_.bob.go b/db/factory/user_.bob.go index 3705bf03..42017dd9 100644 --- a/db/factory/user_.bob.go +++ b/db/factory/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/fieldseeker-schema/containerrelate.sql b/db/fieldseeker-schema/containerrelate.sql deleted file mode 100644 index 47cf09f1..00000000 --- a/db/fieldseeker-schema/containerrelate.sql +++ /dev/null @@ -1,42 +0,0 @@ --- Table definition for fieldseeker.ContainerRelate --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.containerrelate_mosquitocontainertype_enum AS ENUM ( - 'Aquarium', - 'Flower pot', - '5 gallon bucket', - 'Fountain', - 'Bird bath' -); - -CREATE TABLE fieldseeker.containerrelate ( - objectid BIGSERIAL NOT NULL, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - inspsampleid UUID, - mosquitoinspid UUID, - treatmentid UUID, - containertype fieldseeker.containerrelate_mosquitocontainertype_enum, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.containerrelate.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.containerrelate.containertype IS 'Container Type'; - --- See insert/insert_containerrelate_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/fieldscoutinglog.sql b/db/fieldseeker-schema/fieldscoutinglog.sql deleted file mode 100644 index d3315a4c..00000000 --- a/db/fieldseeker-schema/fieldscoutinglog.sql +++ /dev/null @@ -1,38 +0,0 @@ --- Table definition for fieldseeker.FieldScoutingLog --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.fieldscoutinglog_fieldscoutingsymbology_enum AS ENUM ( - '0', - '1', - '2', - '3' -); - -CREATE TABLE fieldseeker.fieldscoutinglog ( - objectid BIGSERIAL NOT NULL, - status fieldseeker.fieldscoutinglog_fieldscoutingsymbology_enum, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.fieldscoutinglog.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.fieldscoutinglog.status IS 'Status'; - --- See insert/insert_fieldscoutinglog_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/habitatrelate.sql b/db/fieldseeker-schema/habitatrelate.sql deleted file mode 100644 index c20add75..00000000 --- a/db/fieldseeker-schema/habitatrelate.sql +++ /dev/null @@ -1,76 +0,0 @@ --- Table definition for fieldseeker.HabitatRelate --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.habitatrelate_habitatrelate_habitattype_2e81cf2f550e400783cf284f3cec3953_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetlands', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point' -); - -CREATE TABLE fieldseeker.habitatrelate ( - objectid BIGSERIAL NOT NULL, - foreign_id UUID, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - habitattype fieldseeker.habitatrelate_habitatrelate_habitattype_2e81cf2f550e400783cf284f3cec3953_enum, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.habitatrelate.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.habitatrelate.habitattype IS 'Habitat Type'; - --- See insert/insert_habitatrelate_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/insert/insert_containerrelate_versioned.sql b/db/fieldseeker-schema/insert/insert_containerrelate_versioned.sql index d2997e4a..dbda7da9 100644 --- a/db/fieldseeker-schema/insert/insert_containerrelate_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_containerrelate_versioned.sql @@ -1,64 +1,109 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.containerrelate --- Only inserts a new version if data has changed -PREPARE insert_containerrelate_versioned(bigint, uuid, varchar, timestamp, varchar, timestamp, uuid, uuid, uuid, fieldseeker.containerrelate_mosquitocontainertype_enum, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.containerrelate - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.containerrelate - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.containerrelate ( - objectid, globalid, created_user, created_date, last_edited_user, last_edited_date, inspsampleid, mosquitoinspid, treatmentid, containertype, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.globalid IS NOT DISTINCT FROM $2 AND - lv.created_user IS NOT DISTINCT FROM $3 AND - lv.created_date IS NOT DISTINCT FROM $4 AND - lv.last_edited_user IS NOT DISTINCT FROM $5 AND - lv.last_edited_date IS NOT DISTINCT FROM $6 AND - lv.inspsampleid IS NOT DISTINCT FROM $7 AND - lv.mosquitoinspid IS NOT DISTINCT FROM $8 AND - lv.treatmentid IS NOT DISTINCT FROM $9 AND - lv.containertype IS NOT DISTINCT FROM $10 AND - lv.creationdate IS NOT DISTINCT FROM $11 AND - lv.creator IS NOT DISTINCT FROM $12 AND - lv.editdate IS NOT DISTINCT FROM $13 AND - lv.editor IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_containerrelate_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: GlobalID (uuid) --- $3: created_user (varchar) --- $4: created_date (timestamp) --- $5: last_edited_user (varchar) --- $6: last_edited_date (timestamp) --- $7: INSPSAMPLEID (uuid) --- $8: MOSQUITOINSPID (uuid) --- $9: TREATMENTID (uuid) --- $10: CONTAINERTYPE (fieldseeker.containerrelate_mosquitocontainertype_enum) --- $11: CreationDate (timestamp) --- $12: Creator (varchar) --- $13: EditDate (timestamp) --- $14: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_containerrelate( + p_objectid bigint, + + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_inspsampleid uuid, + p_mosquitoinspid uuid, + p_treatmentid uuid, + p_containertype varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.containerrelate lv + WHERE lv.objectid = p_objectid + + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.inspsampleid IS NOT DISTINCT FROM p_inspsampleid + AND lv.mosquitoinspid IS NOT DISTINCT FROM p_mosquitoinspid + AND lv.treatmentid IS NOT DISTINCT FROM p_treatmentid + AND lv.containertype IS NOT DISTINCT FROM p_containertype + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.containerrelate + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.containerrelate + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.containerrelate ( + objectid, + + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + inspsampleid, + mosquitoinspid, + treatmentid, + containertype, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_inspsampleid, + p_mosquitoinspid, + p_treatmentid, + p_containertype, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_fieldscoutinglog_versioned.sql b/db/fieldseeker-schema/insert/insert_fieldscoutinglog_versioned.sql index 283bffb6..c4f10e63 100644 --- a/db/fieldseeker-schema/insert/insert_fieldscoutinglog_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_fieldscoutinglog_versioned.sql @@ -1,58 +1,97 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.fieldscoutinglog --- Only inserts a new version if data has changed -PREPARE insert_fieldscoutinglog_versioned(bigint, fieldseeker.fieldscoutinglog_fieldscoutingsymbology_enum, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.fieldscoutinglog - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.fieldscoutinglog - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.fieldscoutinglog ( - objectid, status, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.status IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.creationdate IS NOT DISTINCT FROM $8 AND - lv.creator IS NOT DISTINCT FROM $9 AND - lv.editdate IS NOT DISTINCT FROM $10 AND - lv.editor IS NOT DISTINCT FROM $11 - ) -RETURNING *; - --- Example usage: EXECUTE insert_fieldscoutinglog_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: STATUS (fieldseeker.fieldscoutinglog_fieldscoutingsymbology_enum) --- $3: GlobalID (uuid) --- $4: created_user (varchar) --- $5: created_date (timestamp) --- $6: last_edited_user (varchar) --- $7: last_edited_date (timestamp) --- $8: CreationDate (timestamp) --- $9: Creator (varchar) --- $10: EditDate (timestamp) --- $11: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_fieldscoutinglog( + p_objectid bigint, + + p_status smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.fieldscoutinglog lv + WHERE lv.objectid = p_objectid + + AND lv.status IS NOT DISTINCT FROM p_status + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.fieldscoutinglog + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.fieldscoutinglog + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.fieldscoutinglog ( + objectid, + + status, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_status, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_habitatrelate_versioned.sql b/db/fieldseeker-schema/insert/insert_habitatrelate_versioned.sql index 58025434..39ec987d 100644 --- a/db/fieldseeker-schema/insert/insert_habitatrelate_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_habitatrelate_versioned.sql @@ -1,60 +1,101 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.habitatrelate --- Only inserts a new version if data has changed -PREPARE insert_habitatrelate_versioned(bigint, uuid, uuid, varchar, timestamp, varchar, timestamp, fieldseeker.habitatrelate_habitatrelate_habitattype_2e81cf2f550e400783cf284f3cec3953_enum, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.habitatrelate - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.habitatrelate - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.habitatrelate ( - objectid, foreign_id, globalid, created_user, created_date, last_edited_user, last_edited_date, habitattype, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.foreign_id IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.habitattype IS NOT DISTINCT FROM $8 AND - lv.creationdate IS NOT DISTINCT FROM $9 AND - lv.creator IS NOT DISTINCT FROM $10 AND - lv.editdate IS NOT DISTINCT FROM $11 AND - lv.editor IS NOT DISTINCT FROM $12 - ) -RETURNING *; - --- Example usage: EXECUTE insert_habitatrelate_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: FOREIGN_ID (uuid) --- $3: GlobalID (uuid) --- $4: created_user (varchar) --- $5: created_date (timestamp) --- $6: last_edited_user (varchar) --- $7: last_edited_date (timestamp) --- $8: HABITATTYPE (fieldseeker.habitatrelate_habitatrelate_habitattype_2e81cf2f550e400783cf284f3cec3953_enum) --- $9: CreationDate (timestamp) --- $10: Creator (varchar) --- $11: EditDate (timestamp) --- $12: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_habitatrelate( + p_objectid bigint, + + p_foreign_id uuid, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_habitattype varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.habitatrelate lv + WHERE lv.objectid = p_objectid + + AND lv.foreign_id IS NOT DISTINCT FROM p_foreign_id + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.habitattype IS NOT DISTINCT FROM p_habitattype + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.habitatrelate + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.habitatrelate + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.habitatrelate ( + objectid, + + foreign_id, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + habitattype, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_foreign_id, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_habitattype, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_inspectionsample_versioned.sql b/db/fieldseeker-schema/insert/insert_inspectionsample_versioned.sql index 2e9c3552..498e2c16 100644 --- a/db/fieldseeker-schema/insert/insert_inspectionsample_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_inspectionsample_versioned.sql @@ -1,64 +1,109 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.inspectionsample --- Only inserts a new version if data has changed -PREPARE insert_inspectionsample_versioned(bigint, uuid, varchar, fieldseeker.inspectionsample_notinuit_f_enum, varchar, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.inspectionsample - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.inspectionsample - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.inspectionsample ( - objectid, insp_id, sampleid, processed, idbytech, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.insp_id IS NOT DISTINCT FROM $2 AND - lv.sampleid IS NOT DISTINCT FROM $3 AND - lv.processed IS NOT DISTINCT FROM $4 AND - lv.idbytech IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.creationdate IS NOT DISTINCT FROM $11 AND - lv.creator IS NOT DISTINCT FROM $12 AND - lv.editdate IS NOT DISTINCT FROM $13 AND - lv.editor IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_inspectionsample_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: INSP_ID (uuid) --- $3: SAMPLEID (varchar) --- $4: PROCESSED (fieldseeker.inspectionsample_notinuit_f_enum) --- $5: IDBYTECH (varchar) --- $6: GlobalID (uuid) --- $7: created_user (varchar) --- $8: created_date (timestamp) --- $9: last_edited_user (varchar) --- $10: last_edited_date (timestamp) --- $11: CreationDate (timestamp) --- $12: Creator (varchar) --- $13: EditDate (timestamp) --- $14: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_inspectionsample( + p_objectid bigint, + + p_insp_id uuid, + p_sampleid varchar, + p_processed smallint, + p_idbytech varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.inspectionsample lv + WHERE lv.objectid = p_objectid + + AND lv.insp_id IS NOT DISTINCT FROM p_insp_id + AND lv.sampleid IS NOT DISTINCT FROM p_sampleid + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.idbytech IS NOT DISTINCT FROM p_idbytech + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.inspectionsample + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.inspectionsample + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.inspectionsample ( + objectid, + + insp_id, + sampleid, + processed, + idbytech, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_insp_id, + p_sampleid, + p_processed, + p_idbytech, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_inspectionsampledetail_versioned.sql b/db/fieldseeker-schema/insert/insert_inspectionsampledetail_versioned.sql index 6ffccb66..c6f07d83 100644 --- a/db/fieldseeker-schema/insert/insert_inspectionsampledetail_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_inspectionsampledetail_versioned.sql @@ -1,86 +1,153 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.inspectionsampledetail --- Only inserts a new version if data has changed -PREPARE insert_inspectionsampledetail_versioned(bigint, uuid, fieldseeker.inspectionsampledetail_mosquitofieldspecies_enum, smallint, smallint, smallint, varchar, fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, fieldseeker.inspectionsampledetail_mosquitoadultactivity_enum, varchar, smallint, smallint, smallint, fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, varchar, uuid, varchar, timestamp, varchar, timestamp, smallint, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.inspectionsampledetail - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.inspectionsampledetail - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.inspectionsampledetail ( - objectid, inspsample_id, fieldspecies, flarvcount, fpupcount, feggcount, flstages, fdomstage, fadultact, labspecies, llarvcount, lpupcount, leggcount, ldomstage, comments, globalid, created_user, created_date, last_edited_user, last_edited_date, processed, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.inspsample_id IS NOT DISTINCT FROM $2 AND - lv.fieldspecies IS NOT DISTINCT FROM $3 AND - lv.flarvcount IS NOT DISTINCT FROM $4 AND - lv.fpupcount IS NOT DISTINCT FROM $5 AND - lv.feggcount IS NOT DISTINCT FROM $6 AND - lv.flstages IS NOT DISTINCT FROM $7 AND - lv.fdomstage IS NOT DISTINCT FROM $8 AND - lv.fadultact IS NOT DISTINCT FROM $9 AND - lv.labspecies IS NOT DISTINCT FROM $10 AND - lv.llarvcount IS NOT DISTINCT FROM $11 AND - lv.lpupcount IS NOT DISTINCT FROM $12 AND - lv.leggcount IS NOT DISTINCT FROM $13 AND - lv.ldomstage IS NOT DISTINCT FROM $14 AND - lv.comments IS NOT DISTINCT FROM $15 AND - lv.globalid IS NOT DISTINCT FROM $16 AND - lv.created_user IS NOT DISTINCT FROM $17 AND - lv.created_date IS NOT DISTINCT FROM $18 AND - lv.last_edited_user IS NOT DISTINCT FROM $19 AND - lv.last_edited_date IS NOT DISTINCT FROM $20 AND - lv.processed IS NOT DISTINCT FROM $21 AND - lv.creationdate IS NOT DISTINCT FROM $22 AND - lv.creator IS NOT DISTINCT FROM $23 AND - lv.editdate IS NOT DISTINCT FROM $24 AND - lv.editor IS NOT DISTINCT FROM $25 - ) -RETURNING *; - --- Example usage: EXECUTE insert_inspectionsampledetail_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: INSPSAMPLE_ID (uuid) --- $3: FIELDSPECIES (fieldseeker.inspectionsampledetail_mosquitofieldspecies_enum) --- $4: FLARVCOUNT (smallint) --- $5: FPUPCOUNT (smallint) --- $6: FEGGCOUNT (smallint) --- $7: FLSTAGES (varchar) --- $8: FDOMSTAGE (fieldseeker.inspectionsampledetail_mosquitodominantstage_enum) --- $9: FADULTACT (fieldseeker.inspectionsampledetail_mosquitoadultactivity_enum) --- $10: LABSPECIES (varchar) --- $11: LLARVCOUNT (smallint) --- $12: LPUPCOUNT (smallint) --- $13: LEGGCOUNT (smallint) --- $14: LDOMSTAGE (fieldseeker.inspectionsampledetail_mosquitodominantstage_enum) --- $15: COMMENTS (varchar) --- $16: GlobalID (uuid) --- $17: created_user (varchar) --- $18: created_date (timestamp) --- $19: last_edited_user (varchar) --- $20: last_edited_date (timestamp) --- $21: PROCESSED (smallint) --- $22: CreationDate (timestamp) --- $23: Creator (varchar) --- $24: EditDate (timestamp) --- $25: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_inspectionsampledetail( + p_objectid bigint, + + p_inspsample_id uuid, + p_fieldspecies varchar, + p_flarvcount smallint, + p_fpupcount smallint, + p_feggcount smallint, + p_flstages varchar, + p_fdomstage varchar, + p_fadultact varchar, + p_labspecies varchar, + p_llarvcount smallint, + p_lpupcount smallint, + p_leggcount smallint, + p_ldomstage varchar, + p_comments varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_processed smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.inspectionsampledetail lv + WHERE lv.objectid = p_objectid + + AND lv.inspsample_id IS NOT DISTINCT FROM p_inspsample_id + AND lv.fieldspecies IS NOT DISTINCT FROM p_fieldspecies + AND lv.flarvcount IS NOT DISTINCT FROM p_flarvcount + AND lv.fpupcount IS NOT DISTINCT FROM p_fpupcount + AND lv.feggcount IS NOT DISTINCT FROM p_feggcount + AND lv.flstages IS NOT DISTINCT FROM p_flstages + AND lv.fdomstage IS NOT DISTINCT FROM p_fdomstage + AND lv.fadultact IS NOT DISTINCT FROM p_fadultact + AND lv.labspecies IS NOT DISTINCT FROM p_labspecies + AND lv.llarvcount IS NOT DISTINCT FROM p_llarvcount + AND lv.lpupcount IS NOT DISTINCT FROM p_lpupcount + AND lv.leggcount IS NOT DISTINCT FROM p_leggcount + AND lv.ldomstage IS NOT DISTINCT FROM p_ldomstage + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.inspectionsampledetail + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.inspectionsampledetail + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.inspectionsampledetail ( + objectid, + + inspsample_id, + fieldspecies, + flarvcount, + fpupcount, + feggcount, + flstages, + fdomstage, + fadultact, + labspecies, + llarvcount, + lpupcount, + leggcount, + ldomstage, + comments, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + processed, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_inspsample_id, + p_fieldspecies, + p_flarvcount, + p_fpupcount, + p_feggcount, + p_flstages, + p_fdomstage, + p_fadultact, + p_labspecies, + p_llarvcount, + p_lpupcount, + p_leggcount, + p_ldomstage, + p_comments, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_processed, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_linelocation_versioned.sql b/db/fieldseeker-schema/insert/insert_linelocation_versioned.sql index 31f85fe8..84ef42f8 100644 --- a/db/fieldseeker-schema/insert/insert_linelocation_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_linelocation_versioned.sql @@ -1,132 +1,245 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.linelocation --- Only inserts a new version if data has changed -PREPARE insert_linelocation_versioned(bigint, varchar, varchar, fieldseeker.linelocation_linelocation_habitat_fc51bdc4f1954df58206d69ce14182f3_enum, fieldseeker.linelocation_locationpriority_enum, fieldseeker.linelocation_linelocation_usetype_2aeca2e60d2f455c86fc34895dc80a02_enum, fieldseeker.linelocation_notinuit_f_enum, varchar, varchar, varchar, fieldseeker.linelocation_locationsymbology_enum, varchar, double precision, timestamp, smallint, double precision, double precision, varchar, integer, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, double precision, double precision, varchar, varchar, varchar, timestamp, varchar, double precision, varchar, double precision, varchar, varchar, double precision, double precision, varchar, fieldseeker.linelocation_linelocation_waterorigin_84723d92_306a_46f4_8ef1_69b55a916008_enum, timestamp, varchar, timestamp, varchar, varchar, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.linelocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.linelocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.linelocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, acres, nextactiondatescheduled, larvinspectinterval, length_ft, width_ft, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, hectares, lastinspectactivity, lasttreatactivity, length_meters, width_meters, lastinspectconditions, waterorigin, creationdate, creator, editdate, editor, jurisdiction, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.symbology IS NOT DISTINCT FROM $11 AND - lv.externalid IS NOT DISTINCT FROM $12 AND - lv.acres IS NOT DISTINCT FROM $13 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $14 AND - lv.larvinspectinterval IS NOT DISTINCT FROM $15 AND - lv.length_ft IS NOT DISTINCT FROM $16 AND - lv.width_ft IS NOT DISTINCT FROM $17 AND - lv.zone2 IS NOT DISTINCT FROM $18 AND - lv.locationnumber IS NOT DISTINCT FROM $19 AND - lv.globalid IS NOT DISTINCT FROM $20 AND - lv.created_user IS NOT DISTINCT FROM $21 AND - lv.created_date IS NOT DISTINCT FROM $22 AND - lv.last_edited_user IS NOT DISTINCT FROM $23 AND - lv.last_edited_date IS NOT DISTINCT FROM $24 AND - lv.lastinspectdate IS NOT DISTINCT FROM $25 AND - lv.lastinspectbreeding IS NOT DISTINCT FROM $26 AND - lv.lastinspectavglarvae IS NOT DISTINCT FROM $27 AND - lv.lastinspectavgpupae IS NOT DISTINCT FROM $28 AND - lv.lastinspectlstages IS NOT DISTINCT FROM $29 AND - lv.lastinspectactiontaken IS NOT DISTINCT FROM $30 AND - lv.lastinspectfieldspecies IS NOT DISTINCT FROM $31 AND - lv.lasttreatdate IS NOT DISTINCT FROM $32 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $33 AND - lv.lasttreatqty IS NOT DISTINCT FROM $34 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $35 AND - lv.hectares IS NOT DISTINCT FROM $36 AND - lv.lastinspectactivity IS NOT DISTINCT FROM $37 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $38 AND - lv.length_meters IS NOT DISTINCT FROM $39 AND - lv.width_meters IS NOT DISTINCT FROM $40 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $41 AND - lv.waterorigin IS NOT DISTINCT FROM $42 AND - lv.creationdate IS NOT DISTINCT FROM $43 AND - lv.creator IS NOT DISTINCT FROM $44 AND - lv.editdate IS NOT DISTINCT FROM $45 AND - lv.editor IS NOT DISTINCT FROM $46 AND - lv.jurisdiction IS NOT DISTINCT FROM $47 AND - lv.shape__length IS NOT DISTINCT FROM $48 - ) -RETURNING *; - --- Example usage: EXECUTE insert_linelocation_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NAME (varchar) --- $3: ZONE (varchar) --- $4: HABITAT (fieldseeker.linelocation_linelocation_habitat_fc51bdc4f1954df58206d69ce14182f3_enum) --- $5: PRIORITY (fieldseeker.linelocation_locationpriority_enum) --- $6: USETYPE (fieldseeker.linelocation_linelocation_usetype_2aeca2e60d2f455c86fc34895dc80a02_enum) --- $7: ACTIVE (fieldseeker.linelocation_notinuit_f_enum) --- $8: DESCRIPTION (varchar) --- $9: ACCESSDESC (varchar) --- $10: COMMENTS (varchar) --- $11: SYMBOLOGY (fieldseeker.linelocation_locationsymbology_enum) --- $12: EXTERNALID (varchar) --- $13: ACRES (double precision) --- $14: NEXTACTIONDATESCHEDULED (timestamp) --- $15: LARVINSPECTINTERVAL (smallint) --- $16: LENGTH_FT (double precision) --- $17: WIDTH_FT (double precision) --- $18: ZONE2 (varchar) --- $19: LOCATIONNUMBER (integer) --- $20: GlobalID (uuid) --- $21: created_user (varchar) --- $22: created_date (timestamp) --- $23: last_edited_user (varchar) --- $24: last_edited_date (timestamp) --- $25: LASTINSPECTDATE (timestamp) --- $26: LASTINSPECTBREEDING (varchar) --- $27: LASTINSPECTAVGLARVAE (double precision) --- $28: LASTINSPECTAVGPUPAE (double precision) --- $29: LASTINSPECTLSTAGES (varchar) --- $30: LASTINSPECTACTIONTAKEN (varchar) --- $31: LASTINSPECTFIELDSPECIES (varchar) --- $32: LASTTREATDATE (timestamp) --- $33: LASTTREATPRODUCT (varchar) --- $34: LASTTREATQTY (double precision) --- $35: LASTTREATQTYUNIT (varchar) --- $36: HECTARES (double precision) --- $37: LASTINSPECTACTIVITY (varchar) --- $38: LASTTREATACTIVITY (varchar) --- $39: LENGTH_METERS (double precision) --- $40: WIDTH_METERS (double precision) --- $41: LASTINSPECTCONDITIONS (varchar) --- $42: WATERORIGIN (fieldseeker.linelocation_linelocation_waterorigin_84723d92_306a_46f4_8ef1_69b55a916008_enum) --- $43: CreationDate (timestamp) --- $44: Creator (varchar) --- $45: EditDate (timestamp) --- $46: Editor (varchar) --- $47: JURISDICTION (varchar) --- $48: Shape__Length (double precision) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_linelocation( + p_objectid bigint, + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_symbology varchar, + p_externalid varchar, + p_acres double precision, + p_nextactiondatescheduled timestamp, + p_larvinspectinterval smallint, + p_length_ft double precision, + p_width_ft double precision, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_lastinspectdate timestamp, + p_lastinspectbreeding varchar, + p_lastinspectavglarvae double precision, + p_lastinspectavgpupae double precision, + p_lastinspectlstages varchar, + p_lastinspectactiontaken varchar, + p_lastinspectfieldspecies varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_hectares double precision, + p_lastinspectactivity varchar, + p_lasttreatactivity varchar, + p_length_meters double precision, + p_width_meters double precision, + p_lastinspectconditions varchar, + p_waterorigin varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.linelocation lv + WHERE lv.objectid = p_objectid + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.acres IS NOT DISTINCT FROM p_acres + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval + AND lv.length_ft IS NOT DISTINCT FROM p_length_ft + AND lv.width_ft IS NOT DISTINCT FROM p_width_ft + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding + AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae + AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae + AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages + AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken + AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.hectares IS NOT DISTINCT FROM p_hectares + AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.length_meters IS NOT DISTINCT FROM p_length_meters + AND lv.width_meters IS NOT DISTINCT FROM p_width_meters + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.linelocation + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.linelocation + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.linelocation ( + objectid, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + acres, + nextactiondatescheduled, + larvinspectinterval, + length_ft, + width_ft, + zone2, + locationnumber, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + lastinspectdate, + lastinspectbreeding, + lastinspectavglarvae, + lastinspectavgpupae, + lastinspectlstages, + lastinspectactiontaken, + lastinspectfieldspecies, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + hectares, + lastinspectactivity, + lasttreatactivity, + length_meters, + width_meters, + lastinspectconditions, + waterorigin, + creationdate, + creator, + editdate, + editor, + jurisdiction, + shape__length, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_acres, + p_nextactiondatescheduled, + p_larvinspectinterval, + p_length_ft, + p_width_ft, + p_zone2, + p_locationnumber, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_lastinspectdate, + p_lastinspectbreeding, + p_lastinspectavglarvae, + p_lastinspectavgpupae, + p_lastinspectlstages, + p_lastinspectactiontaken, + p_lastinspectfieldspecies, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_hectares, + p_lastinspectactivity, + p_lasttreatactivity, + p_length_meters, + p_width_meters, + p_lastinspectconditions, + p_waterorigin, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_shape__length, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_locationtracking_versioned.sql b/db/fieldseeker-schema/insert/insert_locationtracking_versioned.sql index d2199a51..f6b9daea 100644 --- a/db/fieldseeker-schema/insert/insert_locationtracking_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_locationtracking_versioned.sql @@ -1,60 +1,101 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.locationtracking --- Only inserts a new version if data has changed -PREPARE insert_locationtracking_versioned(bigint, double precision, varchar, timestamp, varchar, timestamp, uuid, varchar, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.locationtracking - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.locationtracking - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.locationtracking ( - objectid, accuracy, created_user, created_date, last_edited_user, last_edited_date, globalid, fieldtech, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.accuracy IS NOT DISTINCT FROM $2 AND - lv.created_user IS NOT DISTINCT FROM $3 AND - lv.created_date IS NOT DISTINCT FROM $4 AND - lv.last_edited_user IS NOT DISTINCT FROM $5 AND - lv.last_edited_date IS NOT DISTINCT FROM $6 AND - lv.globalid IS NOT DISTINCT FROM $7 AND - lv.fieldtech IS NOT DISTINCT FROM $8 AND - lv.creationdate IS NOT DISTINCT FROM $9 AND - lv.creator IS NOT DISTINCT FROM $10 AND - lv.editdate IS NOT DISTINCT FROM $11 AND - lv.editor IS NOT DISTINCT FROM $12 - ) -RETURNING *; - --- Example usage: EXECUTE insert_locationtracking_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: Accuracy (double precision) --- $3: created_user (varchar) --- $4: created_date (timestamp) --- $5: last_edited_user (varchar) --- $6: last_edited_date (timestamp) --- $7: GlobalID (uuid) --- $8: FIELDTECH (varchar) --- $9: CreationDate (timestamp) --- $10: Creator (varchar) --- $11: EditDate (timestamp) --- $12: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_locationtracking( + p_objectid bigint, + + p_accuracy double precision, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_globalid uuid, + p_fieldtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.locationtracking lv + WHERE lv.objectid = p_objectid + + AND lv.accuracy IS NOT DISTINCT FROM p_accuracy + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.locationtracking + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.locationtracking + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.locationtracking ( + objectid, + + accuracy, + created_user, + created_date, + last_edited_user, + last_edited_date, + globalid, + fieldtech, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_accuracy, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_globalid, + p_fieldtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_mosquitoinspection_versioned.sql b/db/fieldseeker-schema/insert/insert_mosquitoinspection_versioned.sql index 8da99b47..7674e201 100644 --- a/db/fieldseeker-schema/insert/insert_mosquitoinspection_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_mosquitoinspection_versioned.sql @@ -1,150 +1,281 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.mosquitoinspection --- Only inserts a new version if data has changed -PREPARE insert_mosquitoinspection_versioned(bigint, smallint, fieldseeker.mosquitoinspection_mosquitoactivity_enum, fieldseeker.mosquitoinspection_mosquitobreeding_enum, smallint, smallint, smallint, smallint, fieldseeker.mosquitoinspection_mosquitoadultactivity_enum, varchar, fieldseeker.mosquitoinspection_mosquitoinspection_domstage_b7a6c36bccde49a292020de4812cf5ae_enum, fieldseeker.mosquitoinspection_mosquitoinspection_actiontaken_252243d69b0b44ddbdc229c04ec3a8d5_enum, varchar, double precision, double precision, double precision, timestamp, timestamp, fieldseeker.mosquitoinspection_notinuiwinddirection_enum, double precision, double precision, fieldseeker.mosquitoinspection_notinuit_f_enum, varchar, timestamp, varchar, varchar, smallint, varchar, fieldseeker.mosquitoinspection_notinuit_f_enum, smallint, smallint, smallint, fieldseeker.mosquitoinspection_mosquitofieldspecies_enum, uuid, varchar, timestamp, varchar, timestamp, uuid, uuid, uuid, uuid, varchar, fieldseeker.mosquitoinspection_notinuit_f_enum, fieldseeker.mosquitoinspection_notinuit_f_enum, uuid, fieldseeker.mosquitoinspection_mosquitoinspection_sitecond_db7350bc_81e5_401e_858f_cd3e5e5d8a34_enum, smallint, timestamp, varchar, timestamp, varchar, varchar, fieldseeker.mosquitoinspection_notinuit_f_enum, varchar, fieldseeker.mosquitoinspection_mosquitoinspection_adminaction_b74ae1bb_c98b_40f6_8cfa_40e4fd16c270_enum, uuid) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.mosquitoinspection - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.mosquitoinspection - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.mosquitoinspection ( - objectid, numdips, activity, breeding, totlarvae, totpupae, eggs, posdips, adultact, lstages, domstage, actiontaken, comments, avetemp, windspeed, raingauge, startdatetime, enddatetime, winddir, avglarvae, avgpupae, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, personalcontact, tirecount, cbcount, containercount, fieldspecies, globalid, created_user, created_date, last_edited_user, last_edited_date, linelocid, pointlocid, polygonlocid, srid, fieldtech, larvaepresent, pupaepresent, sdid, sitecond, positivecontainercount, creationdate, creator, editdate, editor, jurisdiction, visualmonitoring, vmcomments, adminaction, ptaid, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.numdips IS NOT DISTINCT FROM $2 AND - lv.activity IS NOT DISTINCT FROM $3 AND - lv.breeding IS NOT DISTINCT FROM $4 AND - lv.totlarvae IS NOT DISTINCT FROM $5 AND - lv.totpupae IS NOT DISTINCT FROM $6 AND - lv.eggs IS NOT DISTINCT FROM $7 AND - lv.posdips IS NOT DISTINCT FROM $8 AND - lv.adultact IS NOT DISTINCT FROM $9 AND - lv.lstages IS NOT DISTINCT FROM $10 AND - lv.domstage IS NOT DISTINCT FROM $11 AND - lv.actiontaken IS NOT DISTINCT FROM $12 AND - lv.comments IS NOT DISTINCT FROM $13 AND - lv.avetemp IS NOT DISTINCT FROM $14 AND - lv.windspeed IS NOT DISTINCT FROM $15 AND - lv.raingauge IS NOT DISTINCT FROM $16 AND - lv.startdatetime IS NOT DISTINCT FROM $17 AND - lv.enddatetime IS NOT DISTINCT FROM $18 AND - lv.winddir IS NOT DISTINCT FROM $19 AND - lv.avglarvae IS NOT DISTINCT FROM $20 AND - lv.avgpupae IS NOT DISTINCT FROM $21 AND - lv.reviewed IS NOT DISTINCT FROM $22 AND - lv.reviewedby IS NOT DISTINCT FROM $23 AND - lv.revieweddate IS NOT DISTINCT FROM $24 AND - lv.locationname IS NOT DISTINCT FROM $25 AND - lv.zone IS NOT DISTINCT FROM $26 AND - lv.recordstatus IS NOT DISTINCT FROM $27 AND - lv.zone2 IS NOT DISTINCT FROM $28 AND - lv.personalcontact IS NOT DISTINCT FROM $29 AND - lv.tirecount IS NOT DISTINCT FROM $30 AND - lv.cbcount IS NOT DISTINCT FROM $31 AND - lv.containercount IS NOT DISTINCT FROM $32 AND - lv.fieldspecies IS NOT DISTINCT FROM $33 AND - lv.globalid IS NOT DISTINCT FROM $34 AND - lv.created_user IS NOT DISTINCT FROM $35 AND - lv.created_date IS NOT DISTINCT FROM $36 AND - lv.last_edited_user IS NOT DISTINCT FROM $37 AND - lv.last_edited_date IS NOT DISTINCT FROM $38 AND - lv.linelocid IS NOT DISTINCT FROM $39 AND - lv.pointlocid IS NOT DISTINCT FROM $40 AND - lv.polygonlocid IS NOT DISTINCT FROM $41 AND - lv.srid IS NOT DISTINCT FROM $42 AND - lv.fieldtech IS NOT DISTINCT FROM $43 AND - lv.larvaepresent IS NOT DISTINCT FROM $44 AND - lv.pupaepresent IS NOT DISTINCT FROM $45 AND - lv.sdid IS NOT DISTINCT FROM $46 AND - lv.sitecond IS NOT DISTINCT FROM $47 AND - lv.positivecontainercount IS NOT DISTINCT FROM $48 AND - lv.creationdate IS NOT DISTINCT FROM $49 AND - lv.creator IS NOT DISTINCT FROM $50 AND - lv.editdate IS NOT DISTINCT FROM $51 AND - lv.editor IS NOT DISTINCT FROM $52 AND - lv.jurisdiction IS NOT DISTINCT FROM $53 AND - lv.visualmonitoring IS NOT DISTINCT FROM $54 AND - lv.vmcomments IS NOT DISTINCT FROM $55 AND - lv.adminaction IS NOT DISTINCT FROM $56 AND - lv.ptaid IS NOT DISTINCT FROM $57 - ) -RETURNING *; - --- Example usage: EXECUTE insert_mosquitoinspection_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NUMDIPS (smallint) --- $3: ACTIVITY (fieldseeker.mosquitoinspection_mosquitoactivity_enum) --- $4: BREEDING (fieldseeker.mosquitoinspection_mosquitobreeding_enum) --- $5: TOTLARVAE (smallint) --- $6: TOTPUPAE (smallint) --- $7: EGGS (smallint) --- $8: POSDIPS (smallint) --- $9: ADULTACT (fieldseeker.mosquitoinspection_mosquitoadultactivity_enum) --- $10: LSTAGES (varchar) --- $11: DOMSTAGE (fieldseeker.mosquitoinspection_mosquitoinspection_domstage_b7a6c36bccde49a292020de4812cf5ae_enum) --- $12: ACTIONTAKEN (fieldseeker.mosquitoinspection_mosquitoinspection_actiontaken_252243d69b0b44ddbdc229c04ec3a8d5_enum) --- $13: COMMENTS (varchar) --- $14: AVETEMP (double precision) --- $15: WINDSPEED (double precision) --- $16: RAINGAUGE (double precision) --- $17: STARTDATETIME (timestamp) --- $18: ENDDATETIME (timestamp) --- $19: WINDDIR (fieldseeker.mosquitoinspection_notinuiwinddirection_enum) --- $20: AVGLARVAE (double precision) --- $21: AVGPUPAE (double precision) --- $22: REVIEWED (fieldseeker.mosquitoinspection_notinuit_f_enum) --- $23: REVIEWEDBY (varchar) --- $24: REVIEWEDDATE (timestamp) --- $25: LOCATIONNAME (varchar) --- $26: ZONE (varchar) --- $27: RECORDSTATUS (smallint) --- $28: ZONE2 (varchar) --- $29: PERSONALCONTACT (fieldseeker.mosquitoinspection_notinuit_f_enum) --- $30: TIRECOUNT (smallint) --- $31: CBCOUNT (smallint) --- $32: CONTAINERCOUNT (smallint) --- $33: FIELDSPECIES (fieldseeker.mosquitoinspection_mosquitofieldspecies_enum) --- $34: GlobalID (uuid) --- $35: created_user (varchar) --- $36: created_date (timestamp) --- $37: last_edited_user (varchar) --- $38: last_edited_date (timestamp) --- $39: LINELOCID (uuid) --- $40: POINTLOCID (uuid) --- $41: POLYGONLOCID (uuid) --- $42: SRID (uuid) --- $43: FIELDTECH (varchar) --- $44: LARVAEPRESENT (fieldseeker.mosquitoinspection_notinuit_f_enum) --- $45: PUPAEPRESENT (fieldseeker.mosquitoinspection_notinuit_f_enum) --- $46: SDID (uuid) --- $47: SITECOND (fieldseeker.mosquitoinspection_mosquitoinspection_sitecond_db7350bc_81e5_401e_858f_cd3e5e5d8a34_enum) --- $48: POSITIVECONTAINERCOUNT (smallint) --- $49: CreationDate (timestamp) --- $50: Creator (varchar) --- $51: EditDate (timestamp) --- $52: Editor (varchar) --- $53: JURISDICTION (varchar) --- $54: VISUALMONITORING (fieldseeker.mosquitoinspection_notinuit_f_enum) --- $55: VMCOMMENTS (varchar) --- $56: adminAction (fieldseeker.mosquitoinspection_mosquitoinspection_adminaction_b74ae1bb_c98b_40f6_8cfa_40e4fd16c270_enum) --- $57: PTAID (uuid) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_mosquitoinspection( + p_objectid bigint, + + p_numdips smallint, + p_activity varchar, + p_breeding varchar, + p_totlarvae smallint, + p_totpupae smallint, + p_eggs smallint, + p_posdips smallint, + p_adultact varchar, + p_lstages varchar, + p_domstage varchar, + p_actiontaken varchar, + p_comments varchar, + p_avetemp double precision, + p_windspeed double precision, + p_raingauge double precision, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_winddir varchar, + p_avglarvae double precision, + p_avgpupae double precision, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_recordstatus smallint, + p_zone2 varchar, + p_personalcontact smallint, + p_tirecount smallint, + p_cbcount smallint, + p_containercount smallint, + p_fieldspecies varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_srid uuid, + p_fieldtech varchar, + p_larvaepresent smallint, + p_pupaepresent smallint, + p_sdid uuid, + p_sitecond varchar, + p_positivecontainercount smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_visualmonitoring smallint, + p_vmcomments varchar, + p_adminaction varchar, + p_ptaid uuid, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.mosquitoinspection lv + WHERE lv.objectid = p_objectid + + AND lv.numdips IS NOT DISTINCT FROM p_numdips + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.breeding IS NOT DISTINCT FROM p_breeding + AND lv.totlarvae IS NOT DISTINCT FROM p_totlarvae + AND lv.totpupae IS NOT DISTINCT FROM p_totpupae + AND lv.eggs IS NOT DISTINCT FROM p_eggs + AND lv.posdips IS NOT DISTINCT FROM p_posdips + AND lv.adultact IS NOT DISTINCT FROM p_adultact + AND lv.lstages IS NOT DISTINCT FROM p_lstages + AND lv.domstage IS NOT DISTINCT FROM p_domstage + AND lv.actiontaken IS NOT DISTINCT FROM p_actiontaken + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.avglarvae IS NOT DISTINCT FROM p_avglarvae + AND lv.avgpupae IS NOT DISTINCT FROM p_avgpupae + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.personalcontact IS NOT DISTINCT FROM p_personalcontact + AND lv.tirecount IS NOT DISTINCT FROM p_tirecount + AND lv.cbcount IS NOT DISTINCT FROM p_cbcount + AND lv.containercount IS NOT DISTINCT FROM p_containercount + AND lv.fieldspecies IS NOT DISTINCT FROM p_fieldspecies + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.larvaepresent IS NOT DISTINCT FROM p_larvaepresent + AND lv.pupaepresent IS NOT DISTINCT FROM p_pupaepresent + AND lv.sdid IS NOT DISTINCT FROM p_sdid + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.positivecontainercount IS NOT DISTINCT FROM p_positivecontainercount + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.visualmonitoring IS NOT DISTINCT FROM p_visualmonitoring + AND lv.vmcomments IS NOT DISTINCT FROM p_vmcomments + AND lv.adminaction IS NOT DISTINCT FROM p_adminaction + AND lv.ptaid IS NOT DISTINCT FROM p_ptaid + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.mosquitoinspection + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.mosquitoinspection + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.mosquitoinspection ( + objectid, + + numdips, + activity, + breeding, + totlarvae, + totpupae, + eggs, + posdips, + adultact, + lstages, + domstage, + actiontaken, + comments, + avetemp, + windspeed, + raingauge, + startdatetime, + enddatetime, + winddir, + avglarvae, + avgpupae, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + recordstatus, + zone2, + personalcontact, + tirecount, + cbcount, + containercount, + fieldspecies, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + linelocid, + pointlocid, + polygonlocid, + srid, + fieldtech, + larvaepresent, + pupaepresent, + sdid, + sitecond, + positivecontainercount, + creationdate, + creator, + editdate, + editor, + jurisdiction, + visualmonitoring, + vmcomments, + adminaction, + ptaid, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_numdips, + p_activity, + p_breeding, + p_totlarvae, + p_totpupae, + p_eggs, + p_posdips, + p_adultact, + p_lstages, + p_domstage, + p_actiontaken, + p_comments, + p_avetemp, + p_windspeed, + p_raingauge, + p_startdatetime, + p_enddatetime, + p_winddir, + p_avglarvae, + p_avgpupae, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_recordstatus, + p_zone2, + p_personalcontact, + p_tirecount, + p_cbcount, + p_containercount, + p_fieldspecies, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_srid, + p_fieldtech, + p_larvaepresent, + p_pupaepresent, + p_sdid, + p_sitecond, + p_positivecontainercount, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_visualmonitoring, + p_vmcomments, + p_adminaction, + p_ptaid, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_pointlocation_versioned.sql b/db/fieldseeker-schema/insert/insert_pointlocation_versioned.sql index d042c23f..c30e8bb6 100644 --- a/db/fieldseeker-schema/insert/insert_pointlocation_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_pointlocation_versioned.sql @@ -1,124 +1,229 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.pointlocation --- Only inserts a new version if data has changed -PREPARE insert_pointlocation_versioned(bigint, varchar, varchar, fieldseeker.pointlocation_pointlocation_habitat_b4d8135a_4979_49c8_8bb3_67ec7230e661_enum, fieldseeker.pointlocation_locationpriority_enum, fieldseeker.pointlocation_pointlocation_usetype_58d62d18ef4f47fc8cb9874df867f89e_enum, fieldseeker.pointlocation_notinuit_f_enum, varchar, varchar, varchar, fieldseeker.pointlocation_locationsymbology_enum, varchar, timestamp, smallint, varchar, integer, uuid, varchar, timestamp, varchar, double precision, double precision, varchar, varchar, varchar, timestamp, varchar, double precision, varchar, varchar, varchar, varchar, fieldseeker.pointlocation_pointlocation_waterorigin_197b22bf_f3eb_4dad_8899_986460f6ea97_enum, double precision, double precision, fieldseeker.pointlocation_pointlocation_assignedtech_9393a162_2474_429d_85be_daa44e4c091f_enum, timestamp, varchar, timestamp, varchar, varchar, fieldseeker.pointlocation_pointlocation_deactivate_reason_dd303085_b33c_4894_8c47_fa847dd9d7c5_enum, integer, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.pointlocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.pointlocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.pointlocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, nextactiondatescheduled, larvinspectinterval, zone2, locationnumber, globalid, stype, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, lastinspectactivity, lasttreatactivity, lastinspectconditions, waterorigin, x, y, assignedtech, creationdate, creator, editdate, editor, jurisdiction, deactivate_reason, scalarpriority, sourcestatus, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.symbology IS NOT DISTINCT FROM $11 AND - lv.externalid IS NOT DISTINCT FROM $12 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $13 AND - lv.larvinspectinterval IS NOT DISTINCT FROM $14 AND - lv.zone2 IS NOT DISTINCT FROM $15 AND - lv.locationnumber IS NOT DISTINCT FROM $16 AND - lv.globalid IS NOT DISTINCT FROM $17 AND - lv.stype IS NOT DISTINCT FROM $18 AND - lv.lastinspectdate IS NOT DISTINCT FROM $19 AND - lv.lastinspectbreeding IS NOT DISTINCT FROM $20 AND - lv.lastinspectavglarvae IS NOT DISTINCT FROM $21 AND - lv.lastinspectavgpupae IS NOT DISTINCT FROM $22 AND - lv.lastinspectlstages IS NOT DISTINCT FROM $23 AND - lv.lastinspectactiontaken IS NOT DISTINCT FROM $24 AND - lv.lastinspectfieldspecies IS NOT DISTINCT FROM $25 AND - lv.lasttreatdate IS NOT DISTINCT FROM $26 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $27 AND - lv.lasttreatqty IS NOT DISTINCT FROM $28 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $29 AND - lv.lastinspectactivity IS NOT DISTINCT FROM $30 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $31 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $32 AND - lv.waterorigin IS NOT DISTINCT FROM $33 AND - lv.x IS NOT DISTINCT FROM $34 AND - lv.y IS NOT DISTINCT FROM $35 AND - lv.assignedtech IS NOT DISTINCT FROM $36 AND - lv.creationdate IS NOT DISTINCT FROM $37 AND - lv.creator IS NOT DISTINCT FROM $38 AND - lv.editdate IS NOT DISTINCT FROM $39 AND - lv.editor IS NOT DISTINCT FROM $40 AND - lv.jurisdiction IS NOT DISTINCT FROM $41 AND - lv.deactivate_reason IS NOT DISTINCT FROM $42 AND - lv.scalarpriority IS NOT DISTINCT FROM $43 AND - lv.sourcestatus IS NOT DISTINCT FROM $44 - ) -RETURNING *; - --- Example usage: EXECUTE insert_pointlocation_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NAME (varchar) --- $3: ZONE (varchar) --- $4: HABITAT (fieldseeker.pointlocation_pointlocation_habitat_b4d8135a_4979_49c8_8bb3_67ec7230e661_enum) --- $5: PRIORITY (fieldseeker.pointlocation_locationpriority_enum) --- $6: USETYPE (fieldseeker.pointlocation_pointlocation_usetype_58d62d18ef4f47fc8cb9874df867f89e_enum) --- $7: ACTIVE (fieldseeker.pointlocation_notinuit_f_enum) --- $8: DESCRIPTION (varchar) --- $9: ACCESSDESC (varchar) --- $10: COMMENTS (varchar) --- $11: SYMBOLOGY (fieldseeker.pointlocation_locationsymbology_enum) --- $12: EXTERNALID (varchar) --- $13: NEXTACTIONDATESCHEDULED (timestamp) --- $14: LARVINSPECTINTERVAL (smallint) --- $15: ZONE2 (varchar) --- $16: LOCATIONNUMBER (integer) --- $17: GlobalID (uuid) --- $18: STYPE (varchar) --- $19: LASTINSPECTDATE (timestamp) --- $20: LASTINSPECTBREEDING (varchar) --- $21: LASTINSPECTAVGLARVAE (double precision) --- $22: LASTINSPECTAVGPUPAE (double precision) --- $23: LASTINSPECTLSTAGES (varchar) --- $24: LASTINSPECTACTIONTAKEN (varchar) --- $25: LASTINSPECTFIELDSPECIES (varchar) --- $26: LASTTREATDATE (timestamp) --- $27: LASTTREATPRODUCT (varchar) --- $28: LASTTREATQTY (double precision) --- $29: LASTTREATQTYUNIT (varchar) --- $30: LASTINSPECTACTIVITY (varchar) --- $31: LASTTREATACTIVITY (varchar) --- $32: LASTINSPECTCONDITIONS (varchar) --- $33: WATERORIGIN (fieldseeker.pointlocation_pointlocation_waterorigin_197b22bf_f3eb_4dad_8899_986460f6ea97_enum) --- $34: X (double precision) --- $35: Y (double precision) --- $36: ASSIGNEDTECH (fieldseeker.pointlocation_pointlocation_assignedtech_9393a162_2474_429d_85be_daa44e4c091f_enum) --- $37: CreationDate (timestamp) --- $38: Creator (varchar) --- $39: EditDate (timestamp) --- $40: Editor (varchar) --- $41: JURISDICTION (varchar) --- $42: deactivate_reason (fieldseeker.pointlocation_pointlocation_deactivate_reason_dd303085_b33c_4894_8c47_fa847dd9d7c5_enum) --- $43: scalarPriority (integer) --- $44: sourceStatus (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_pointlocation( + p_objectid bigint, + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_symbology varchar, + p_externalid varchar, + p_nextactiondatescheduled timestamp, + p_larvinspectinterval smallint, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_stype varchar, + p_lastinspectdate timestamp, + p_lastinspectbreeding varchar, + p_lastinspectavglarvae double precision, + p_lastinspectavgpupae double precision, + p_lastinspectlstages varchar, + p_lastinspectactiontaken varchar, + p_lastinspectfieldspecies varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_lastinspectactivity varchar, + p_lasttreatactivity varchar, + p_lastinspectconditions varchar, + p_waterorigin varchar, + p_x double precision, + p_y double precision, + p_assignedtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_deactivate_reason varchar, + p_scalarpriority integer, + p_sourcestatus varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.pointlocation lv + WHERE lv.objectid = p_objectid + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.stype IS NOT DISTINCT FROM p_stype + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding + AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae + AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae + AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages + AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken + AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin + AND lv.x IS NOT DISTINCT FROM p_x + AND lv.y IS NOT DISTINCT FROM p_y + AND lv.assignedtech IS NOT DISTINCT FROM p_assignedtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.deactivate_reason IS NOT DISTINCT FROM p_deactivate_reason + AND lv.scalarpriority IS NOT DISTINCT FROM p_scalarpriority + AND lv.sourcestatus IS NOT DISTINCT FROM p_sourcestatus + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.pointlocation + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.pointlocation + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.pointlocation ( + objectid, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + nextactiondatescheduled, + larvinspectinterval, + zone2, + locationnumber, + globalid, + stype, + lastinspectdate, + lastinspectbreeding, + lastinspectavglarvae, + lastinspectavgpupae, + lastinspectlstages, + lastinspectactiontaken, + lastinspectfieldspecies, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + lastinspectactivity, + lasttreatactivity, + lastinspectconditions, + waterorigin, + x, + y, + assignedtech, + creationdate, + creator, + editdate, + editor, + jurisdiction, + deactivate_reason, + scalarpriority, + sourcestatus, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_nextactiondatescheduled, + p_larvinspectinterval, + p_zone2, + p_locationnumber, + p_globalid, + p_stype, + p_lastinspectdate, + p_lastinspectbreeding, + p_lastinspectavglarvae, + p_lastinspectavgpupae, + p_lastinspectlstages, + p_lastinspectactiontaken, + p_lastinspectfieldspecies, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_lastinspectactivity, + p_lasttreatactivity, + p_lastinspectconditions, + p_waterorigin, + p_x, + p_y, + p_assignedtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_deactivate_reason, + p_scalarpriority, + p_sourcestatus, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_polygonlocation_versioned.sql b/db/fieldseeker-schema/insert/insert_polygonlocation_versioned.sql index feb7ae50..aa6e38e8 100644 --- a/db/fieldseeker-schema/insert/insert_polygonlocation_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_polygonlocation_versioned.sql @@ -1,120 +1,221 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.polygonlocation --- Only inserts a new version if data has changed -PREPARE insert_polygonlocation_versioned(bigint, varchar, varchar, fieldseeker.polygonlocation_polygonlocation_habitat_45e9dde79ac84d959df8b65ba7d5dafd_enum, fieldseeker.polygonlocation_locationpriority_enum, fieldseeker.polygonlocation_polygonlocation_usetype_e546154cb9544b9aa8e7b13e8e258b27_enum, fieldseeker.polygonlocation_notinuit_f_enum, varchar, varchar, varchar, fieldseeker.polygonlocation_locationsymbology_enum, varchar, double precision, timestamp, smallint, varchar, integer, uuid, timestamp, varchar, double precision, double precision, varchar, varchar, varchar, timestamp, varchar, double precision, varchar, double precision, varchar, varchar, varchar, fieldseeker.polygonlocation_polygonlocation_waterorigin_e9018e92_5f47_4ff9_8a7c_b818d848dc7a_enum, varchar, timestamp, varchar, timestamp, varchar, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.polygonlocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.polygonlocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.polygonlocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, acres, nextactiondatescheduled, larvinspectinterval, zone2, locationnumber, globalid, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, hectares, lastinspectactivity, lasttreatactivity, lastinspectconditions, waterorigin, filter, creationdate, creator, editdate, editor, jurisdiction, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.symbology IS NOT DISTINCT FROM $11 AND - lv.externalid IS NOT DISTINCT FROM $12 AND - lv.acres IS NOT DISTINCT FROM $13 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $14 AND - lv.larvinspectinterval IS NOT DISTINCT FROM $15 AND - lv.zone2 IS NOT DISTINCT FROM $16 AND - lv.locationnumber IS NOT DISTINCT FROM $17 AND - lv.globalid IS NOT DISTINCT FROM $18 AND - lv.lastinspectdate IS NOT DISTINCT FROM $19 AND - lv.lastinspectbreeding IS NOT DISTINCT FROM $20 AND - lv.lastinspectavglarvae IS NOT DISTINCT FROM $21 AND - lv.lastinspectavgpupae IS NOT DISTINCT FROM $22 AND - lv.lastinspectlstages IS NOT DISTINCT FROM $23 AND - lv.lastinspectactiontaken IS NOT DISTINCT FROM $24 AND - lv.lastinspectfieldspecies IS NOT DISTINCT FROM $25 AND - lv.lasttreatdate IS NOT DISTINCT FROM $26 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $27 AND - lv.lasttreatqty IS NOT DISTINCT FROM $28 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $29 AND - lv.hectares IS NOT DISTINCT FROM $30 AND - lv.lastinspectactivity IS NOT DISTINCT FROM $31 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $32 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $33 AND - lv.waterorigin IS NOT DISTINCT FROM $34 AND - lv.filter IS NOT DISTINCT FROM $35 AND - lv.creationdate IS NOT DISTINCT FROM $36 AND - lv.creator IS NOT DISTINCT FROM $37 AND - lv.editdate IS NOT DISTINCT FROM $38 AND - lv.editor IS NOT DISTINCT FROM $39 AND - lv.jurisdiction IS NOT DISTINCT FROM $40 AND - lv.shape__area IS NOT DISTINCT FROM $41 AND - lv.shape__length IS NOT DISTINCT FROM $42 - ) -RETURNING *; - --- Example usage: EXECUTE insert_polygonlocation_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NAME (varchar) --- $3: ZONE (varchar) --- $4: HABITAT (fieldseeker.polygonlocation_polygonlocation_habitat_45e9dde79ac84d959df8b65ba7d5dafd_enum) --- $5: PRIORITY (fieldseeker.polygonlocation_locationpriority_enum) --- $6: USETYPE (fieldseeker.polygonlocation_polygonlocation_usetype_e546154cb9544b9aa8e7b13e8e258b27_enum) --- $7: ACTIVE (fieldseeker.polygonlocation_notinuit_f_enum) --- $8: DESCRIPTION (varchar) --- $9: ACCESSDESC (varchar) --- $10: COMMENTS (varchar) --- $11: SYMBOLOGY (fieldseeker.polygonlocation_locationsymbology_enum) --- $12: EXTERNALID (varchar) --- $13: ACRES (double precision) --- $14: NEXTACTIONDATESCHEDULED (timestamp) --- $15: LARVINSPECTINTERVAL (smallint) --- $16: ZONE2 (varchar) --- $17: LOCATIONNUMBER (integer) --- $18: GlobalID (uuid) --- $19: LASTINSPECTDATE (timestamp) --- $20: LASTINSPECTBREEDING (varchar) --- $21: LASTINSPECTAVGLARVAE (double precision) --- $22: LASTINSPECTAVGPUPAE (double precision) --- $23: LASTINSPECTLSTAGES (varchar) --- $24: LASTINSPECTACTIONTAKEN (varchar) --- $25: LASTINSPECTFIELDSPECIES (varchar) --- $26: LASTTREATDATE (timestamp) --- $27: LASTTREATPRODUCT (varchar) --- $28: LASTTREATQTY (double precision) --- $29: LASTTREATQTYUNIT (varchar) --- $30: HECTARES (double precision) --- $31: LASTINSPECTACTIVITY (varchar) --- $32: LASTTREATACTIVITY (varchar) --- $33: LASTINSPECTCONDITIONS (varchar) --- $34: WATERORIGIN (fieldseeker.polygonlocation_polygonlocation_waterorigin_e9018e92_5f47_4ff9_8a7c_b818d848dc7a_enum) --- $35: Filter (varchar) --- $36: CreationDate (timestamp) --- $37: Creator (varchar) --- $38: EditDate (timestamp) --- $39: Editor (varchar) --- $40: JURISDICTION (varchar) --- $41: Shape__Area (double precision) --- $42: Shape__Length (double precision) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_polygonlocation( + p_objectid bigint, + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_symbology varchar, + p_externalid varchar, + p_acres double precision, + p_nextactiondatescheduled timestamp, + p_larvinspectinterval smallint, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_lastinspectdate timestamp, + p_lastinspectbreeding varchar, + p_lastinspectavglarvae double precision, + p_lastinspectavgpupae double precision, + p_lastinspectlstages varchar, + p_lastinspectactiontaken varchar, + p_lastinspectfieldspecies varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_hectares double precision, + p_lastinspectactivity varchar, + p_lasttreatactivity varchar, + p_lastinspectconditions varchar, + p_waterorigin varchar, + p_filter varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.polygonlocation lv + WHERE lv.objectid = p_objectid + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.acres IS NOT DISTINCT FROM p_acres + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding + AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae + AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae + AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages + AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken + AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.hectares IS NOT DISTINCT FROM p_hectares + AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin + AND lv.filter IS NOT DISTINCT FROM p_filter + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.polygonlocation + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.polygonlocation + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.polygonlocation ( + objectid, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + acres, + nextactiondatescheduled, + larvinspectinterval, + zone2, + locationnumber, + globalid, + lastinspectdate, + lastinspectbreeding, + lastinspectavglarvae, + lastinspectavgpupae, + lastinspectlstages, + lastinspectactiontaken, + lastinspectfieldspecies, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + hectares, + lastinspectactivity, + lasttreatactivity, + lastinspectconditions, + waterorigin, + filter, + creationdate, + creator, + editdate, + editor, + jurisdiction, + shape__area, + shape__length, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_acres, + p_nextactiondatescheduled, + p_larvinspectinterval, + p_zone2, + p_locationnumber, + p_globalid, + p_lastinspectdate, + p_lastinspectbreeding, + p_lastinspectavglarvae, + p_lastinspectavgpupae, + p_lastinspectlstages, + p_lastinspectactiontaken, + p_lastinspectfieldspecies, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_hectares, + p_lastinspectactivity, + p_lasttreatactivity, + p_lastinspectconditions, + p_waterorigin, + p_filter, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_pool_versioned.sql b/db/fieldseeker-schema/insert/insert_pool_versioned.sql index 8eb5924b..2e207610 100644 --- a/db/fieldseeker-schema/insert/insert_pool_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_pool_versioned.sql @@ -1,92 +1,165 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.pool --- Only inserts a new version if data has changed -PREPARE insert_pool_versioned(bigint, uuid, timestamp, varchar, timestamp, varchar, varchar, varchar, fieldseeker.pool_notinuit_f_enum, uuid, fieldseeker.pool_pool_testmethod_670efbfba86d41ba8e2d3cab5d749e7f_enum, fieldseeker.pool_pool_diseasetested_0f02232949c04c7e8de820b9b515ed97_enum, fieldseeker.pool_pool_diseasepos_6889f8dd00074874aa726907e78497fa_enum, uuid, varchar, timestamp, varchar, timestamp, fieldseeker.pool_mosquitolabname_enum, smallint, smallint, varchar, varchar, varchar, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.pool - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.pool - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.pool ( - objectid, trapdata_id, datesent, survtech, datetested, testtech, comments, sampleid, processed, lab_id, testmethod, diseasetested, diseasepos, globalid, created_user, created_date, last_edited_user, last_edited_date, lab, poolyear, gatewaysync, vectorsurvcollectionid, vectorsurvpoolid, vectorsurvtrapdataid, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.trapdata_id IS NOT DISTINCT FROM $2 AND - lv.datesent IS NOT DISTINCT FROM $3 AND - lv.survtech IS NOT DISTINCT FROM $4 AND - lv.datetested IS NOT DISTINCT FROM $5 AND - lv.testtech IS NOT DISTINCT FROM $6 AND - lv.comments IS NOT DISTINCT FROM $7 AND - lv.sampleid IS NOT DISTINCT FROM $8 AND - lv.processed IS NOT DISTINCT FROM $9 AND - lv.lab_id IS NOT DISTINCT FROM $10 AND - lv.testmethod IS NOT DISTINCT FROM $11 AND - lv.diseasetested IS NOT DISTINCT FROM $12 AND - lv.diseasepos IS NOT DISTINCT FROM $13 AND - lv.globalid IS NOT DISTINCT FROM $14 AND - lv.created_user IS NOT DISTINCT FROM $15 AND - lv.created_date IS NOT DISTINCT FROM $16 AND - lv.last_edited_user IS NOT DISTINCT FROM $17 AND - lv.last_edited_date IS NOT DISTINCT FROM $18 AND - lv.lab IS NOT DISTINCT FROM $19 AND - lv.poolyear IS NOT DISTINCT FROM $20 AND - lv.gatewaysync IS NOT DISTINCT FROM $21 AND - lv.vectorsurvcollectionid IS NOT DISTINCT FROM $22 AND - lv.vectorsurvpoolid IS NOT DISTINCT FROM $23 AND - lv.vectorsurvtrapdataid IS NOT DISTINCT FROM $24 AND - lv.creationdate IS NOT DISTINCT FROM $25 AND - lv.creator IS NOT DISTINCT FROM $26 AND - lv.editdate IS NOT DISTINCT FROM $27 AND - lv.editor IS NOT DISTINCT FROM $28 - ) -RETURNING *; - --- Example usage: EXECUTE insert_pool_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: TRAPDATA_ID (uuid) --- $3: DATESENT (timestamp) --- $4: SURVTECH (varchar) --- $5: DATETESTED (timestamp) --- $6: TESTTECH (varchar) --- $7: COMMENTS (varchar) --- $8: SAMPLEID (varchar) --- $9: PROCESSED (fieldseeker.pool_notinuit_f_enum) --- $10: LAB_ID (uuid) --- $11: TESTMETHOD (fieldseeker.pool_pool_testmethod_670efbfba86d41ba8e2d3cab5d749e7f_enum) --- $12: DISEASETESTED (fieldseeker.pool_pool_diseasetested_0f02232949c04c7e8de820b9b515ed97_enum) --- $13: DISEASEPOS (fieldseeker.pool_pool_diseasepos_6889f8dd00074874aa726907e78497fa_enum) --- $14: GlobalID (uuid) --- $15: created_user (varchar) --- $16: created_date (timestamp) --- $17: last_edited_user (varchar) --- $18: last_edited_date (timestamp) --- $19: LAB (fieldseeker.pool_mosquitolabname_enum) --- $20: POOLYEAR (smallint) --- $21: GATEWAYSYNC (smallint) --- $22: VECTORSURVCOLLECTIONID (varchar) --- $23: VECTORSURVPOOLID (varchar) --- $24: VECTORSURVTRAPDATAID (varchar) --- $25: CreationDate (timestamp) --- $26: Creator (varchar) --- $27: EditDate (timestamp) --- $28: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_pool( + p_objectid bigint, + + p_trapdata_id uuid, + p_datesent timestamp, + p_survtech varchar, + p_datetested timestamp, + p_testtech varchar, + p_comments varchar, + p_sampleid varchar, + p_processed smallint, + p_lab_id uuid, + p_testmethod varchar, + p_diseasetested varchar, + p_diseasepos varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_lab varchar, + p_poolyear smallint, + p_gatewaysync smallint, + p_vectorsurvcollectionid varchar, + p_vectorsurvpoolid varchar, + p_vectorsurvtrapdataid varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.pool lv + WHERE lv.objectid = p_objectid + + AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id + AND lv.datesent IS NOT DISTINCT FROM p_datesent + AND lv.survtech IS NOT DISTINCT FROM p_survtech + AND lv.datetested IS NOT DISTINCT FROM p_datetested + AND lv.testtech IS NOT DISTINCT FROM p_testtech + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.sampleid IS NOT DISTINCT FROM p_sampleid + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.lab_id IS NOT DISTINCT FROM p_lab_id + AND lv.testmethod IS NOT DISTINCT FROM p_testmethod + AND lv.diseasetested IS NOT DISTINCT FROM p_diseasetested + AND lv.diseasepos IS NOT DISTINCT FROM p_diseasepos + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.lab IS NOT DISTINCT FROM p_lab + AND lv.poolyear IS NOT DISTINCT FROM p_poolyear + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.vectorsurvcollectionid IS NOT DISTINCT FROM p_vectorsurvcollectionid + AND lv.vectorsurvpoolid IS NOT DISTINCT FROM p_vectorsurvpoolid + AND lv.vectorsurvtrapdataid IS NOT DISTINCT FROM p_vectorsurvtrapdataid + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.pool + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.pool + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.pool ( + objectid, + + trapdata_id, + datesent, + survtech, + datetested, + testtech, + comments, + sampleid, + processed, + lab_id, + testmethod, + diseasetested, + diseasepos, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + lab, + poolyear, + gatewaysync, + vectorsurvcollectionid, + vectorsurvpoolid, + vectorsurvtrapdataid, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_trapdata_id, + p_datesent, + p_survtech, + p_datetested, + p_testtech, + p_comments, + p_sampleid, + p_processed, + p_lab_id, + p_testmethod, + p_diseasetested, + p_diseasepos, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_lab, + p_poolyear, + p_gatewaysync, + p_vectorsurvcollectionid, + p_vectorsurvpoolid, + p_vectorsurvtrapdataid, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_pooldetail_versioned.sql b/db/fieldseeker-schema/insert/insert_pooldetail_versioned.sql index ac2f20de..e66573a0 100644 --- a/db/fieldseeker-schema/insert/insert_pooldetail_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_pooldetail_versioned.sql @@ -1,64 +1,109 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.pooldetail --- Only inserts a new version if data has changed -PREPARE insert_pooldetail_versioned(bigint, uuid, uuid, varchar, smallint, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.pooldetail - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.pooldetail - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.pooldetail ( - objectid, trapdata_id, pool_id, species, females, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.trapdata_id IS NOT DISTINCT FROM $2 AND - lv.pool_id IS NOT DISTINCT FROM $3 AND - lv.species IS NOT DISTINCT FROM $4 AND - lv.females IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.creationdate IS NOT DISTINCT FROM $11 AND - lv.creator IS NOT DISTINCT FROM $12 AND - lv.editdate IS NOT DISTINCT FROM $13 AND - lv.editor IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_pooldetail_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: TRAPDATA_ID (uuid) --- $3: POOL_ID (uuid) --- $4: SPECIES (varchar) --- $5: FEMALES (smallint) --- $6: GlobalID (uuid) --- $7: created_user (varchar) --- $8: created_date (timestamp) --- $9: last_edited_user (varchar) --- $10: last_edited_date (timestamp) --- $11: CreationDate (timestamp) --- $12: Creator (varchar) --- $13: EditDate (timestamp) --- $14: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_pooldetail( + p_objectid bigint, + + p_trapdata_id uuid, + p_pool_id uuid, + p_species varchar, + p_females smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.pooldetail lv + WHERE lv.objectid = p_objectid + + AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id + AND lv.pool_id IS NOT DISTINCT FROM p_pool_id + AND lv.species IS NOT DISTINCT FROM p_species + AND lv.females IS NOT DISTINCT FROM p_females + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.pooldetail + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.pooldetail + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.pooldetail ( + objectid, + + trapdata_id, + pool_id, + species, + females, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_trapdata_id, + p_pool_id, + p_species, + p_females, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_proposedtreatmentarea_versioned.sql b/db/fieldseeker-schema/insert/insert_proposedtreatmentarea_versioned.sql index 46ec69e7..40bd8747 100644 --- a/db/fieldseeker-schema/insert/insert_proposedtreatmentarea_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_proposedtreatmentarea_versioned.sql @@ -1,102 +1,185 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.proposedtreatmentarea --- Only inserts a new version if data has changed -PREPARE insert_proposedtreatmentarea_versioned(bigint, fieldseeker.proposedtreatmentarea_mosquitotreatmentmethod_enum, varchar, varchar, fieldseeker.proposedtreatmentarea_notinuit_f_enum, varchar, timestamp, varchar, timestamp, varchar, fieldseeker.proposedtreatmentarea_notinuit_f_enum, fieldseeker.proposedtreatmentarea_notinuit_f_enum, varchar, double precision, uuid, fieldseeker.proposedtreatmentarea_notinuit_f_enum, varchar, double precision, double precision, varchar, timestamp, varchar, double precision, varchar, fieldseeker.proposedtreatmentarea_locationpriority_enum, timestamp, timestamp, varchar, timestamp, varchar, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.proposedtreatmentarea - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.proposedtreatmentarea - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.proposedtreatmentarea ( - objectid, method, comments, zone, reviewed, reviewedby, revieweddate, zone2, completeddate, completedby, completed, issprayroute, name, acres, globalid, exported, targetproduct, targetapprate, hectares, lasttreatactivity, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, priority, duedate, creationdate, creator, editdate, editor, targetspecies, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.method IS NOT DISTINCT FROM $2 AND - lv.comments IS NOT DISTINCT FROM $3 AND - lv.zone IS NOT DISTINCT FROM $4 AND - lv.reviewed IS NOT DISTINCT FROM $5 AND - lv.reviewedby IS NOT DISTINCT FROM $6 AND - lv.revieweddate IS NOT DISTINCT FROM $7 AND - lv.zone2 IS NOT DISTINCT FROM $8 AND - lv.completeddate IS NOT DISTINCT FROM $9 AND - lv.completedby IS NOT DISTINCT FROM $10 AND - lv.completed IS NOT DISTINCT FROM $11 AND - lv.issprayroute IS NOT DISTINCT FROM $12 AND - lv.name IS NOT DISTINCT FROM $13 AND - lv.acres IS NOT DISTINCT FROM $14 AND - lv.globalid IS NOT DISTINCT FROM $15 AND - lv.exported IS NOT DISTINCT FROM $16 AND - lv.targetproduct IS NOT DISTINCT FROM $17 AND - lv.targetapprate IS NOT DISTINCT FROM $18 AND - lv.hectares IS NOT DISTINCT FROM $19 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $20 AND - lv.lasttreatdate IS NOT DISTINCT FROM $21 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $22 AND - lv.lasttreatqty IS NOT DISTINCT FROM $23 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $24 AND - lv.priority IS NOT DISTINCT FROM $25 AND - lv.duedate IS NOT DISTINCT FROM $26 AND - lv.creationdate IS NOT DISTINCT FROM $27 AND - lv.creator IS NOT DISTINCT FROM $28 AND - lv.editdate IS NOT DISTINCT FROM $29 AND - lv.editor IS NOT DISTINCT FROM $30 AND - lv.targetspecies IS NOT DISTINCT FROM $31 AND - lv.shape__area IS NOT DISTINCT FROM $32 AND - lv.shape__length IS NOT DISTINCT FROM $33 - ) -RETURNING *; - --- Example usage: EXECUTE insert_proposedtreatmentarea_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: METHOD (fieldseeker.proposedtreatmentarea_mosquitotreatmentmethod_enum) --- $3: COMMENTS (varchar) --- $4: ZONE (varchar) --- $5: REVIEWED (fieldseeker.proposedtreatmentarea_notinuit_f_enum) --- $6: REVIEWEDBY (varchar) --- $7: REVIEWEDDATE (timestamp) --- $8: ZONE2 (varchar) --- $9: COMPLETEDDATE (timestamp) --- $10: COMPLETEDBY (varchar) --- $11: COMPLETED (fieldseeker.proposedtreatmentarea_notinuit_f_enum) --- $12: ISSPRAYROUTE (fieldseeker.proposedtreatmentarea_notinuit_f_enum) --- $13: NAME (varchar) --- $14: ACRES (double precision) --- $15: GlobalID (uuid) --- $16: EXPORTED (fieldseeker.proposedtreatmentarea_notinuit_f_enum) --- $17: TARGETPRODUCT (varchar) --- $18: TARGETAPPRATE (double precision) --- $19: HECTARES (double precision) --- $20: LASTTREATACTIVITY (varchar) --- $21: LASTTREATDATE (timestamp) --- $22: LASTTREATPRODUCT (varchar) --- $23: LASTTREATQTY (double precision) --- $24: LASTTREATQTYUNIT (varchar) --- $25: PRIORITY (fieldseeker.proposedtreatmentarea_locationpriority_enum) --- $26: DUEDATE (timestamp) --- $27: CreationDate (timestamp) --- $28: Creator (varchar) --- $29: EditDate (timestamp) --- $30: Editor (varchar) --- $31: TARGETSPECIES (varchar) --- $32: Shape__Area (double precision) --- $33: Shape__Length (double precision) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_proposedtreatmentarea( + p_objectid bigint, + + p_method varchar, + p_comments varchar, + p_zone varchar, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_zone2 varchar, + p_completeddate timestamp, + p_completedby varchar, + p_completed smallint, + p_issprayroute smallint, + p_name varchar, + p_acres double precision, + p_globalid uuid, + p_exported smallint, + p_targetproduct varchar, + p_targetapprate double precision, + p_hectares double precision, + p_lasttreatactivity varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_priority varchar, + p_duedate timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_targetspecies varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.proposedtreatmentarea lv + WHERE lv.objectid = p_objectid + + AND lv.method IS NOT DISTINCT FROM p_method + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.completeddate IS NOT DISTINCT FROM p_completeddate + AND lv.completedby IS NOT DISTINCT FROM p_completedby + AND lv.completed IS NOT DISTINCT FROM p_completed + AND lv.issprayroute IS NOT DISTINCT FROM p_issprayroute + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.acres IS NOT DISTINCT FROM p_acres + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.exported IS NOT DISTINCT FROM p_exported + AND lv.targetproduct IS NOT DISTINCT FROM p_targetproduct + AND lv.targetapprate IS NOT DISTINCT FROM p_targetapprate + AND lv.hectares IS NOT DISTINCT FROM p_hectares + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.duedate IS NOT DISTINCT FROM p_duedate + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.targetspecies IS NOT DISTINCT FROM p_targetspecies + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.proposedtreatmentarea + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.proposedtreatmentarea + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.proposedtreatmentarea ( + objectid, + + method, + comments, + zone, + reviewed, + reviewedby, + revieweddate, + zone2, + completeddate, + completedby, + completed, + issprayroute, + name, + acres, + globalid, + exported, + targetproduct, + targetapprate, + hectares, + lasttreatactivity, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + priority, + duedate, + creationdate, + creator, + editdate, + editor, + targetspecies, + shape__area, + shape__length, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_method, + p_comments, + p_zone, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_zone2, + p_completeddate, + p_completedby, + p_completed, + p_issprayroute, + p_name, + p_acres, + p_globalid, + p_exported, + p_targetproduct, + p_targetapprate, + p_hectares, + p_lasttreatactivity, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_priority, + p_duedate, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_targetspecies, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_qamosquitoinspection_versioned.sql b/db/fieldseeker-schema/insert/insert_qamosquitoinspection_versioned.sql index 9f2bca69..9fbe2563 100644 --- a/db/fieldseeker-schema/insert/insert_qamosquitoinspection_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_qamosquitoinspection_versioned.sql @@ -1,160 +1,301 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.qamosquitoinspection --- Only inserts a new version if data has changed -PREPARE insert_qamosquitoinspection_versioned(bigint, smallint, fieldseeker.qamosquitoinspection_mosquitoaction_enum, varchar, double precision, double precision, double precision, uuid, timestamp, timestamp, varchar, fieldseeker.qamosquitoinspection_notinuit_f_enum, varchar, timestamp, varchar, varchar, smallint, varchar, smallint, smallint, double precision, double precision, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qasitetype_enum, fieldseeker.qamosquitoinspection_qabreedingpotential_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qamosquitohabitat_enum, smallint, smallint, smallint, smallint, smallint, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qalarvaereason_enum, fieldseeker.qamosquitoinspection_qaaquaticorganisms_enum, fieldseeker.qamosquitoinspection_qavegetation_enum, fieldseeker.qamosquitoinspection_qasourcereduction_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qawatermovement_enum, smallint, fieldseeker.qamosquitoinspection_qawatermovement_enum, smallint, fieldseeker.qamosquitoinspection_qasoilcondition_enum, fieldseeker.qamosquitoinspection_qawaterduration_enum, fieldseeker.qamosquitoinspection_qawatersource_enum, fieldseeker.qamosquitoinspection_qawaterconditions_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, uuid, uuid, uuid, varchar, timestamp, varchar, timestamp, varchar, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.qamosquitoinspection - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.qamosquitoinspection - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.qamosquitoinspection ( - objectid, posdips, actiontaken, comments, avetemp, windspeed, raingauge, globalid, startdatetime, enddatetime, winddir, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, lr, negdips, totalacres, acresbreeding, fish, sitetype, breedingpotential, movingwater, nowaterever, mosquitohabitat, habvalue1, habvalue1percent, habvalue2, habvalue2percent, potential, larvaepresent, larvaeinsidetreatedarea, larvaeoutsidetreatedarea, larvaereason, aquaticorganisms, vegetation, sourcereduction, waterpresent, watermovement1, watermovement1percent, watermovement2, watermovement2percent, soilconditions, waterduration, watersource, waterconditions, adultactivity, linelocid, pointlocid, polygonlocid, created_user, created_date, last_edited_user, last_edited_date, fieldtech, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.posdips IS NOT DISTINCT FROM $2 AND - lv.actiontaken IS NOT DISTINCT FROM $3 AND - lv.comments IS NOT DISTINCT FROM $4 AND - lv.avetemp IS NOT DISTINCT FROM $5 AND - lv.windspeed IS NOT DISTINCT FROM $6 AND - lv.raingauge IS NOT DISTINCT FROM $7 AND - lv.globalid IS NOT DISTINCT FROM $8 AND - lv.startdatetime IS NOT DISTINCT FROM $9 AND - lv.enddatetime IS NOT DISTINCT FROM $10 AND - lv.winddir IS NOT DISTINCT FROM $11 AND - lv.reviewed IS NOT DISTINCT FROM $12 AND - lv.reviewedby IS NOT DISTINCT FROM $13 AND - lv.revieweddate IS NOT DISTINCT FROM $14 AND - lv.locationname IS NOT DISTINCT FROM $15 AND - lv.zone IS NOT DISTINCT FROM $16 AND - lv.recordstatus IS NOT DISTINCT FROM $17 AND - lv.zone2 IS NOT DISTINCT FROM $18 AND - lv.lr IS NOT DISTINCT FROM $19 AND - lv.negdips IS NOT DISTINCT FROM $20 AND - lv.totalacres IS NOT DISTINCT FROM $21 AND - lv.acresbreeding IS NOT DISTINCT FROM $22 AND - lv.fish IS NOT DISTINCT FROM $23 AND - lv.sitetype IS NOT DISTINCT FROM $24 AND - lv.breedingpotential IS NOT DISTINCT FROM $25 AND - lv.movingwater IS NOT DISTINCT FROM $26 AND - lv.nowaterever IS NOT DISTINCT FROM $27 AND - lv.mosquitohabitat IS NOT DISTINCT FROM $28 AND - lv.habvalue1 IS NOT DISTINCT FROM $29 AND - lv.habvalue1percent IS NOT DISTINCT FROM $30 AND - lv.habvalue2 IS NOT DISTINCT FROM $31 AND - lv.habvalue2percent IS NOT DISTINCT FROM $32 AND - lv.potential IS NOT DISTINCT FROM $33 AND - lv.larvaepresent IS NOT DISTINCT FROM $34 AND - lv.larvaeinsidetreatedarea IS NOT DISTINCT FROM $35 AND - lv.larvaeoutsidetreatedarea IS NOT DISTINCT FROM $36 AND - lv.larvaereason IS NOT DISTINCT FROM $37 AND - lv.aquaticorganisms IS NOT DISTINCT FROM $38 AND - lv.vegetation IS NOT DISTINCT FROM $39 AND - lv.sourcereduction IS NOT DISTINCT FROM $40 AND - lv.waterpresent IS NOT DISTINCT FROM $41 AND - lv.watermovement1 IS NOT DISTINCT FROM $42 AND - lv.watermovement1percent IS NOT DISTINCT FROM $43 AND - lv.watermovement2 IS NOT DISTINCT FROM $44 AND - lv.watermovement2percent IS NOT DISTINCT FROM $45 AND - lv.soilconditions IS NOT DISTINCT FROM $46 AND - lv.waterduration IS NOT DISTINCT FROM $47 AND - lv.watersource IS NOT DISTINCT FROM $48 AND - lv.waterconditions IS NOT DISTINCT FROM $49 AND - lv.adultactivity IS NOT DISTINCT FROM $50 AND - lv.linelocid IS NOT DISTINCT FROM $51 AND - lv.pointlocid IS NOT DISTINCT FROM $52 AND - lv.polygonlocid IS NOT DISTINCT FROM $53 AND - lv.created_user IS NOT DISTINCT FROM $54 AND - lv.created_date IS NOT DISTINCT FROM $55 AND - lv.last_edited_user IS NOT DISTINCT FROM $56 AND - lv.last_edited_date IS NOT DISTINCT FROM $57 AND - lv.fieldtech IS NOT DISTINCT FROM $58 AND - lv.creationdate IS NOT DISTINCT FROM $59 AND - lv.creator IS NOT DISTINCT FROM $60 AND - lv.editdate IS NOT DISTINCT FROM $61 AND - lv.editor IS NOT DISTINCT FROM $62 - ) -RETURNING *; - --- Example usage: EXECUTE insert_qamosquitoinspection_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: POSDIPS (smallint) --- $3: ACTIONTAKEN (fieldseeker.qamosquitoinspection_mosquitoaction_enum) --- $4: COMMENTS (varchar) --- $5: AVETEMP (double precision) --- $6: WINDSPEED (double precision) --- $7: RAINGAUGE (double precision) --- $8: GlobalID (uuid) --- $9: STARTDATETIME (timestamp) --- $10: ENDDATETIME (timestamp) --- $11: WINDDIR (varchar) --- $12: REVIEWED (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $13: REVIEWEDBY (varchar) --- $14: REVIEWEDDATE (timestamp) --- $15: LOCATIONNAME (varchar) --- $16: ZONE (varchar) --- $17: RECORDSTATUS (smallint) --- $18: ZONE2 (varchar) --- $19: LR (smallint) --- $20: NEGDIPS (smallint) --- $21: TOTALACRES (double precision) --- $22: ACRESBREEDING (double precision) --- $23: FISH (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $24: SITETYPE (fieldseeker.qamosquitoinspection_qasitetype_enum) --- $25: BREEDINGPOTENTIAL (fieldseeker.qamosquitoinspection_qabreedingpotential_enum) --- $26: MOVINGWATER (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $27: NOWATEREVER (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $28: MOSQUITOHABITAT (fieldseeker.qamosquitoinspection_qamosquitohabitat_enum) --- $29: HABVALUE1 (smallint) --- $30: HABVALUE1PERCENT (smallint) --- $31: HABVALUE2 (smallint) --- $32: HABVALUE2PERCENT (smallint) --- $33: POTENTIAL (smallint) --- $34: LARVAEPRESENT (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $35: LARVAEINSIDETREATEDAREA (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $36: LARVAEOUTSIDETREATEDAREA (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $37: LARVAEREASON (fieldseeker.qamosquitoinspection_qalarvaereason_enum) --- $38: AQUATICORGANISMS (fieldseeker.qamosquitoinspection_qaaquaticorganisms_enum) --- $39: VEGETATION (fieldseeker.qamosquitoinspection_qavegetation_enum) --- $40: SOURCEREDUCTION (fieldseeker.qamosquitoinspection_qasourcereduction_enum) --- $41: WATERPRESENT (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $42: WATERMOVEMENT1 (fieldseeker.qamosquitoinspection_qawatermovement_enum) --- $43: WATERMOVEMENT1PERCENT (smallint) --- $44: WATERMOVEMENT2 (fieldseeker.qamosquitoinspection_qawatermovement_enum) --- $45: WATERMOVEMENT2PERCENT (smallint) --- $46: SOILCONDITIONS (fieldseeker.qamosquitoinspection_qasoilcondition_enum) --- $47: WATERDURATION (fieldseeker.qamosquitoinspection_qawaterduration_enum) --- $48: WATERSOURCE (fieldseeker.qamosquitoinspection_qawatersource_enum) --- $49: WATERCONDITIONS (fieldseeker.qamosquitoinspection_qawaterconditions_enum) --- $50: ADULTACTIVITY (fieldseeker.qamosquitoinspection_notinuit_f_enum) --- $51: LINELOCID (uuid) --- $52: POINTLOCID (uuid) --- $53: POLYGONLOCID (uuid) --- $54: created_user (varchar) --- $55: created_date (timestamp) --- $56: last_edited_user (varchar) --- $57: last_edited_date (timestamp) --- $58: FIELDTECH (varchar) --- $59: CreationDate (timestamp) --- $60: Creator (varchar) --- $61: EditDate (timestamp) --- $62: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_qamosquitoinspection( + p_objectid bigint, + + p_posdips smallint, + p_actiontaken varchar, + p_comments varchar, + p_avetemp double precision, + p_windspeed double precision, + p_raingauge double precision, + p_globalid uuid, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_winddir varchar, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_recordstatus smallint, + p_zone2 varchar, + p_lr smallint, + p_negdips smallint, + p_totalacres double precision, + p_acresbreeding double precision, + p_fish smallint, + p_sitetype varchar, + p_breedingpotential varchar, + p_movingwater smallint, + p_nowaterever smallint, + p_mosquitohabitat varchar, + p_habvalue1 smallint, + p_habvalue1percent smallint, + p_habvalue2 smallint, + p_habvalue2percent smallint, + p_potential smallint, + p_larvaepresent smallint, + p_larvaeinsidetreatedarea smallint, + p_larvaeoutsidetreatedarea smallint, + p_larvaereason varchar, + p_aquaticorganisms varchar, + p_vegetation varchar, + p_sourcereduction varchar, + p_waterpresent smallint, + p_watermovement1 varchar, + p_watermovement1percent smallint, + p_watermovement2 varchar, + p_watermovement2percent smallint, + p_soilconditions varchar, + p_waterduration varchar, + p_watersource varchar, + p_waterconditions varchar, + p_adultactivity smallint, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_fieldtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.qamosquitoinspection lv + WHERE lv.objectid = p_objectid + + AND lv.posdips IS NOT DISTINCT FROM p_posdips + AND lv.actiontaken IS NOT DISTINCT FROM p_actiontaken + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.lr IS NOT DISTINCT FROM p_lr + AND lv.negdips IS NOT DISTINCT FROM p_negdips + AND lv.totalacres IS NOT DISTINCT FROM p_totalacres + AND lv.acresbreeding IS NOT DISTINCT FROM p_acresbreeding + AND lv.fish IS NOT DISTINCT FROM p_fish + AND lv.sitetype IS NOT DISTINCT FROM p_sitetype + AND lv.breedingpotential IS NOT DISTINCT FROM p_breedingpotential + AND lv.movingwater IS NOT DISTINCT FROM p_movingwater + AND lv.nowaterever IS NOT DISTINCT FROM p_nowaterever + AND lv.mosquitohabitat IS NOT DISTINCT FROM p_mosquitohabitat + AND lv.habvalue1 IS NOT DISTINCT FROM p_habvalue1 + AND lv.habvalue1percent IS NOT DISTINCT FROM p_habvalue1percent + AND lv.habvalue2 IS NOT DISTINCT FROM p_habvalue2 + AND lv.habvalue2percent IS NOT DISTINCT FROM p_habvalue2percent + AND lv.potential IS NOT DISTINCT FROM p_potential + AND lv.larvaepresent IS NOT DISTINCT FROM p_larvaepresent + AND lv.larvaeinsidetreatedarea IS NOT DISTINCT FROM p_larvaeinsidetreatedarea + AND lv.larvaeoutsidetreatedarea IS NOT DISTINCT FROM p_larvaeoutsidetreatedarea + AND lv.larvaereason IS NOT DISTINCT FROM p_larvaereason + AND lv.aquaticorganisms IS NOT DISTINCT FROM p_aquaticorganisms + AND lv.vegetation IS NOT DISTINCT FROM p_vegetation + AND lv.sourcereduction IS NOT DISTINCT FROM p_sourcereduction + AND lv.waterpresent IS NOT DISTINCT FROM p_waterpresent + AND lv.watermovement1 IS NOT DISTINCT FROM p_watermovement1 + AND lv.watermovement1percent IS NOT DISTINCT FROM p_watermovement1percent + AND lv.watermovement2 IS NOT DISTINCT FROM p_watermovement2 + AND lv.watermovement2percent IS NOT DISTINCT FROM p_watermovement2percent + AND lv.soilconditions IS NOT DISTINCT FROM p_soilconditions + AND lv.waterduration IS NOT DISTINCT FROM p_waterduration + AND lv.watersource IS NOT DISTINCT FROM p_watersource + AND lv.waterconditions IS NOT DISTINCT FROM p_waterconditions + AND lv.adultactivity IS NOT DISTINCT FROM p_adultactivity + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.qamosquitoinspection + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.qamosquitoinspection + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.qamosquitoinspection ( + objectid, + + posdips, + actiontaken, + comments, + avetemp, + windspeed, + raingauge, + globalid, + startdatetime, + enddatetime, + winddir, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + recordstatus, + zone2, + lr, + negdips, + totalacres, + acresbreeding, + fish, + sitetype, + breedingpotential, + movingwater, + nowaterever, + mosquitohabitat, + habvalue1, + habvalue1percent, + habvalue2, + habvalue2percent, + potential, + larvaepresent, + larvaeinsidetreatedarea, + larvaeoutsidetreatedarea, + larvaereason, + aquaticorganisms, + vegetation, + sourcereduction, + waterpresent, + watermovement1, + watermovement1percent, + watermovement2, + watermovement2percent, + soilconditions, + waterduration, + watersource, + waterconditions, + adultactivity, + linelocid, + pointlocid, + polygonlocid, + created_user, + created_date, + last_edited_user, + last_edited_date, + fieldtech, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_posdips, + p_actiontaken, + p_comments, + p_avetemp, + p_windspeed, + p_raingauge, + p_globalid, + p_startdatetime, + p_enddatetime, + p_winddir, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_recordstatus, + p_zone2, + p_lr, + p_negdips, + p_totalacres, + p_acresbreeding, + p_fish, + p_sitetype, + p_breedingpotential, + p_movingwater, + p_nowaterever, + p_mosquitohabitat, + p_habvalue1, + p_habvalue1percent, + p_habvalue2, + p_habvalue2percent, + p_potential, + p_larvaepresent, + p_larvaeinsidetreatedarea, + p_larvaeoutsidetreatedarea, + p_larvaereason, + p_aquaticorganisms, + p_vegetation, + p_sourcereduction, + p_waterpresent, + p_watermovement1, + p_watermovement1percent, + p_watermovement2, + p_watermovement2percent, + p_soilconditions, + p_waterduration, + p_watersource, + p_waterconditions, + p_adultactivity, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_fieldtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_rodentlocation_versioned.sql b/db/fieldseeker-schema/insert/insert_rodentlocation_versioned.sql index 2393d1cd..22ef5755 100644 --- a/db/fieldseeker-schema/insert/insert_rodentlocation_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_rodentlocation_versioned.sql @@ -1,96 +1,173 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.rodentlocation --- Only inserts a new version if data has changed -PREPARE insert_rodentlocation_versioned(bigint, varchar, varchar, varchar, fieldseeker.rodentlocation_rodentlocationhabitat_enum, fieldseeker.rodentlocation_locationpriority_1_enum, fieldseeker.rodentlocation_locationusetype_1_enum, fieldseeker.rodentlocation_notinuit_f_1_enum, varchar, varchar, varchar, fieldseeker.rodentlocation_rodentlocation_symbology_enum, varchar, timestamp, integer, timestamp, varchar, varchar, varchar, varchar, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.rodentlocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.rodentlocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.rodentlocation ( - objectid, locationname, zone, zone2, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, nextactiondatescheduled, locationnumber, lastinspectdate, lastinspectspecies, lastinspectaction, lastinspectconditions, lastinspectrodentevidence, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, jurisdiction, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.locationname IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.zone2 IS NOT DISTINCT FROM $4 AND - lv.habitat IS NOT DISTINCT FROM $5 AND - lv.priority IS NOT DISTINCT FROM $6 AND - lv.usetype IS NOT DISTINCT FROM $7 AND - lv.active IS NOT DISTINCT FROM $8 AND - lv.description IS NOT DISTINCT FROM $9 AND - lv.accessdesc IS NOT DISTINCT FROM $10 AND - lv.comments IS NOT DISTINCT FROM $11 AND - lv.symbology IS NOT DISTINCT FROM $12 AND - lv.externalid IS NOT DISTINCT FROM $13 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $14 AND - lv.locationnumber IS NOT DISTINCT FROM $15 AND - lv.lastinspectdate IS NOT DISTINCT FROM $16 AND - lv.lastinspectspecies IS NOT DISTINCT FROM $17 AND - lv.lastinspectaction IS NOT DISTINCT FROM $18 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $19 AND - lv.lastinspectrodentevidence IS NOT DISTINCT FROM $20 AND - lv.globalid IS NOT DISTINCT FROM $21 AND - lv.created_user IS NOT DISTINCT FROM $22 AND - lv.created_date IS NOT DISTINCT FROM $23 AND - lv.last_edited_user IS NOT DISTINCT FROM $24 AND - lv.last_edited_date IS NOT DISTINCT FROM $25 AND - lv.creationdate IS NOT DISTINCT FROM $26 AND - lv.creator IS NOT DISTINCT FROM $27 AND - lv.editdate IS NOT DISTINCT FROM $28 AND - lv.editor IS NOT DISTINCT FROM $29 AND - lv.jurisdiction IS NOT DISTINCT FROM $30 - ) -RETURNING *; - --- Example usage: EXECUTE insert_rodentlocation_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: LOCATIONNAME (varchar) --- $3: ZONE (varchar) --- $4: ZONE2 (varchar) --- $5: HABITAT (fieldseeker.rodentlocation_rodentlocationhabitat_enum) --- $6: PRIORITY (fieldseeker.rodentlocation_locationpriority_1_enum) --- $7: USETYPE (fieldseeker.rodentlocation_locationusetype_1_enum) --- $8: ACTIVE (fieldseeker.rodentlocation_notinuit_f_1_enum) --- $9: DESCRIPTION (varchar) --- $10: ACCESSDESC (varchar) --- $11: COMMENTS (varchar) --- $12: SYMBOLOGY (fieldseeker.rodentlocation_rodentlocation_symbology_enum) --- $13: EXTERNALID (varchar) --- $14: NEXTACTIONDATESCHEDULED (timestamp) --- $15: LOCATIONNUMBER (integer) --- $16: LASTINSPECTDATE (timestamp) --- $17: LASTINSPECTSPECIES (varchar) --- $18: LASTINSPECTACTION (varchar) --- $19: LASTINSPECTCONDITIONS (varchar) --- $20: LASTINSPECTRODENTEVIDENCE (varchar) --- $21: GlobalID (uuid) --- $22: created_user (varchar) --- $23: created_date (timestamp) --- $24: last_edited_user (varchar) --- $25: last_edited_date (timestamp) --- $26: CreationDate (timestamp) --- $27: Creator (varchar) --- $28: EditDate (timestamp) --- $29: Editor (varchar) --- $30: JURISDICTION (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_rodentlocation( + p_objectid bigint, + + p_locationname varchar, + p_zone varchar, + p_zone2 varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_symbology varchar, + p_externalid varchar, + p_nextactiondatescheduled timestamp, + p_locationnumber integer, + p_lastinspectdate timestamp, + p_lastinspectspecies varchar, + p_lastinspectaction varchar, + p_lastinspectconditions varchar, + p_lastinspectrodentevidence varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.rodentlocation lv + WHERE lv.objectid = p_objectid + + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectspecies IS NOT DISTINCT FROM p_lastinspectspecies + AND lv.lastinspectaction IS NOT DISTINCT FROM p_lastinspectaction + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.lastinspectrodentevidence IS NOT DISTINCT FROM p_lastinspectrodentevidence + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.rodentlocation + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.rodentlocation + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.rodentlocation ( + objectid, + + locationname, + zone, + zone2, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + nextactiondatescheduled, + locationnumber, + lastinspectdate, + lastinspectspecies, + lastinspectaction, + lastinspectconditions, + lastinspectrodentevidence, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + jurisdiction, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_locationname, + p_zone, + p_zone2, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_nextactiondatescheduled, + p_locationnumber, + p_lastinspectdate, + p_lastinspectspecies, + p_lastinspectaction, + p_lastinspectconditions, + p_lastinspectrodentevidence, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_samplecollection_versioned.sql b/db/fieldseeker-schema/insert/insert_samplecollection_versioned.sql index 16c3a93d..7d739070 100644 --- a/db/fieldseeker-schema/insert/insert_samplecollection_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_samplecollection_versioned.sql @@ -1,128 +1,237 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.samplecollection --- Only inserts a new version if data has changed -PREPARE insert_samplecollection_versioned(bigint, uuid, timestamp, timestamp, fieldseeker.samplecollection_mosquitositecondition_enum, varchar, varchar, timestamp, timestamp, varchar, varchar, fieldseeker.samplecollection_notinuit_f_enum, fieldseeker.samplecollection_mosquitosampletype_enum, fieldseeker.samplecollection_mosquitosamplecondition_enum, fieldseeker.samplecollection_mosquitosamplespecies_enum, fieldseeker.samplecollection_notinuisex_enum, double precision, double precision, fieldseeker.samplecollection_notinuiwinddirection_enum, double precision, fieldseeker.samplecollection_mosquitoactivity_enum, fieldseeker.samplecollection_mosquitotestmethod_enum, fieldseeker.samplecollection_mosquitodisease_enum, fieldseeker.samplecollection_mosquitodisease_enum, fieldseeker.samplecollection_notinuit_f_enum, varchar, timestamp, varchar, varchar, smallint, varchar, uuid, varchar, timestamp, varchar, timestamp, fieldseeker.samplecollection_mosquitolabname_enum, varchar, uuid, smallint, uuid, smallint, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.samplecollection - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.samplecollection - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.samplecollection ( - objectid, loc_id, startdatetime, enddatetime, sitecond, sampleid, survtech, datesent, datetested, testtech, comments, processed, sampletype, samplecond, species, sex, avetemp, windspeed, winddir, raingauge, activity, testmethod, diseasetested, diseasepos, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, lab, fieldtech, flockid, samplecount, chickenid, gatewaysync, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.loc_id IS NOT DISTINCT FROM $2 AND - lv.startdatetime IS NOT DISTINCT FROM $3 AND - lv.enddatetime IS NOT DISTINCT FROM $4 AND - lv.sitecond IS NOT DISTINCT FROM $5 AND - lv.sampleid IS NOT DISTINCT FROM $6 AND - lv.survtech IS NOT DISTINCT FROM $7 AND - lv.datesent IS NOT DISTINCT FROM $8 AND - lv.datetested IS NOT DISTINCT FROM $9 AND - lv.testtech IS NOT DISTINCT FROM $10 AND - lv.comments IS NOT DISTINCT FROM $11 AND - lv.processed IS NOT DISTINCT FROM $12 AND - lv.sampletype IS NOT DISTINCT FROM $13 AND - lv.samplecond IS NOT DISTINCT FROM $14 AND - lv.species IS NOT DISTINCT FROM $15 AND - lv.sex IS NOT DISTINCT FROM $16 AND - lv.avetemp IS NOT DISTINCT FROM $17 AND - lv.windspeed IS NOT DISTINCT FROM $18 AND - lv.winddir IS NOT DISTINCT FROM $19 AND - lv.raingauge IS NOT DISTINCT FROM $20 AND - lv.activity IS NOT DISTINCT FROM $21 AND - lv.testmethod IS NOT DISTINCT FROM $22 AND - lv.diseasetested IS NOT DISTINCT FROM $23 AND - lv.diseasepos IS NOT DISTINCT FROM $24 AND - lv.reviewed IS NOT DISTINCT FROM $25 AND - lv.reviewedby IS NOT DISTINCT FROM $26 AND - lv.revieweddate IS NOT DISTINCT FROM $27 AND - lv.locationname IS NOT DISTINCT FROM $28 AND - lv.zone IS NOT DISTINCT FROM $29 AND - lv.recordstatus IS NOT DISTINCT FROM $30 AND - lv.zone2 IS NOT DISTINCT FROM $31 AND - lv.globalid IS NOT DISTINCT FROM $32 AND - lv.created_user IS NOT DISTINCT FROM $33 AND - lv.created_date IS NOT DISTINCT FROM $34 AND - lv.last_edited_user IS NOT DISTINCT FROM $35 AND - lv.last_edited_date IS NOT DISTINCT FROM $36 AND - lv.lab IS NOT DISTINCT FROM $37 AND - lv.fieldtech IS NOT DISTINCT FROM $38 AND - lv.flockid IS NOT DISTINCT FROM $39 AND - lv.samplecount IS NOT DISTINCT FROM $40 AND - lv.chickenid IS NOT DISTINCT FROM $41 AND - lv.gatewaysync IS NOT DISTINCT FROM $42 AND - lv.creationdate IS NOT DISTINCT FROM $43 AND - lv.creator IS NOT DISTINCT FROM $44 AND - lv.editdate IS NOT DISTINCT FROM $45 AND - lv.editor IS NOT DISTINCT FROM $46 - ) -RETURNING *; - --- Example usage: EXECUTE insert_samplecollection_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: LOC_ID (uuid) --- $3: STARTDATETIME (timestamp) --- $4: ENDDATETIME (timestamp) --- $5: SITECOND (fieldseeker.samplecollection_mosquitositecondition_enum) --- $6: SAMPLEID (varchar) --- $7: SURVTECH (varchar) --- $8: DATESENT (timestamp) --- $9: DATETESTED (timestamp) --- $10: TESTTECH (varchar) --- $11: COMMENTS (varchar) --- $12: PROCESSED (fieldseeker.samplecollection_notinuit_f_enum) --- $13: SAMPLETYPE (fieldseeker.samplecollection_mosquitosampletype_enum) --- $14: SAMPLECOND (fieldseeker.samplecollection_mosquitosamplecondition_enum) --- $15: SPECIES (fieldseeker.samplecollection_mosquitosamplespecies_enum) --- $16: SEX (fieldseeker.samplecollection_notinuisex_enum) --- $17: AVETEMP (double precision) --- $18: WINDSPEED (double precision) --- $19: WINDDIR (fieldseeker.samplecollection_notinuiwinddirection_enum) --- $20: RAINGAUGE (double precision) --- $21: ACTIVITY (fieldseeker.samplecollection_mosquitoactivity_enum) --- $22: TESTMETHOD (fieldseeker.samplecollection_mosquitotestmethod_enum) --- $23: DISEASETESTED (fieldseeker.samplecollection_mosquitodisease_enum) --- $24: DISEASEPOS (fieldseeker.samplecollection_mosquitodisease_enum) --- $25: REVIEWED (fieldseeker.samplecollection_notinuit_f_enum) --- $26: REVIEWEDBY (varchar) --- $27: REVIEWEDDATE (timestamp) --- $28: LOCATIONNAME (varchar) --- $29: ZONE (varchar) --- $30: RECORDSTATUS (smallint) --- $31: ZONE2 (varchar) --- $32: GlobalID (uuid) --- $33: created_user (varchar) --- $34: created_date (timestamp) --- $35: last_edited_user (varchar) --- $36: last_edited_date (timestamp) --- $37: LAB (fieldseeker.samplecollection_mosquitolabname_enum) --- $38: FIELDTECH (varchar) --- $39: FLOCKID (uuid) --- $40: SAMPLECOUNT (smallint) --- $41: CHICKENID (uuid) --- $42: GATEWAYSYNC (smallint) --- $43: CreationDate (timestamp) --- $44: Creator (varchar) --- $45: EditDate (timestamp) --- $46: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_samplecollection( + p_objectid bigint, + + p_loc_id uuid, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_sitecond varchar, + p_sampleid varchar, + p_survtech varchar, + p_datesent timestamp, + p_datetested timestamp, + p_testtech varchar, + p_comments varchar, + p_processed smallint, + p_sampletype varchar, + p_samplecond varchar, + p_species varchar, + p_sex varchar, + p_avetemp double precision, + p_windspeed double precision, + p_winddir varchar, + p_raingauge double precision, + p_activity varchar, + p_testmethod varchar, + p_diseasetested varchar, + p_diseasepos varchar, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_recordstatus smallint, + p_zone2 varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_lab varchar, + p_fieldtech varchar, + p_flockid uuid, + p_samplecount smallint, + p_chickenid uuid, + p_gatewaysync smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.samplecollection lv + WHERE lv.objectid = p_objectid + + AND lv.loc_id IS NOT DISTINCT FROM p_loc_id + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.sampleid IS NOT DISTINCT FROM p_sampleid + AND lv.survtech IS NOT DISTINCT FROM p_survtech + AND lv.datesent IS NOT DISTINCT FROM p_datesent + AND lv.datetested IS NOT DISTINCT FROM p_datetested + AND lv.testtech IS NOT DISTINCT FROM p_testtech + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.sampletype IS NOT DISTINCT FROM p_sampletype + AND lv.samplecond IS NOT DISTINCT FROM p_samplecond + AND lv.species IS NOT DISTINCT FROM p_species + AND lv.sex IS NOT DISTINCT FROM p_sex + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.testmethod IS NOT DISTINCT FROM p_testmethod + AND lv.diseasetested IS NOT DISTINCT FROM p_diseasetested + AND lv.diseasepos IS NOT DISTINCT FROM p_diseasepos + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.lab IS NOT DISTINCT FROM p_lab + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.flockid IS NOT DISTINCT FROM p_flockid + AND lv.samplecount IS NOT DISTINCT FROM p_samplecount + AND lv.chickenid IS NOT DISTINCT FROM p_chickenid + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.samplecollection + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.samplecollection + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.samplecollection ( + objectid, + + loc_id, + startdatetime, + enddatetime, + sitecond, + sampleid, + survtech, + datesent, + datetested, + testtech, + comments, + processed, + sampletype, + samplecond, + species, + sex, + avetemp, + windspeed, + winddir, + raingauge, + activity, + testmethod, + diseasetested, + diseasepos, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + recordstatus, + zone2, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + lab, + fieldtech, + flockid, + samplecount, + chickenid, + gatewaysync, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_loc_id, + p_startdatetime, + p_enddatetime, + p_sitecond, + p_sampleid, + p_survtech, + p_datesent, + p_datetested, + p_testtech, + p_comments, + p_processed, + p_sampletype, + p_samplecond, + p_species, + p_sex, + p_avetemp, + p_windspeed, + p_winddir, + p_raingauge, + p_activity, + p_testmethod, + p_diseasetested, + p_diseasepos, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_recordstatus, + p_zone2, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_lab, + p_fieldtech, + p_flockid, + p_samplecount, + p_chickenid, + p_gatewaysync, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_samplelocation_versioned.sql b/db/fieldseeker-schema/insert/insert_samplelocation_versioned.sql index 13a98dbb..358d3007 100644 --- a/db/fieldseeker-schema/insert/insert_samplelocation_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_samplelocation_versioned.sql @@ -1,84 +1,149 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.samplelocation --- Only inserts a new version if data has changed -PREPARE insert_samplelocation_versioned(bigint, varchar, varchar, fieldseeker.samplelocation_locationhabitattype_enum, fieldseeker.samplelocation_locationpriority_enum, fieldseeker.samplelocation_samplelocationusetype_enum, fieldseeker.samplelocation_notinuit_f_enum, varchar, varchar, varchar, varchar, timestamp, varchar, integer, uuid, varchar, timestamp, varchar, timestamp, smallint, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.samplelocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.samplelocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.samplelocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, externalid, nextactiondatescheduled, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, gatewaysync, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.externalid IS NOT DISTINCT FROM $11 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $12 AND - lv.zone2 IS NOT DISTINCT FROM $13 AND - lv.locationnumber IS NOT DISTINCT FROM $14 AND - lv.globalid IS NOT DISTINCT FROM $15 AND - lv.created_user IS NOT DISTINCT FROM $16 AND - lv.created_date IS NOT DISTINCT FROM $17 AND - lv.last_edited_user IS NOT DISTINCT FROM $18 AND - lv.last_edited_date IS NOT DISTINCT FROM $19 AND - lv.gatewaysync IS NOT DISTINCT FROM $20 AND - lv.creationdate IS NOT DISTINCT FROM $21 AND - lv.creator IS NOT DISTINCT FROM $22 AND - lv.editdate IS NOT DISTINCT FROM $23 AND - lv.editor IS NOT DISTINCT FROM $24 - ) -RETURNING *; - --- Example usage: EXECUTE insert_samplelocation_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NAME (varchar) --- $3: ZONE (varchar) --- $4: HABITAT (fieldseeker.samplelocation_locationhabitattype_enum) --- $5: PRIORITY (fieldseeker.samplelocation_locationpriority_enum) --- $6: USETYPE (fieldseeker.samplelocation_samplelocationusetype_enum) --- $7: ACTIVE (fieldseeker.samplelocation_notinuit_f_enum) --- $8: DESCRIPTION (varchar) --- $9: ACCESSDESC (varchar) --- $10: COMMENTS (varchar) --- $11: EXTERNALID (varchar) --- $12: NEXTACTIONDATESCHEDULED (timestamp) --- $13: ZONE2 (varchar) --- $14: LOCATIONNUMBER (integer) --- $15: GlobalID (uuid) --- $16: created_user (varchar) --- $17: created_date (timestamp) --- $18: last_edited_user (varchar) --- $19: last_edited_date (timestamp) --- $20: GATEWAYSYNC (smallint) --- $21: CreationDate (timestamp) --- $22: Creator (varchar) --- $23: EditDate (timestamp) --- $24: Editor (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_samplelocation( + p_objectid bigint, + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_externalid varchar, + p_nextactiondatescheduled timestamp, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_gatewaysync smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.samplelocation lv + WHERE lv.objectid = p_objectid + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.samplelocation + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.samplelocation + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.samplelocation ( + objectid, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + externalid, + nextactiondatescheduled, + zone2, + locationnumber, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + gatewaysync, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_externalid, + p_nextactiondatescheduled, + p_zone2, + p_locationnumber, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_gatewaysync, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_servicerequest_versioned.sql b/db/fieldseeker-schema/insert/insert_servicerequest_versioned.sql index 7ecf3d12..f2049d18 100644 --- a/db/fieldseeker-schema/insert/insert_servicerequest_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_servicerequest_versioned.sql @@ -1,208 +1,397 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.servicerequest --- Only inserts a new version if data has changed -PREPARE insert_servicerequest_versioned(bigint, timestamp, fieldseeker.servicerequest_servicerequestsource_enum, varchar, fieldseeker.servicerequest_servicerequestpriority_enum, fieldseeker.servicerequest_servicerequest_supervisor_eba07b90_c885_4fe6_8080_7aa775403b9a_enum, fieldseeker.servicerequest_servicerequest_assignedtech_71d0d685_868f_4b7a_87e2_3661a3ee67c5_enum, fieldseeker.servicerequest_servicerequeststatus_enum, fieldseeker.servicerequest_notinuit_f_enum, varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar, fieldseeker.servicerequest_servicerequestregion_enum, varchar, varchar, fieldseeker.servicerequest_servicerequestcontactpreferences_enum, varchar, varchar, varchar, varchar, fieldseeker.servicerequest_servicerequestregion_enum, varchar, varchar, varchar, varchar, fieldseeker.servicerequest_notinuit_f_enum, fieldseeker.servicerequest_servicerequesttarget_enum, varchar, varchar, varchar, varchar, varchar, timestamp, varchar, integer, fieldseeker.servicerequest_notinuit_f_enum, varchar, timestamp, fieldseeker.servicerequest_notinuit_f_enum, timestamp, varchar, timestamp, fieldseeker.servicerequest_servicerequestrejectedreason_enum, timestamp, varchar, varchar, timestamp, fieldseeker.servicerequest_servicerequestnextaction_enum, smallint, uuid, varchar, timestamp, varchar, timestamp, timestamp, smallint, varchar, varchar, varchar, varchar, varchar, varchar, varchar, uuid, smallint, timestamp, smallint, timestamp, fieldseeker.servicerequest_servicerequest_dog_2b95ec97_1286_4fcd_88f4_f0e31113f696_enum, fieldseeker.servicerequest_servicerequest_schedule_period_3f40c046_afd1_4abd_8bf4_389650d29a49_enum, varchar, fieldseeker.servicerequest_servicerequest_spanish_aaa3dc66_9f9a_4527_8ecd_c9f76db33879_enum, timestamp, varchar, timestamp, varchar, fieldseeker.servicerequest_servicerequestissues_enum, varchar, varchar, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.servicerequest - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.servicerequest - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.servicerequest ( - objectid, recdatetime, source, entrytech, priority, supervisor, assignedtech, status, clranon, clrfname, clrphone1, clrphone2, clremail, clrcompany, clraddr1, clraddr2, clrcity, clrstate, clrzip, clrother, clrcontpref, reqcompany, reqaddr1, reqaddr2, reqcity, reqstate, reqzip, reqcrossst, reqsubdiv, reqmapgrid, reqpermission, reqtarget, reqdescr, reqnotesfortech, reqnotesforcust, reqfldnotes, reqprogramactions, datetimeclosed, techclosed, sr_number, reviewed, reviewedby, revieweddate, accepted, accepteddate, rejectedby, rejecteddate, rejectedreason, duedate, acceptedby, comments, estcompletedate, nextaction, recordstatus, globalid, created_user, created_date, last_edited_user, last_edited_date, firstresponsedate, responsedaycount, allowed, xvalue, yvalue, validx, validy, externalid, externalerror, pointlocid, notified, notifieddate, scheduled, scheduleddate, dog, schedule_period, schedule_notes, spanish, creationdate, creator, editdate, editor, issuesreported, jurisdiction, notificationtimestamp, zone, zone2, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $80, $81, $82, $83, $84, $85, $86, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.recdatetime IS NOT DISTINCT FROM $2 AND - lv.source IS NOT DISTINCT FROM $3 AND - lv.entrytech IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.supervisor IS NOT DISTINCT FROM $6 AND - lv.assignedtech IS NOT DISTINCT FROM $7 AND - lv.status IS NOT DISTINCT FROM $8 AND - lv.clranon IS NOT DISTINCT FROM $9 AND - lv.clrfname IS NOT DISTINCT FROM $10 AND - lv.clrphone1 IS NOT DISTINCT FROM $11 AND - lv.clrphone2 IS NOT DISTINCT FROM $12 AND - lv.clremail IS NOT DISTINCT FROM $13 AND - lv.clrcompany IS NOT DISTINCT FROM $14 AND - lv.clraddr1 IS NOT DISTINCT FROM $15 AND - lv.clraddr2 IS NOT DISTINCT FROM $16 AND - lv.clrcity IS NOT DISTINCT FROM $17 AND - lv.clrstate IS NOT DISTINCT FROM $18 AND - lv.clrzip IS NOT DISTINCT FROM $19 AND - lv.clrother IS NOT DISTINCT FROM $20 AND - lv.clrcontpref IS NOT DISTINCT FROM $21 AND - lv.reqcompany IS NOT DISTINCT FROM $22 AND - lv.reqaddr1 IS NOT DISTINCT FROM $23 AND - lv.reqaddr2 IS NOT DISTINCT FROM $24 AND - lv.reqcity IS NOT DISTINCT FROM $25 AND - lv.reqstate IS NOT DISTINCT FROM $26 AND - lv.reqzip IS NOT DISTINCT FROM $27 AND - lv.reqcrossst IS NOT DISTINCT FROM $28 AND - lv.reqsubdiv IS NOT DISTINCT FROM $29 AND - lv.reqmapgrid IS NOT DISTINCT FROM $30 AND - lv.reqpermission IS NOT DISTINCT FROM $31 AND - lv.reqtarget IS NOT DISTINCT FROM $32 AND - lv.reqdescr IS NOT DISTINCT FROM $33 AND - lv.reqnotesfortech IS NOT DISTINCT FROM $34 AND - lv.reqnotesforcust IS NOT DISTINCT FROM $35 AND - lv.reqfldnotes IS NOT DISTINCT FROM $36 AND - lv.reqprogramactions IS NOT DISTINCT FROM $37 AND - lv.datetimeclosed IS NOT DISTINCT FROM $38 AND - lv.techclosed IS NOT DISTINCT FROM $39 AND - lv.sr_number IS NOT DISTINCT FROM $40 AND - lv.reviewed IS NOT DISTINCT FROM $41 AND - lv.reviewedby IS NOT DISTINCT FROM $42 AND - lv.revieweddate IS NOT DISTINCT FROM $43 AND - lv.accepted IS NOT DISTINCT FROM $44 AND - lv.accepteddate IS NOT DISTINCT FROM $45 AND - lv.rejectedby IS NOT DISTINCT FROM $46 AND - lv.rejecteddate IS NOT DISTINCT FROM $47 AND - lv.rejectedreason IS NOT DISTINCT FROM $48 AND - lv.duedate IS NOT DISTINCT FROM $49 AND - lv.acceptedby IS NOT DISTINCT FROM $50 AND - lv.comments IS NOT DISTINCT FROM $51 AND - lv.estcompletedate IS NOT DISTINCT FROM $52 AND - lv.nextaction IS NOT DISTINCT FROM $53 AND - lv.recordstatus IS NOT DISTINCT FROM $54 AND - lv.globalid IS NOT DISTINCT FROM $55 AND - lv.created_user IS NOT DISTINCT FROM $56 AND - lv.created_date IS NOT DISTINCT FROM $57 AND - lv.last_edited_user IS NOT DISTINCT FROM $58 AND - lv.last_edited_date IS NOT DISTINCT FROM $59 AND - lv.firstresponsedate IS NOT DISTINCT FROM $60 AND - lv.responsedaycount IS NOT DISTINCT FROM $61 AND - lv.allowed IS NOT DISTINCT FROM $62 AND - lv.xvalue IS NOT DISTINCT FROM $63 AND - lv.yvalue IS NOT DISTINCT FROM $64 AND - lv.validx IS NOT DISTINCT FROM $65 AND - lv.validy IS NOT DISTINCT FROM $66 AND - lv.externalid IS NOT DISTINCT FROM $67 AND - lv.externalerror IS NOT DISTINCT FROM $68 AND - lv.pointlocid IS NOT DISTINCT FROM $69 AND - lv.notified IS NOT DISTINCT FROM $70 AND - lv.notifieddate IS NOT DISTINCT FROM $71 AND - lv.scheduled IS NOT DISTINCT FROM $72 AND - lv.scheduleddate IS NOT DISTINCT FROM $73 AND - lv.dog IS NOT DISTINCT FROM $74 AND - lv.schedule_period IS NOT DISTINCT FROM $75 AND - lv.schedule_notes IS NOT DISTINCT FROM $76 AND - lv.spanish IS NOT DISTINCT FROM $77 AND - lv.creationdate IS NOT DISTINCT FROM $78 AND - lv.creator IS NOT DISTINCT FROM $79 AND - lv.editdate IS NOT DISTINCT FROM $80 AND - lv.editor IS NOT DISTINCT FROM $81 AND - lv.issuesreported IS NOT DISTINCT FROM $82 AND - lv.jurisdiction IS NOT DISTINCT FROM $83 AND - lv.notificationtimestamp IS NOT DISTINCT FROM $84 AND - lv.zone IS NOT DISTINCT FROM $85 AND - lv.zone2 IS NOT DISTINCT FROM $86 - ) -RETURNING *; - --- Example usage: EXECUTE insert_servicerequest_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: RECDATETIME (timestamp) --- $3: SOURCE (fieldseeker.servicerequest_servicerequestsource_enum) --- $4: ENTRYTECH (varchar) --- $5: PRIORITY (fieldseeker.servicerequest_servicerequestpriority_enum) --- $6: SUPERVISOR (fieldseeker.servicerequest_servicerequest_supervisor_eba07b90_c885_4fe6_8080_7aa775403b9a_enum) --- $7: ASSIGNEDTECH (fieldseeker.servicerequest_servicerequest_assignedtech_71d0d685_868f_4b7a_87e2_3661a3ee67c5_enum) --- $8: STATUS (fieldseeker.servicerequest_servicerequeststatus_enum) --- $9: CLRANON (fieldseeker.servicerequest_notinuit_f_enum) --- $10: CLRFNAME (varchar) --- $11: CLRPHONE1 (varchar) --- $12: CLRPHONE2 (varchar) --- $13: CLREMAIL (varchar) --- $14: CLRCOMPANY (varchar) --- $15: CLRADDR1 (varchar) --- $16: CLRADDR2 (varchar) --- $17: CLRCITY (varchar) --- $18: CLRSTATE (fieldseeker.servicerequest_servicerequestregion_enum) --- $19: CLRZIP (varchar) --- $20: CLROTHER (varchar) --- $21: CLRCONTPREF (fieldseeker.servicerequest_servicerequestcontactpreferences_enum) --- $22: REQCOMPANY (varchar) --- $23: REQADDR1 (varchar) --- $24: REQADDR2 (varchar) --- $25: REQCITY (varchar) --- $26: REQSTATE (fieldseeker.servicerequest_servicerequestregion_enum) --- $27: REQZIP (varchar) --- $28: REQCROSSST (varchar) --- $29: REQSUBDIV (varchar) --- $30: REQMAPGRID (varchar) --- $31: REQPERMISSION (fieldseeker.servicerequest_notinuit_f_enum) --- $32: REQTARGET (fieldseeker.servicerequest_servicerequesttarget_enum) --- $33: REQDESCR (varchar) --- $34: REQNOTESFORTECH (varchar) --- $35: REQNOTESFORCUST (varchar) --- $36: REQFLDNOTES (varchar) --- $37: REQPROGRAMACTIONS (varchar) --- $38: DATETIMECLOSED (timestamp) --- $39: TECHCLOSED (varchar) --- $40: SR_NUMBER (integer) --- $41: REVIEWED (fieldseeker.servicerequest_notinuit_f_enum) --- $42: REVIEWEDBY (varchar) --- $43: REVIEWEDDATE (timestamp) --- $44: ACCEPTED (fieldseeker.servicerequest_notinuit_f_enum) --- $45: ACCEPTEDDATE (timestamp) --- $46: REJECTEDBY (varchar) --- $47: REJECTEDDATE (timestamp) --- $48: REJECTEDREASON (fieldseeker.servicerequest_servicerequestrejectedreason_enum) --- $49: DUEDATE (timestamp) --- $50: ACCEPTEDBY (varchar) --- $51: COMMENTS (varchar) --- $52: ESTCOMPLETEDATE (timestamp) --- $53: NEXTACTION (fieldseeker.servicerequest_servicerequestnextaction_enum) --- $54: RECORDSTATUS (smallint) --- $55: GlobalID (uuid) --- $56: created_user (varchar) --- $57: created_date (timestamp) --- $58: last_edited_user (varchar) --- $59: last_edited_date (timestamp) --- $60: FIRSTRESPONSEDATE (timestamp) --- $61: RESPONSEDAYCOUNT (smallint) --- $62: ALLOWED (varchar) --- $63: XVALUE (varchar) --- $64: YVALUE (varchar) --- $65: VALIDX (varchar) --- $66: VALIDY (varchar) --- $67: EXTERNALID (varchar) --- $68: EXTERNALERROR (varchar) --- $69: POINTLOCID (uuid) --- $70: NOTIFIED (smallint) --- $71: NOTIFIEDDATE (timestamp) --- $72: SCHEDULED (smallint) --- $73: SCHEDULEDDATE (timestamp) --- $74: DOG (fieldseeker.servicerequest_servicerequest_dog_2b95ec97_1286_4fcd_88f4_f0e31113f696_enum) --- $75: schedule_period (fieldseeker.servicerequest_servicerequest_schedule_period_3f40c046_afd1_4abd_8bf4_389650d29a49_enum) --- $76: schedule_notes (varchar) --- $77: Spanish (fieldseeker.servicerequest_servicerequest_spanish_aaa3dc66_9f9a_4527_8ecd_c9f76db33879_enum) --- $78: CreationDate (timestamp) --- $79: Creator (varchar) --- $80: EditDate (timestamp) --- $81: Editor (varchar) --- $82: ISSUESREPORTED (fieldseeker.servicerequest_servicerequestissues_enum) --- $83: JURISDICTION (varchar) --- $84: NOTIFICATIONTIMESTAMP (varchar) --- $85: ZONE (varchar) --- $86: ZONE2 (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_servicerequest( + p_objectid bigint, + + p_recdatetime timestamp, + p_source varchar, + p_entrytech varchar, + p_priority varchar, + p_supervisor varchar, + p_assignedtech varchar, + p_status varchar, + p_clranon smallint, + p_clrfname varchar, + p_clrphone1 varchar, + p_clrphone2 varchar, + p_clremail varchar, + p_clrcompany varchar, + p_clraddr1 varchar, + p_clraddr2 varchar, + p_clrcity varchar, + p_clrstate varchar, + p_clrzip varchar, + p_clrother varchar, + p_clrcontpref varchar, + p_reqcompany varchar, + p_reqaddr1 varchar, + p_reqaddr2 varchar, + p_reqcity varchar, + p_reqstate varchar, + p_reqzip varchar, + p_reqcrossst varchar, + p_reqsubdiv varchar, + p_reqmapgrid varchar, + p_reqpermission smallint, + p_reqtarget varchar, + p_reqdescr varchar, + p_reqnotesfortech varchar, + p_reqnotesforcust varchar, + p_reqfldnotes varchar, + p_reqprogramactions varchar, + p_datetimeclosed timestamp, + p_techclosed varchar, + p_sr_number integer, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_accepted smallint, + p_accepteddate timestamp, + p_rejectedby varchar, + p_rejecteddate timestamp, + p_rejectedreason varchar, + p_duedate timestamp, + p_acceptedby varchar, + p_comments varchar, + p_estcompletedate timestamp, + p_nextaction varchar, + p_recordstatus smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_firstresponsedate timestamp, + p_responsedaycount smallint, + p_allowed varchar, + p_xvalue varchar, + p_yvalue varchar, + p_validx varchar, + p_validy varchar, + p_externalid varchar, + p_externalerror varchar, + p_pointlocid uuid, + p_notified smallint, + p_notifieddate timestamp, + p_scheduled smallint, + p_scheduleddate timestamp, + p_dog integer, + p_schedule_period varchar, + p_schedule_notes varchar, + p_spanish integer, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_issuesreported varchar, + p_jurisdiction varchar, + p_notificationtimestamp varchar, + p_zone varchar, + p_zone2 varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.servicerequest lv + WHERE lv.objectid = p_objectid + + AND lv.recdatetime IS NOT DISTINCT FROM p_recdatetime + AND lv.source IS NOT DISTINCT FROM p_source + AND lv.entrytech IS NOT DISTINCT FROM p_entrytech + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.supervisor IS NOT DISTINCT FROM p_supervisor + AND lv.assignedtech IS NOT DISTINCT FROM p_assignedtech + AND lv.status IS NOT DISTINCT FROM p_status + AND lv.clranon IS NOT DISTINCT FROM p_clranon + AND lv.clrfname IS NOT DISTINCT FROM p_clrfname + AND lv.clrphone1 IS NOT DISTINCT FROM p_clrphone1 + AND lv.clrphone2 IS NOT DISTINCT FROM p_clrphone2 + AND lv.clremail IS NOT DISTINCT FROM p_clremail + AND lv.clrcompany IS NOT DISTINCT FROM p_clrcompany + AND lv.clraddr1 IS NOT DISTINCT FROM p_clraddr1 + AND lv.clraddr2 IS NOT DISTINCT FROM p_clraddr2 + AND lv.clrcity IS NOT DISTINCT FROM p_clrcity + AND lv.clrstate IS NOT DISTINCT FROM p_clrstate + AND lv.clrzip IS NOT DISTINCT FROM p_clrzip + AND lv.clrother IS NOT DISTINCT FROM p_clrother + AND lv.clrcontpref IS NOT DISTINCT FROM p_clrcontpref + AND lv.reqcompany IS NOT DISTINCT FROM p_reqcompany + AND lv.reqaddr1 IS NOT DISTINCT FROM p_reqaddr1 + AND lv.reqaddr2 IS NOT DISTINCT FROM p_reqaddr2 + AND lv.reqcity IS NOT DISTINCT FROM p_reqcity + AND lv.reqstate IS NOT DISTINCT FROM p_reqstate + AND lv.reqzip IS NOT DISTINCT FROM p_reqzip + AND lv.reqcrossst IS NOT DISTINCT FROM p_reqcrossst + AND lv.reqsubdiv IS NOT DISTINCT FROM p_reqsubdiv + AND lv.reqmapgrid IS NOT DISTINCT FROM p_reqmapgrid + AND lv.reqpermission IS NOT DISTINCT FROM p_reqpermission + AND lv.reqtarget IS NOT DISTINCT FROM p_reqtarget + AND lv.reqdescr IS NOT DISTINCT FROM p_reqdescr + AND lv.reqnotesfortech IS NOT DISTINCT FROM p_reqnotesfortech + AND lv.reqnotesforcust IS NOT DISTINCT FROM p_reqnotesforcust + AND lv.reqfldnotes IS NOT DISTINCT FROM p_reqfldnotes + AND lv.reqprogramactions IS NOT DISTINCT FROM p_reqprogramactions + AND lv.datetimeclosed IS NOT DISTINCT FROM p_datetimeclosed + AND lv.techclosed IS NOT DISTINCT FROM p_techclosed + AND lv.sr_number IS NOT DISTINCT FROM p_sr_number + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.accepted IS NOT DISTINCT FROM p_accepted + AND lv.accepteddate IS NOT DISTINCT FROM p_accepteddate + AND lv.rejectedby IS NOT DISTINCT FROM p_rejectedby + AND lv.rejecteddate IS NOT DISTINCT FROM p_rejecteddate + AND lv.rejectedreason IS NOT DISTINCT FROM p_rejectedreason + AND lv.duedate IS NOT DISTINCT FROM p_duedate + AND lv.acceptedby IS NOT DISTINCT FROM p_acceptedby + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.estcompletedate IS NOT DISTINCT FROM p_estcompletedate + AND lv.nextaction IS NOT DISTINCT FROM p_nextaction + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.firstresponsedate IS NOT DISTINCT FROM p_firstresponsedate + AND lv.responsedaycount IS NOT DISTINCT FROM p_responsedaycount + AND lv.allowed IS NOT DISTINCT FROM p_allowed + AND lv.xvalue IS NOT DISTINCT FROM p_xvalue + AND lv.yvalue IS NOT DISTINCT FROM p_yvalue + AND lv.validx IS NOT DISTINCT FROM p_validx + AND lv.validy IS NOT DISTINCT FROM p_validy + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.externalerror IS NOT DISTINCT FROM p_externalerror + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.notified IS NOT DISTINCT FROM p_notified + AND lv.notifieddate IS NOT DISTINCT FROM p_notifieddate + AND lv.scheduled IS NOT DISTINCT FROM p_scheduled + AND lv.scheduleddate IS NOT DISTINCT FROM p_scheduleddate + AND lv.dog IS NOT DISTINCT FROM p_dog + AND lv.schedule_period IS NOT DISTINCT FROM p_schedule_period + AND lv.schedule_notes IS NOT DISTINCT FROM p_schedule_notes + AND lv.spanish IS NOT DISTINCT FROM p_spanish + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.issuesreported IS NOT DISTINCT FROM p_issuesreported + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.notificationtimestamp IS NOT DISTINCT FROM p_notificationtimestamp + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.servicerequest + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.servicerequest + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.servicerequest ( + objectid, + + recdatetime, + source, + entrytech, + priority, + supervisor, + assignedtech, + status, + clranon, + clrfname, + clrphone1, + clrphone2, + clremail, + clrcompany, + clraddr1, + clraddr2, + clrcity, + clrstate, + clrzip, + clrother, + clrcontpref, + reqcompany, + reqaddr1, + reqaddr2, + reqcity, + reqstate, + reqzip, + reqcrossst, + reqsubdiv, + reqmapgrid, + reqpermission, + reqtarget, + reqdescr, + reqnotesfortech, + reqnotesforcust, + reqfldnotes, + reqprogramactions, + datetimeclosed, + techclosed, + sr_number, + reviewed, + reviewedby, + revieweddate, + accepted, + accepteddate, + rejectedby, + rejecteddate, + rejectedreason, + duedate, + acceptedby, + comments, + estcompletedate, + nextaction, + recordstatus, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + firstresponsedate, + responsedaycount, + allowed, + xvalue, + yvalue, + validx, + validy, + externalid, + externalerror, + pointlocid, + notified, + notifieddate, + scheduled, + scheduleddate, + dog, + schedule_period, + schedule_notes, + spanish, + creationdate, + creator, + editdate, + editor, + issuesreported, + jurisdiction, + notificationtimestamp, + zone, + zone2, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_recdatetime, + p_source, + p_entrytech, + p_priority, + p_supervisor, + p_assignedtech, + p_status, + p_clranon, + p_clrfname, + p_clrphone1, + p_clrphone2, + p_clremail, + p_clrcompany, + p_clraddr1, + p_clraddr2, + p_clrcity, + p_clrstate, + p_clrzip, + p_clrother, + p_clrcontpref, + p_reqcompany, + p_reqaddr1, + p_reqaddr2, + p_reqcity, + p_reqstate, + p_reqzip, + p_reqcrossst, + p_reqsubdiv, + p_reqmapgrid, + p_reqpermission, + p_reqtarget, + p_reqdescr, + p_reqnotesfortech, + p_reqnotesforcust, + p_reqfldnotes, + p_reqprogramactions, + p_datetimeclosed, + p_techclosed, + p_sr_number, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_accepted, + p_accepteddate, + p_rejectedby, + p_rejecteddate, + p_rejectedreason, + p_duedate, + p_acceptedby, + p_comments, + p_estcompletedate, + p_nextaction, + p_recordstatus, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_firstresponsedate, + p_responsedaycount, + p_allowed, + p_xvalue, + p_yvalue, + p_validx, + p_validy, + p_externalid, + p_externalerror, + p_pointlocid, + p_notified, + p_notifieddate, + p_scheduled, + p_scheduleddate, + p_dog, + p_schedule_period, + p_schedule_notes, + p_spanish, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_issuesreported, + p_jurisdiction, + p_notificationtimestamp, + p_zone, + p_zone2, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_speciesabundance_versioned.sql b/db/fieldseeker-schema/insert/insert_speciesabundance_versioned.sql index 1b4dd628..3369f95f 100644 --- a/db/fieldseeker-schema/insert/insert_speciesabundance_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_speciesabundance_versioned.sql @@ -1,94 +1,169 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.speciesabundance --- Only inserts a new version if data has changed -PREPARE insert_speciesabundance_versioned(bigint, uuid, varchar, smallint, smallint, smallint, smallint, smallint, smallint, fieldseeker.speciesabundance_notinuit_f_enum, uuid, varchar, timestamp, varchar, timestamp, smallint, smallint, integer, integer, timestamp, varchar, timestamp, varchar, integer, double precision, double precision, double precision, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.speciesabundance - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.speciesabundance - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.speciesabundance ( - objectid, trapdata_id, species, males, unknown, bloodedfem, gravidfem, larvae, poolstogen, processed, globalid, created_user, created_date, last_edited_user, last_edited_date, pupae, eggs, females, total, creationdate, creator, editdate, editor, yearweek, globalzscore, r7score, r8score, h3r7, h3r8, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.trapdata_id IS NOT DISTINCT FROM $2 AND - lv.species IS NOT DISTINCT FROM $3 AND - lv.males IS NOT DISTINCT FROM $4 AND - lv.unknown IS NOT DISTINCT FROM $5 AND - lv.bloodedfem IS NOT DISTINCT FROM $6 AND - lv.gravidfem IS NOT DISTINCT FROM $7 AND - lv.larvae IS NOT DISTINCT FROM $8 AND - lv.poolstogen IS NOT DISTINCT FROM $9 AND - lv.processed IS NOT DISTINCT FROM $10 AND - lv.globalid IS NOT DISTINCT FROM $11 AND - lv.created_user IS NOT DISTINCT FROM $12 AND - lv.created_date IS NOT DISTINCT FROM $13 AND - lv.last_edited_user IS NOT DISTINCT FROM $14 AND - lv.last_edited_date IS NOT DISTINCT FROM $15 AND - lv.pupae IS NOT DISTINCT FROM $16 AND - lv.eggs IS NOT DISTINCT FROM $17 AND - lv.females IS NOT DISTINCT FROM $18 AND - lv.total IS NOT DISTINCT FROM $19 AND - lv.creationdate IS NOT DISTINCT FROM $20 AND - lv.creator IS NOT DISTINCT FROM $21 AND - lv.editdate IS NOT DISTINCT FROM $22 AND - lv.editor IS NOT DISTINCT FROM $23 AND - lv.yearweek IS NOT DISTINCT FROM $24 AND - lv.globalzscore IS NOT DISTINCT FROM $25 AND - lv.r7score IS NOT DISTINCT FROM $26 AND - lv.r8score IS NOT DISTINCT FROM $27 AND - lv.h3r7 IS NOT DISTINCT FROM $28 AND - lv.h3r8 IS NOT DISTINCT FROM $29 - ) -RETURNING *; - --- Example usage: EXECUTE insert_speciesabundance_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: TRAPDATA_ID (uuid) --- $3: SPECIES (varchar) --- $4: MALES (smallint) --- $5: UNKNOWN (smallint) --- $6: BLOODEDFEM (smallint) --- $7: GRAVIDFEM (smallint) --- $8: LARVAE (smallint) --- $9: POOLSTOGEN (smallint) --- $10: PROCESSED (fieldseeker.speciesabundance_notinuit_f_enum) --- $11: GlobalID (uuid) --- $12: created_user (varchar) --- $13: created_date (timestamp) --- $14: last_edited_user (varchar) --- $15: last_edited_date (timestamp) --- $16: PUPAE (smallint) --- $17: EGGS (smallint) --- $18: FEMALES (integer) --- $19: TOTAL (integer) --- $20: CreationDate (timestamp) --- $21: Creator (varchar) --- $22: EditDate (timestamp) --- $23: Editor (varchar) --- $24: yearWeek (integer) --- $25: globalZScore (double precision) --- $26: r7Score (double precision) --- $27: r8Score (double precision) --- $28: h3r7 (varchar) --- $29: h3r8 (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_speciesabundance( + p_objectid bigint, + + p_trapdata_id uuid, + p_species varchar, + p_males smallint, + p_unknown smallint, + p_bloodedfem smallint, + p_gravidfem smallint, + p_larvae smallint, + p_poolstogen smallint, + p_processed smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_pupae smallint, + p_eggs smallint, + p_females integer, + p_total integer, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_yearweek integer, + p_globalzscore double precision, + p_r7score double precision, + p_r8score double precision, + p_h3r7 varchar, + p_h3r8 varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.speciesabundance lv + WHERE lv.objectid = p_objectid + + AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id + AND lv.species IS NOT DISTINCT FROM p_species + AND lv.males IS NOT DISTINCT FROM p_males + AND lv.unknown IS NOT DISTINCT FROM p_unknown + AND lv.bloodedfem IS NOT DISTINCT FROM p_bloodedfem + AND lv.gravidfem IS NOT DISTINCT FROM p_gravidfem + AND lv.larvae IS NOT DISTINCT FROM p_larvae + AND lv.poolstogen IS NOT DISTINCT FROM p_poolstogen + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.pupae IS NOT DISTINCT FROM p_pupae + AND lv.eggs IS NOT DISTINCT FROM p_eggs + AND lv.females IS NOT DISTINCT FROM p_females + AND lv.total IS NOT DISTINCT FROM p_total + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.yearweek IS NOT DISTINCT FROM p_yearweek + AND lv.globalzscore IS NOT DISTINCT FROM p_globalzscore + AND lv.r7score IS NOT DISTINCT FROM p_r7score + AND lv.r8score IS NOT DISTINCT FROM p_r8score + AND lv.h3r7 IS NOT DISTINCT FROM p_h3r7 + AND lv.h3r8 IS NOT DISTINCT FROM p_h3r8 + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.speciesabundance + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.speciesabundance + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.speciesabundance ( + objectid, + + trapdata_id, + species, + males, + unknown, + bloodedfem, + gravidfem, + larvae, + poolstogen, + processed, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + pupae, + eggs, + females, + total, + creationdate, + creator, + editdate, + editor, + yearweek, + globalzscore, + r7score, + r8score, + h3r7, + h3r8, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_trapdata_id, + p_species, + p_males, + p_unknown, + p_bloodedfem, + p_gravidfem, + p_larvae, + p_poolstogen, + p_processed, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_pupae, + p_eggs, + p_females, + p_total, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_yearweek, + p_globalzscore, + p_r7score, + p_r8score, + p_h3r7, + p_h3r8, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_stormdrain_versioned.sql b/db/fieldseeker-schema/insert/insert_stormdrain_versioned.sql index 48ee551a..abf3935f 100644 --- a/db/fieldseeker-schema/insert/insert_stormdrain_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_stormdrain_versioned.sql @@ -1,74 +1,129 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.stormdrain --- Only inserts a new version if data has changed -PREPARE insert_stormdrain_versioned(bigint, timestamp, timestamp, varchar, fieldseeker.stormdrain_stormdrainsymbology_enum, uuid, varchar, timestamp, varchar, timestamp, varchar, varchar, varchar, timestamp, varchar, timestamp, varchar, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.stormdrain - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.stormdrain - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.stormdrain ( - objectid, nexttreatmentdate, lasttreatdate, lastaction, symbology, globalid, created_user, created_date, last_edited_user, last_edited_date, laststatus, zone, zone2, creationdate, creator, editdate, editor, type, jurisdiction, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.nexttreatmentdate IS NOT DISTINCT FROM $2 AND - lv.lasttreatdate IS NOT DISTINCT FROM $3 AND - lv.lastaction IS NOT DISTINCT FROM $4 AND - lv.symbology IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.laststatus IS NOT DISTINCT FROM $11 AND - lv.zone IS NOT DISTINCT FROM $12 AND - lv.zone2 IS NOT DISTINCT FROM $13 AND - lv.creationdate IS NOT DISTINCT FROM $14 AND - lv.creator IS NOT DISTINCT FROM $15 AND - lv.editdate IS NOT DISTINCT FROM $16 AND - lv.editor IS NOT DISTINCT FROM $17 AND - lv.type IS NOT DISTINCT FROM $18 AND - lv.jurisdiction IS NOT DISTINCT FROM $19 - ) -RETURNING *; - --- Example usage: EXECUTE insert_stormdrain_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NextTreatmentDate (timestamp) --- $3: LastTreatDate (timestamp) --- $4: LastAction (varchar) --- $5: Symbology (fieldseeker.stormdrain_stormdrainsymbology_enum) --- $6: GlobalID (uuid) --- $7: created_user (varchar) --- $8: created_date (timestamp) --- $9: last_edited_user (varchar) --- $10: last_edited_date (timestamp) --- $11: LastStatus (varchar) --- $12: ZONE (varchar) --- $13: ZONE2 (varchar) --- $14: CreationDate (timestamp) --- $15: Creator (varchar) --- $16: EditDate (timestamp) --- $17: Editor (varchar) --- $18: TYPE (varchar) --- $19: JURISDICTION (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_stormdrain( + p_objectid bigint, + + p_nexttreatmentdate timestamp, + p_lasttreatdate timestamp, + p_lastaction varchar, + p_symbology varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_laststatus varchar, + p_zone varchar, + p_zone2 varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_type varchar, + p_jurisdiction varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.stormdrain lv + WHERE lv.objectid = p_objectid + + AND lv.nexttreatmentdate IS NOT DISTINCT FROM p_nexttreatmentdate + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lastaction IS NOT DISTINCT FROM p_lastaction + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.laststatus IS NOT DISTINCT FROM p_laststatus + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.type IS NOT DISTINCT FROM p_type + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.stormdrain + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.stormdrain + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.stormdrain ( + objectid, + + nexttreatmentdate, + lasttreatdate, + lastaction, + symbology, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + laststatus, + zone, + zone2, + creationdate, + creator, + editdate, + editor, + type, + jurisdiction, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_nexttreatmentdate, + p_lasttreatdate, + p_lastaction, + p_symbology, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_laststatus, + p_zone, + p_zone2, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_type, + p_jurisdiction, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_timecard_versioned.sql b/db/fieldseeker-schema/insert/insert_timecard_versioned.sql index 45a7371d..f8b29226 100644 --- a/db/fieldseeker-schema/insert/insert_timecard_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_timecard_versioned.sql @@ -1,92 +1,165 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.timecard --- Only inserts a new version if data has changed -PREPARE insert_timecard_versioned(bigint, fieldseeker.timecard_timecard_activity_451e67260c084304a35457170dc13366_enum, timestamp, timestamp, varchar, varchar, fieldseeker.timecard_timecardequipmenttype_enum, varchar, varchar, varchar, uuid, varchar, timestamp, varchar, timestamp, uuid, uuid, uuid, uuid, uuid, uuid, uuid, varchar, timestamp, varchar, timestamp, varchar, uuid) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.timecard - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.timecard - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.timecard ( - objectid, activity, startdatetime, enddatetime, comments, externalid, equiptype, locationname, zone, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, linelocid, pointlocid, polygonlocid, lclocid, samplelocid, srid, traplocid, fieldtech, creationdate, creator, editdate, editor, rodentlocid, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.activity IS NOT DISTINCT FROM $2 AND - lv.startdatetime IS NOT DISTINCT FROM $3 AND - lv.enddatetime IS NOT DISTINCT FROM $4 AND - lv.comments IS NOT DISTINCT FROM $5 AND - lv.externalid IS NOT DISTINCT FROM $6 AND - lv.equiptype IS NOT DISTINCT FROM $7 AND - lv.locationname IS NOT DISTINCT FROM $8 AND - lv.zone IS NOT DISTINCT FROM $9 AND - lv.zone2 IS NOT DISTINCT FROM $10 AND - lv.globalid IS NOT DISTINCT FROM $11 AND - lv.created_user IS NOT DISTINCT FROM $12 AND - lv.created_date IS NOT DISTINCT FROM $13 AND - lv.last_edited_user IS NOT DISTINCT FROM $14 AND - lv.last_edited_date IS NOT DISTINCT FROM $15 AND - lv.linelocid IS NOT DISTINCT FROM $16 AND - lv.pointlocid IS NOT DISTINCT FROM $17 AND - lv.polygonlocid IS NOT DISTINCT FROM $18 AND - lv.lclocid IS NOT DISTINCT FROM $19 AND - lv.samplelocid IS NOT DISTINCT FROM $20 AND - lv.srid IS NOT DISTINCT FROM $21 AND - lv.traplocid IS NOT DISTINCT FROM $22 AND - lv.fieldtech IS NOT DISTINCT FROM $23 AND - lv.creationdate IS NOT DISTINCT FROM $24 AND - lv.creator IS NOT DISTINCT FROM $25 AND - lv.editdate IS NOT DISTINCT FROM $26 AND - lv.editor IS NOT DISTINCT FROM $27 AND - lv.rodentlocid IS NOT DISTINCT FROM $28 - ) -RETURNING *; - --- Example usage: EXECUTE insert_timecard_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: ACTIVITY (fieldseeker.timecard_timecard_activity_451e67260c084304a35457170dc13366_enum) --- $3: STARTDATETIME (timestamp) --- $4: ENDDATETIME (timestamp) --- $5: COMMENTS (varchar) --- $6: EXTERNALID (varchar) --- $7: EQUIPTYPE (fieldseeker.timecard_timecardequipmenttype_enum) --- $8: LOCATIONNAME (varchar) --- $9: ZONE (varchar) --- $10: ZONE2 (varchar) --- $11: GlobalID (uuid) --- $12: created_user (varchar) --- $13: created_date (timestamp) --- $14: last_edited_user (varchar) --- $15: last_edited_date (timestamp) --- $16: LINELOCID (uuid) --- $17: POINTLOCID (uuid) --- $18: POLYGONLOCID (uuid) --- $19: LCLOCID (uuid) --- $20: SAMPLELOCID (uuid) --- $21: SRID (uuid) --- $22: TRAPLOCID (uuid) --- $23: FIELDTECH (varchar) --- $24: CreationDate (timestamp) --- $25: Creator (varchar) --- $26: EditDate (timestamp) --- $27: Editor (varchar) --- $28: RODENTLOCID (uuid) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_timecard( + p_objectid bigint, + + p_activity varchar, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_comments varchar, + p_externalid varchar, + p_equiptype varchar, + p_locationname varchar, + p_zone varchar, + p_zone2 varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_lclocid uuid, + p_samplelocid uuid, + p_srid uuid, + p_traplocid uuid, + p_fieldtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_rodentlocid uuid, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.timecard lv + WHERE lv.objectid = p_objectid + + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.equiptype IS NOT DISTINCT FROM p_equiptype + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.lclocid IS NOT DISTINCT FROM p_lclocid + AND lv.samplelocid IS NOT DISTINCT FROM p_samplelocid + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.traplocid IS NOT DISTINCT FROM p_traplocid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.rodentlocid IS NOT DISTINCT FROM p_rodentlocid + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.timecard + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.timecard + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.timecard ( + objectid, + + activity, + startdatetime, + enddatetime, + comments, + externalid, + equiptype, + locationname, + zone, + zone2, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + linelocid, + pointlocid, + polygonlocid, + lclocid, + samplelocid, + srid, + traplocid, + fieldtech, + creationdate, + creator, + editdate, + editor, + rodentlocid, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_activity, + p_startdatetime, + p_enddatetime, + p_comments, + p_externalid, + p_equiptype, + p_locationname, + p_zone, + p_zone2, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_lclocid, + p_samplelocid, + p_srid, + p_traplocid, + p_fieldtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_rodentlocid, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_trapdata_versioned.sql b/db/fieldseeker-schema/insert/insert_trapdata_versioned.sql index 2a5dadff..7aefa649 100644 --- a/db/fieldseeker-schema/insert/insert_trapdata_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_trapdata_versioned.sql @@ -1,120 +1,221 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.trapdata --- Only inserts a new version if data has changed -PREPARE insert_trapdata_versioned(bigint, fieldseeker.trapdata_mosquitotraptype_enum, fieldseeker.trapdata_notinuitrapactivitytype_enum, timestamp, timestamp, varchar, varchar, varchar, fieldseeker.trapdata_notinuit_f_enum, fieldseeker.trapdata_mosquitositecondition_enum, varchar, smallint, fieldseeker.trapdata_notinuit_f_enum, varchar, timestamp, fieldseeker.trapdata_mosquitotrapcondition_enum, smallint, varchar, varchar, uuid, varchar, timestamp, varchar, timestamp, uuid, varchar, smallint, uuid, double precision, fieldseeker.trapdata_trapdata_winddir_c1a31e05_d0b9_4b22_8800_be127bb3f166_enum, double precision, double precision, double precision, smallint, integer, varchar, varchar, timestamp, varchar, timestamp, varchar, fieldseeker.trapdata_trapdata_lure_25fe542f_077f_4254_8681_76e8f436354b_enum) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.trapdata - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.trapdata - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.trapdata ( - objectid, traptype, trapactivitytype, startdatetime, enddatetime, comments, idbytech, sortbytech, processed, sitecond, locationname, recordstatus, reviewed, reviewedby, revieweddate, trapcondition, trapnights, zone, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, srid, fieldtech, gatewaysync, loc_id, voltage, winddir, windspeed, avetemp, raingauge, lr, field, vectorsurvtrapdataid, vectorsurvtraplocationid, creationdate, creator, editdate, editor, lure, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.traptype IS NOT DISTINCT FROM $2 AND - lv.trapactivitytype IS NOT DISTINCT FROM $3 AND - lv.startdatetime IS NOT DISTINCT FROM $4 AND - lv.enddatetime IS NOT DISTINCT FROM $5 AND - lv.comments IS NOT DISTINCT FROM $6 AND - lv.idbytech IS NOT DISTINCT FROM $7 AND - lv.sortbytech IS NOT DISTINCT FROM $8 AND - lv.processed IS NOT DISTINCT FROM $9 AND - lv.sitecond IS NOT DISTINCT FROM $10 AND - lv.locationname IS NOT DISTINCT FROM $11 AND - lv.recordstatus IS NOT DISTINCT FROM $12 AND - lv.reviewed IS NOT DISTINCT FROM $13 AND - lv.reviewedby IS NOT DISTINCT FROM $14 AND - lv.revieweddate IS NOT DISTINCT FROM $15 AND - lv.trapcondition IS NOT DISTINCT FROM $16 AND - lv.trapnights IS NOT DISTINCT FROM $17 AND - lv.zone IS NOT DISTINCT FROM $18 AND - lv.zone2 IS NOT DISTINCT FROM $19 AND - lv.globalid IS NOT DISTINCT FROM $20 AND - lv.created_user IS NOT DISTINCT FROM $21 AND - lv.created_date IS NOT DISTINCT FROM $22 AND - lv.last_edited_user IS NOT DISTINCT FROM $23 AND - lv.last_edited_date IS NOT DISTINCT FROM $24 AND - lv.srid IS NOT DISTINCT FROM $25 AND - lv.fieldtech IS NOT DISTINCT FROM $26 AND - lv.gatewaysync IS NOT DISTINCT FROM $27 AND - lv.loc_id IS NOT DISTINCT FROM $28 AND - lv.voltage IS NOT DISTINCT FROM $29 AND - lv.winddir IS NOT DISTINCT FROM $30 AND - lv.windspeed IS NOT DISTINCT FROM $31 AND - lv.avetemp IS NOT DISTINCT FROM $32 AND - lv.raingauge IS NOT DISTINCT FROM $33 AND - lv.lr IS NOT DISTINCT FROM $34 AND - lv.field IS NOT DISTINCT FROM $35 AND - lv.vectorsurvtrapdataid IS NOT DISTINCT FROM $36 AND - lv.vectorsurvtraplocationid IS NOT DISTINCT FROM $37 AND - lv.creationdate IS NOT DISTINCT FROM $38 AND - lv.creator IS NOT DISTINCT FROM $39 AND - lv.editdate IS NOT DISTINCT FROM $40 AND - lv.editor IS NOT DISTINCT FROM $41 AND - lv.lure IS NOT DISTINCT FROM $42 - ) -RETURNING *; - --- Example usage: EXECUTE insert_trapdata_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: TRAPTYPE (fieldseeker.trapdata_mosquitotraptype_enum) --- $3: TRAPACTIVITYTYPE (fieldseeker.trapdata_notinuitrapactivitytype_enum) --- $4: STARTDATETIME (timestamp) --- $5: ENDDATETIME (timestamp) --- $6: COMMENTS (varchar) --- $7: IDBYTECH (varchar) --- $8: SORTBYTECH (varchar) --- $9: PROCESSED (fieldseeker.trapdata_notinuit_f_enum) --- $10: SITECOND (fieldseeker.trapdata_mosquitositecondition_enum) --- $11: LOCATIONNAME (varchar) --- $12: RECORDSTATUS (smallint) --- $13: REVIEWED (fieldseeker.trapdata_notinuit_f_enum) --- $14: REVIEWEDBY (varchar) --- $15: REVIEWEDDATE (timestamp) --- $16: TRAPCONDITION (fieldseeker.trapdata_mosquitotrapcondition_enum) --- $17: TRAPNIGHTS (smallint) --- $18: ZONE (varchar) --- $19: ZONE2 (varchar) --- $20: GlobalID (uuid) --- $21: created_user (varchar) --- $22: created_date (timestamp) --- $23: last_edited_user (varchar) --- $24: last_edited_date (timestamp) --- $25: SRID (uuid) --- $26: FIELDTECH (varchar) --- $27: GATEWAYSYNC (smallint) --- $28: LOC_ID (uuid) --- $29: VOLTAGE (double precision) --- $30: WINDDIR (fieldseeker.trapdata_trapdata_winddir_c1a31e05_d0b9_4b22_8800_be127bb3f166_enum) --- $31: WINDSPEED (double precision) --- $32: AVETEMP (double precision) --- $33: RAINGAUGE (double precision) --- $34: LR (smallint) --- $35: Field (integer) --- $36: VECTORSURVTRAPDATAID (varchar) --- $37: VECTORSURVTRAPLOCATIONID (varchar) --- $38: CreationDate (timestamp) --- $39: Creator (varchar) --- $40: EditDate (timestamp) --- $41: Editor (varchar) --- $42: Lure (fieldseeker.trapdata_trapdata_lure_25fe542f_077f_4254_8681_76e8f436354b_enum) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_trapdata( + p_objectid bigint, + + p_traptype varchar, + p_trapactivitytype varchar, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_comments varchar, + p_idbytech varchar, + p_sortbytech varchar, + p_processed smallint, + p_sitecond varchar, + p_locationname varchar, + p_recordstatus smallint, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_trapcondition varchar, + p_trapnights smallint, + p_zone varchar, + p_zone2 varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_srid uuid, + p_fieldtech varchar, + p_gatewaysync smallint, + p_loc_id uuid, + p_voltage double precision, + p_winddir varchar, + p_windspeed double precision, + p_avetemp double precision, + p_raingauge double precision, + p_lr smallint, + p_field integer, + p_vectorsurvtrapdataid varchar, + p_vectorsurvtraplocationid varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_lure varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.trapdata lv + WHERE lv.objectid = p_objectid + + AND lv.traptype IS NOT DISTINCT FROM p_traptype + AND lv.trapactivitytype IS NOT DISTINCT FROM p_trapactivitytype + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.idbytech IS NOT DISTINCT FROM p_idbytech + AND lv.sortbytech IS NOT DISTINCT FROM p_sortbytech + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.trapcondition IS NOT DISTINCT FROM p_trapcondition + AND lv.trapnights IS NOT DISTINCT FROM p_trapnights + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.loc_id IS NOT DISTINCT FROM p_loc_id + AND lv.voltage IS NOT DISTINCT FROM p_voltage + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.lr IS NOT DISTINCT FROM p_lr + AND lv.field IS NOT DISTINCT FROM p_field + AND lv.vectorsurvtrapdataid IS NOT DISTINCT FROM p_vectorsurvtrapdataid + AND lv.vectorsurvtraplocationid IS NOT DISTINCT FROM p_vectorsurvtraplocationid + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.lure IS NOT DISTINCT FROM p_lure + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.trapdata + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.trapdata + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.trapdata ( + objectid, + + traptype, + trapactivitytype, + startdatetime, + enddatetime, + comments, + idbytech, + sortbytech, + processed, + sitecond, + locationname, + recordstatus, + reviewed, + reviewedby, + revieweddate, + trapcondition, + trapnights, + zone, + zone2, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + srid, + fieldtech, + gatewaysync, + loc_id, + voltage, + winddir, + windspeed, + avetemp, + raingauge, + lr, + field, + vectorsurvtrapdataid, + vectorsurvtraplocationid, + creationdate, + creator, + editdate, + editor, + lure, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_traptype, + p_trapactivitytype, + p_startdatetime, + p_enddatetime, + p_comments, + p_idbytech, + p_sortbytech, + p_processed, + p_sitecond, + p_locationname, + p_recordstatus, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_trapcondition, + p_trapnights, + p_zone, + p_zone2, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_srid, + p_fieldtech, + p_gatewaysync, + p_loc_id, + p_voltage, + p_winddir, + p_windspeed, + p_avetemp, + p_raingauge, + p_lr, + p_field, + p_vectorsurvtrapdataid, + p_vectorsurvtraplocationid, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_lure, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_traplocation_versioned.sql b/db/fieldseeker-schema/insert/insert_traplocation_versioned.sql index bf5d4c0a..a155cd03 100644 --- a/db/fieldseeker-schema/insert/insert_traplocation_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_traplocation_versioned.sql @@ -1,96 +1,173 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.traplocation --- Only inserts a new version if data has changed -PREPARE insert_traplocation_versioned(bigint, varchar, varchar, fieldseeker.traplocation_traplocation_habitat_5c349680f5ff40b1aeca88c17993e8f3_enum, fieldseeker.traplocation_traplocation_priority_680fb011063b41d59f39271c959b857f_enum, fieldseeker.traplocation_traplocation_usetype_5e0eff9231fb404c98cc53c1d49a2193_enum, fieldseeker.traplocation_notinuit_f_enum, varchar, fieldseeker.traplocation_traplocation_accessdesc_154cbd10_4524_4e3a_8ca0_f099ec86556a_enum, varchar, varchar, timestamp, varchar, integer, uuid, varchar, timestamp, varchar, timestamp, smallint, integer, integer, integer, varchar, timestamp, varchar, timestamp, varchar, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.traplocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.traplocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.traplocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, externalid, nextactiondatescheduled, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, gatewaysync, route, set_dow, route_order, vectorsurvsiteid, creationdate, creator, editdate, editor, h3r7, h3r8, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.externalid IS NOT DISTINCT FROM $11 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $12 AND - lv.zone2 IS NOT DISTINCT FROM $13 AND - lv.locationnumber IS NOT DISTINCT FROM $14 AND - lv.globalid IS NOT DISTINCT FROM $15 AND - lv.created_user IS NOT DISTINCT FROM $16 AND - lv.created_date IS NOT DISTINCT FROM $17 AND - lv.last_edited_user IS NOT DISTINCT FROM $18 AND - lv.last_edited_date IS NOT DISTINCT FROM $19 AND - lv.gatewaysync IS NOT DISTINCT FROM $20 AND - lv.route IS NOT DISTINCT FROM $21 AND - lv.set_dow IS NOT DISTINCT FROM $22 AND - lv.route_order IS NOT DISTINCT FROM $23 AND - lv.vectorsurvsiteid IS NOT DISTINCT FROM $24 AND - lv.creationdate IS NOT DISTINCT FROM $25 AND - lv.creator IS NOT DISTINCT FROM $26 AND - lv.editdate IS NOT DISTINCT FROM $27 AND - lv.editor IS NOT DISTINCT FROM $28 AND - lv.h3r7 IS NOT DISTINCT FROM $29 AND - lv.h3r8 IS NOT DISTINCT FROM $30 - ) -RETURNING *; - --- Example usage: EXECUTE insert_traplocation_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NAME (varchar) --- $3: ZONE (varchar) --- $4: HABITAT (fieldseeker.traplocation_traplocation_habitat_5c349680f5ff40b1aeca88c17993e8f3_enum) --- $5: PRIORITY (fieldseeker.traplocation_traplocation_priority_680fb011063b41d59f39271c959b857f_enum) --- $6: USETYPE (fieldseeker.traplocation_traplocation_usetype_5e0eff9231fb404c98cc53c1d49a2193_enum) --- $7: ACTIVE (fieldseeker.traplocation_notinuit_f_enum) --- $8: DESCRIPTION (varchar) --- $9: ACCESSDESC (fieldseeker.traplocation_traplocation_accessdesc_154cbd10_4524_4e3a_8ca0_f099ec86556a_enum) --- $10: COMMENTS (varchar) --- $11: EXTERNALID (varchar) --- $12: NEXTACTIONDATESCHEDULED (timestamp) --- $13: ZONE2 (varchar) --- $14: LOCATIONNUMBER (integer) --- $15: GlobalID (uuid) --- $16: created_user (varchar) --- $17: created_date (timestamp) --- $18: last_edited_user (varchar) --- $19: last_edited_date (timestamp) --- $20: GATEWAYSYNC (smallint) --- $21: route (integer) --- $22: set_dow (integer) --- $23: route_order (integer) --- $24: VECTORSURVSITEID (varchar) --- $25: CreationDate (timestamp) --- $26: Creator (varchar) --- $27: EditDate (timestamp) --- $28: Editor (varchar) --- $29: h3r7 (varchar) --- $30: h3r8 (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_traplocation( + p_objectid bigint, + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_externalid varchar, + p_nextactiondatescheduled timestamp, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_gatewaysync smallint, + p_route integer, + p_set_dow integer, + p_route_order integer, + p_vectorsurvsiteid varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_h3r7 varchar, + p_h3r8 varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.traplocation lv + WHERE lv.objectid = p_objectid + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.route IS NOT DISTINCT FROM p_route + AND lv.set_dow IS NOT DISTINCT FROM p_set_dow + AND lv.route_order IS NOT DISTINCT FROM p_route_order + AND lv.vectorsurvsiteid IS NOT DISTINCT FROM p_vectorsurvsiteid + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.h3r7 IS NOT DISTINCT FROM p_h3r7 + AND lv.h3r8 IS NOT DISTINCT FROM p_h3r8 + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.traplocation + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.traplocation + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.traplocation ( + objectid, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + externalid, + nextactiondatescheduled, + zone2, + locationnumber, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + gatewaysync, + route, + set_dow, + route_order, + vectorsurvsiteid, + creationdate, + creator, + editdate, + editor, + h3r7, + h3r8, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_externalid, + p_nextactiondatescheduled, + p_zone2, + p_locationnumber, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_gatewaysync, + p_route, + p_set_dow, + p_route_order, + p_vectorsurvsiteid, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_h3r7, + p_h3r8, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_treatment_versioned.sql b/db/fieldseeker-schema/insert/insert_treatment_versioned.sql index eae54d21..7cb52407 100644 --- a/db/fieldseeker-schema/insert/insert_treatment_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_treatment_versioned.sql @@ -1,144 +1,269 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.treatment --- Only inserts a new version if data has changed -PREPARE insert_treatment_versioned(bigint, fieldseeker.treatment_mosquitoactivity_enum, double precision, fieldseeker.treatment_mosquitoproductareaunit_enum, varchar, double precision, fieldseeker.treatment_mosquitoproductmeasureunit_enum, fieldseeker.treatment_treatment_method_d558ca3ccf43440c8160758253967621_enum, fieldseeker.treatment_treatment_equiptype_45694d79_ff21_42cc_be4f_a0d1def4fba0_enum, varchar, double precision, double precision, fieldseeker.treatment_notinuiwinddirection_enum, double precision, timestamp, timestamp, uuid, fieldseeker.treatment_notinuit_f_enum, varchar, timestamp, varchar, varchar, fieldseeker.treatment_notinuit_f_enum, smallint, varchar, double precision, smallint, smallint, smallint, uuid, double precision, double precision, varchar, uuid, uuid, uuid, uuid, uuid, uuid, uuid, varchar, uuid, double precision, fieldseeker.treatment_treatment_habitat_0afee7eb_f9ea_4707_8483_cccfe60f0d16_enum, double precision, varchar, fieldseeker.treatment_treatment_sitecond_f812e1f64dcb4dc9a75da9d00abe6169_enum, fieldseeker.treatment_treatment_sitecond_5a15bf36fa124280b961f31cd1a9b571_enum, double precision, timestamp, varchar, timestamp, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.treatment - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.treatment - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.treatment ( - objectid, activity, treatarea, areaunit, product, qty, qtyunit, method, equiptype, comments, avetemp, windspeed, winddir, raingauge, startdatetime, enddatetime, insp_id, reviewed, reviewedby, revieweddate, locationname, zone, warningoverride, recordstatus, zone2, treatacres, tirecount, cbcount, containercount, globalid, treatmentlength, treatmenthours, treatmentlengthunits, linelocid, pointlocid, polygonlocid, srid, sdid, barrierrouteid, ulvrouteid, fieldtech, ptaid, flowrate, habitat, treathectares, invloc, temp_sitecond, sitecond, totalcostprodcut, creationdate, creator, editdate, editor, targetspecies, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.activity IS NOT DISTINCT FROM $2 AND - lv.treatarea IS NOT DISTINCT FROM $3 AND - lv.areaunit IS NOT DISTINCT FROM $4 AND - lv.product IS NOT DISTINCT FROM $5 AND - lv.qty IS NOT DISTINCT FROM $6 AND - lv.qtyunit IS NOT DISTINCT FROM $7 AND - lv.method IS NOT DISTINCT FROM $8 AND - lv.equiptype IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.avetemp IS NOT DISTINCT FROM $11 AND - lv.windspeed IS NOT DISTINCT FROM $12 AND - lv.winddir IS NOT DISTINCT FROM $13 AND - lv.raingauge IS NOT DISTINCT FROM $14 AND - lv.startdatetime IS NOT DISTINCT FROM $15 AND - lv.enddatetime IS NOT DISTINCT FROM $16 AND - lv.insp_id IS NOT DISTINCT FROM $17 AND - lv.reviewed IS NOT DISTINCT FROM $18 AND - lv.reviewedby IS NOT DISTINCT FROM $19 AND - lv.revieweddate IS NOT DISTINCT FROM $20 AND - lv.locationname IS NOT DISTINCT FROM $21 AND - lv.zone IS NOT DISTINCT FROM $22 AND - lv.warningoverride IS NOT DISTINCT FROM $23 AND - lv.recordstatus IS NOT DISTINCT FROM $24 AND - lv.zone2 IS NOT DISTINCT FROM $25 AND - lv.treatacres IS NOT DISTINCT FROM $26 AND - lv.tirecount IS NOT DISTINCT FROM $27 AND - lv.cbcount IS NOT DISTINCT FROM $28 AND - lv.containercount IS NOT DISTINCT FROM $29 AND - lv.globalid IS NOT DISTINCT FROM $30 AND - lv.treatmentlength IS NOT DISTINCT FROM $31 AND - lv.treatmenthours IS NOT DISTINCT FROM $32 AND - lv.treatmentlengthunits IS NOT DISTINCT FROM $33 AND - lv.linelocid IS NOT DISTINCT FROM $34 AND - lv.pointlocid IS NOT DISTINCT FROM $35 AND - lv.polygonlocid IS NOT DISTINCT FROM $36 AND - lv.srid IS NOT DISTINCT FROM $37 AND - lv.sdid IS NOT DISTINCT FROM $38 AND - lv.barrierrouteid IS NOT DISTINCT FROM $39 AND - lv.ulvrouteid IS NOT DISTINCT FROM $40 AND - lv.fieldtech IS NOT DISTINCT FROM $41 AND - lv.ptaid IS NOT DISTINCT FROM $42 AND - lv.flowrate IS NOT DISTINCT FROM $43 AND - lv.habitat IS NOT DISTINCT FROM $44 AND - lv.treathectares IS NOT DISTINCT FROM $45 AND - lv.invloc IS NOT DISTINCT FROM $46 AND - lv.temp_sitecond IS NOT DISTINCT FROM $47 AND - lv.sitecond IS NOT DISTINCT FROM $48 AND - lv.totalcostprodcut IS NOT DISTINCT FROM $49 AND - lv.creationdate IS NOT DISTINCT FROM $50 AND - lv.creator IS NOT DISTINCT FROM $51 AND - lv.editdate IS NOT DISTINCT FROM $52 AND - lv.editor IS NOT DISTINCT FROM $53 AND - lv.targetspecies IS NOT DISTINCT FROM $54 - ) -RETURNING *; - --- Example usage: EXECUTE insert_treatment_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: ACTIVITY (fieldseeker.treatment_mosquitoactivity_enum) --- $3: TREATAREA (double precision) --- $4: AREAUNIT (fieldseeker.treatment_mosquitoproductareaunit_enum) --- $5: PRODUCT (varchar) --- $6: QTY (double precision) --- $7: QTYUNIT (fieldseeker.treatment_mosquitoproductmeasureunit_enum) --- $8: METHOD (fieldseeker.treatment_treatment_method_d558ca3ccf43440c8160758253967621_enum) --- $9: EQUIPTYPE (fieldseeker.treatment_treatment_equiptype_45694d79_ff21_42cc_be4f_a0d1def4fba0_enum) --- $10: COMMENTS (varchar) --- $11: AVETEMP (double precision) --- $12: WINDSPEED (double precision) --- $13: WINDDIR (fieldseeker.treatment_notinuiwinddirection_enum) --- $14: RAINGAUGE (double precision) --- $15: STARTDATETIME (timestamp) --- $16: ENDDATETIME (timestamp) --- $17: INSP_ID (uuid) --- $18: REVIEWED (fieldseeker.treatment_notinuit_f_enum) --- $19: REVIEWEDBY (varchar) --- $20: REVIEWEDDATE (timestamp) --- $21: LOCATIONNAME (varchar) --- $22: ZONE (varchar) --- $23: WARNINGOVERRIDE (fieldseeker.treatment_notinuit_f_enum) --- $24: RECORDSTATUS (smallint) --- $25: ZONE2 (varchar) --- $26: TREATACRES (double precision) --- $27: TIRECOUNT (smallint) --- $28: CBCOUNT (smallint) --- $29: CONTAINERCOUNT (smallint) --- $30: GlobalID (uuid) --- $31: TREATMENTLENGTH (double precision) --- $32: TREATMENTHOURS (double precision) --- $33: TREATMENTLENGTHUNITS (varchar) --- $34: LINELOCID (uuid) --- $35: POINTLOCID (uuid) --- $36: POLYGONLOCID (uuid) --- $37: SRID (uuid) --- $38: SDID (uuid) --- $39: BARRIERROUTEID (uuid) --- $40: ULVROUTEID (uuid) --- $41: FIELDTECH (varchar) --- $42: PTAID (uuid) --- $43: FLOWRATE (double precision) --- $44: HABITAT (fieldseeker.treatment_treatment_habitat_0afee7eb_f9ea_4707_8483_cccfe60f0d16_enum) --- $45: TREATHECTARES (double precision) --- $46: INVLOC (varchar) --- $47: temp_SITECOND (fieldseeker.treatment_treatment_sitecond_f812e1f64dcb4dc9a75da9d00abe6169_enum) --- $48: SITECOND (fieldseeker.treatment_treatment_sitecond_5a15bf36fa124280b961f31cd1a9b571_enum) --- $49: TotalCostProdcut (double precision) --- $50: CreationDate (timestamp) --- $51: Creator (varchar) --- $52: EditDate (timestamp) --- $53: Editor (varchar) --- $54: TARGETSPECIES (varchar) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_treatment( + p_objectid bigint, + + p_activity varchar, + p_treatarea double precision, + p_areaunit varchar, + p_product varchar, + p_qty double precision, + p_qtyunit varchar, + p_method varchar, + p_equiptype varchar, + p_comments varchar, + p_avetemp double precision, + p_windspeed double precision, + p_winddir varchar, + p_raingauge double precision, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_insp_id uuid, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_warningoverride smallint, + p_recordstatus smallint, + p_zone2 varchar, + p_treatacres double precision, + p_tirecount smallint, + p_cbcount smallint, + p_containercount smallint, + p_globalid uuid, + p_treatmentlength double precision, + p_treatmenthours double precision, + p_treatmentlengthunits varchar, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_srid uuid, + p_sdid uuid, + p_barrierrouteid uuid, + p_ulvrouteid uuid, + p_fieldtech varchar, + p_ptaid uuid, + p_flowrate double precision, + p_habitat varchar, + p_treathectares double precision, + p_invloc varchar, + p_temp_sitecond varchar, + p_sitecond varchar, + p_totalcostprodcut double precision, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_targetspecies varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.treatment lv + WHERE lv.objectid = p_objectid + + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.treatarea IS NOT DISTINCT FROM p_treatarea + AND lv.areaunit IS NOT DISTINCT FROM p_areaunit + AND lv.product IS NOT DISTINCT FROM p_product + AND lv.qty IS NOT DISTINCT FROM p_qty + AND lv.qtyunit IS NOT DISTINCT FROM p_qtyunit + AND lv.method IS NOT DISTINCT FROM p_method + AND lv.equiptype IS NOT DISTINCT FROM p_equiptype + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.insp_id IS NOT DISTINCT FROM p_insp_id + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.warningoverride IS NOT DISTINCT FROM p_warningoverride + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.treatacres IS NOT DISTINCT FROM p_treatacres + AND lv.tirecount IS NOT DISTINCT FROM p_tirecount + AND lv.cbcount IS NOT DISTINCT FROM p_cbcount + AND lv.containercount IS NOT DISTINCT FROM p_containercount + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.treatmentlength IS NOT DISTINCT FROM p_treatmentlength + AND lv.treatmenthours IS NOT DISTINCT FROM p_treatmenthours + AND lv.treatmentlengthunits IS NOT DISTINCT FROM p_treatmentlengthunits + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.sdid IS NOT DISTINCT FROM p_sdid + AND lv.barrierrouteid IS NOT DISTINCT FROM p_barrierrouteid + AND lv.ulvrouteid IS NOT DISTINCT FROM p_ulvrouteid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.ptaid IS NOT DISTINCT FROM p_ptaid + AND lv.flowrate IS NOT DISTINCT FROM p_flowrate + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.treathectares IS NOT DISTINCT FROM p_treathectares + AND lv.invloc IS NOT DISTINCT FROM p_invloc + AND lv.temp_sitecond IS NOT DISTINCT FROM p_temp_sitecond + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.totalcostprodcut IS NOT DISTINCT FROM p_totalcostprodcut + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.targetspecies IS NOT DISTINCT FROM p_targetspecies + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.treatment + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.treatment + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.treatment ( + objectid, + + activity, + treatarea, + areaunit, + product, + qty, + qtyunit, + method, + equiptype, + comments, + avetemp, + windspeed, + winddir, + raingauge, + startdatetime, + enddatetime, + insp_id, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + warningoverride, + recordstatus, + zone2, + treatacres, + tirecount, + cbcount, + containercount, + globalid, + treatmentlength, + treatmenthours, + treatmentlengthunits, + linelocid, + pointlocid, + polygonlocid, + srid, + sdid, + barrierrouteid, + ulvrouteid, + fieldtech, + ptaid, + flowrate, + habitat, + treathectares, + invloc, + temp_sitecond, + sitecond, + totalcostprodcut, + creationdate, + creator, + editdate, + editor, + targetspecies, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_activity, + p_treatarea, + p_areaunit, + p_product, + p_qty, + p_qtyunit, + p_method, + p_equiptype, + p_comments, + p_avetemp, + p_windspeed, + p_winddir, + p_raingauge, + p_startdatetime, + p_enddatetime, + p_insp_id, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_warningoverride, + p_recordstatus, + p_zone2, + p_treatacres, + p_tirecount, + p_cbcount, + p_containercount, + p_globalid, + p_treatmentlength, + p_treatmenthours, + p_treatmentlengthunits, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_srid, + p_sdid, + p_barrierrouteid, + p_ulvrouteid, + p_fieldtech, + p_ptaid, + p_flowrate, + p_habitat, + p_treathectares, + p_invloc, + p_temp_sitecond, + p_sitecond, + p_totalcostprodcut, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_targetspecies, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_treatmentarea_versioned.sql b/db/fieldseeker-schema/insert/insert_treatmentarea_versioned.sql index fae3dbdd..b734dd8d 100644 --- a/db/fieldseeker-schema/insert/insert_treatmentarea_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_treatmentarea_versioned.sql @@ -1,72 +1,125 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.treatmentarea --- Only inserts a new version if data has changed -PREPARE insert_treatmentarea_versioned(bigint, uuid, uuid, timestamp, varchar, uuid, varchar, timestamp, varchar, timestamp, smallint, varchar, timestamp, varchar, timestamp, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.treatmentarea - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.treatmentarea - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.treatmentarea ( - objectid, treat_id, session_id, treatdate, comments, globalid, created_user, created_date, last_edited_user, last_edited_date, notified, type, creationdate, creator, editdate, editor, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.treat_id IS NOT DISTINCT FROM $2 AND - lv.session_id IS NOT DISTINCT FROM $3 AND - lv.treatdate IS NOT DISTINCT FROM $4 AND - lv.comments IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.notified IS NOT DISTINCT FROM $11 AND - lv.type IS NOT DISTINCT FROM $12 AND - lv.creationdate IS NOT DISTINCT FROM $13 AND - lv.creator IS NOT DISTINCT FROM $14 AND - lv.editdate IS NOT DISTINCT FROM $15 AND - lv.editor IS NOT DISTINCT FROM $16 AND - lv.shape__area IS NOT DISTINCT FROM $17 AND - lv.shape__length IS NOT DISTINCT FROM $18 - ) -RETURNING *; - --- Example usage: EXECUTE insert_treatmentarea_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: TREAT_ID (uuid) --- $3: SESSION_ID (uuid) --- $4: TREATDATE (timestamp) --- $5: COMMENTS (varchar) --- $6: GlobalID (uuid) --- $7: created_user (varchar) --- $8: created_date (timestamp) --- $9: last_edited_user (varchar) --- $10: last_edited_date (timestamp) --- $11: Notified (smallint) --- $12: Type (varchar) --- $13: CreationDate (timestamp) --- $14: Creator (varchar) --- $15: EditDate (timestamp) --- $16: Editor (varchar) --- $17: Shape__Area (double precision) --- $18: Shape__Length (double precision) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_treatmentarea( + p_objectid bigint, + + p_treat_id uuid, + p_session_id uuid, + p_treatdate timestamp, + p_comments varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_notified smallint, + p_type varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.treatmentarea lv + WHERE lv.objectid = p_objectid + + AND lv.treat_id IS NOT DISTINCT FROM p_treat_id + AND lv.session_id IS NOT DISTINCT FROM p_session_id + AND lv.treatdate IS NOT DISTINCT FROM p_treatdate + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.notified IS NOT DISTINCT FROM p_notified + AND lv.type IS NOT DISTINCT FROM p_type + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.treatmentarea + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.treatmentarea + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.treatmentarea ( + objectid, + + treat_id, + session_id, + treatdate, + comments, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + notified, + type, + creationdate, + creator, + editdate, + editor, + shape__area, + shape__length, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_treat_id, + p_session_id, + p_treatdate, + p_comments, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_notified, + p_type, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_zones2_versioned.sql b/db/fieldseeker-schema/insert/insert_zones2_versioned.sql index 6b99e6fd..81537b68 100644 --- a/db/fieldseeker-schema/insert/insert_zones2_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_zones2_versioned.sql @@ -1,62 +1,105 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.zones2 --- Only inserts a new version if data has changed -PREPARE insert_zones2_versioned(bigint, varchar, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.zones2 - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.zones2 - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.zones2 ( - objectid, name, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.creationdate IS NOT DISTINCT FROM $8 AND - lv.creator IS NOT DISTINCT FROM $9 AND - lv.editdate IS NOT DISTINCT FROM $10 AND - lv.editor IS NOT DISTINCT FROM $11 AND - lv.shape__area IS NOT DISTINCT FROM $12 AND - lv.shape__length IS NOT DISTINCT FROM $13 - ) -RETURNING *; - --- Example usage: EXECUTE insert_zones2_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NAME (varchar) --- $3: GlobalID (uuid) --- $4: created_user (varchar) --- $5: created_date (timestamp) --- $6: last_edited_user (varchar) --- $7: last_edited_date (timestamp) --- $8: CreationDate (timestamp) --- $9: Creator (varchar) --- $10: EditDate (timestamp) --- $11: Editor (varchar) --- $12: Shape__Area (double precision) --- $13: Shape__Length (double precision) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_zones2( + p_objectid bigint, + + p_name varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.zones2 lv + WHERE lv.objectid = p_objectid + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.zones2 + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.zones2 + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.zones2 ( + objectid, + + name, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + shape__area, + shape__length, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_name, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/insert/insert_zones_versioned.sql b/db/fieldseeker-schema/insert/insert_zones_versioned.sql index 399ecd52..3e28eeb5 100644 --- a/db/fieldseeker-schema/insert/insert_zones_versioned.sql +++ b/db/fieldseeker-schema/insert/insert_zones_versioned.sql @@ -1,64 +1,109 @@ --- Prepared statement for conditional insert with versioning for fieldseeker.zones --- Only inserts a new version if data has changed -PREPARE insert_zones_versioned(bigint, varchar, uuid, varchar, timestamp, varchar, timestamp, integer, timestamp, varchar, timestamp, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.zones - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.zones - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.zones ( - objectid, name, globalid, created_user, created_date, last_edited_user, last_edited_date, active, creationdate, creator, editdate, editor, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.active IS NOT DISTINCT FROM $8 AND - lv.creationdate IS NOT DISTINCT FROM $9 AND - lv.creator IS NOT DISTINCT FROM $10 AND - lv.editdate IS NOT DISTINCT FROM $11 AND - lv.editor IS NOT DISTINCT FROM $12 AND - lv.shape__area IS NOT DISTINCT FROM $13 AND - lv.shape__length IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_zones_versioned(id, value1, value2, ...); - --- Parameters in order: --- $1: OBJECTID (bigint) --- $2: NAME (varchar) --- $3: GlobalID (uuid) --- $4: created_user (varchar) --- $5: created_date (timestamp) --- $6: last_edited_user (varchar) --- $7: last_edited_date (timestamp) --- $8: ACTIVE (integer) --- $9: CreationDate (timestamp) --- $10: Creator (varchar) --- $11: EditDate (timestamp) --- $12: Editor (varchar) --- $13: Shape__Area (double precision) --- $14: Shape__Length (double precision) +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_zones( + p_objectid bigint, + + p_name varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_active integer, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.zones lv + WHERE lv.objectid = p_objectid + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.zones + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.zones + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.zones ( + objectid, + + name, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + active, + creationdate, + creator, + editdate, + editor, + shape__area, + shape__length, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_name, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_active, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd diff --git a/db/fieldseeker-schema/inspectionsample.sql b/db/fieldseeker-schema/inspectionsample.sql deleted file mode 100644 index 7ed51040..00000000 --- a/db/fieldseeker-schema/inspectionsample.sql +++ /dev/null @@ -1,41 +0,0 @@ --- Table definition for fieldseeker.InspectionSample --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.inspectionsample_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TABLE fieldseeker.inspectionsample ( - objectid BIGSERIAL NOT NULL, - insp_id UUID, - sampleid VARCHAR(25), - processed fieldseeker.inspectionsample_notinuit_f_enum, - idbytech VARCHAR(25), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.inspectionsample.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.inspectionsample.sampleid IS 'Sample ID'; -COMMENT ON COLUMN fieldseeker.inspectionsample.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.inspectionsample.idbytech IS 'Tech Identifying Species in Lab'; - --- See insert/insert_inspectionsample_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/inspectionsampledetail.sql b/db/fieldseeker-schema/inspectionsampledetail.sql deleted file mode 100644 index 5e6590bf..00000000 --- a/db/fieldseeker-schema/inspectionsampledetail.sql +++ /dev/null @@ -1,78 +0,0 @@ --- Table definition for fieldseeker.InspectionSampleDetail --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.inspectionsampledetail_mosquitofieldspecies_enum AS ENUM ( - 'Aedes', - 'Culex' -); - -CREATE TYPE fieldseeker.inspectionsampledetail_mosquitodominantstage_enum AS ENUM ( - '1', - '2', - '3', - '4', - '1-2', - '3-4' -); - -CREATE TYPE fieldseeker.inspectionsampledetail_mosquitoadultactivity_enum AS ENUM ( - 'None', - 'Light', - 'Moderate', - 'Intense' -); - -CREATE TABLE fieldseeker.inspectionsampledetail ( - objectid BIGSERIAL NOT NULL, - inspsample_id UUID, - fieldspecies fieldseeker.inspectionsampledetail_mosquitofieldspecies_enum, - flarvcount SMALLINT, - fpupcount SMALLINT, - feggcount SMALLINT, - flstages VARCHAR(25), - fdomstage fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, - fadultact fieldseeker.inspectionsampledetail_mosquitoadultactivity_enum, - labspecies VARCHAR(50), - llarvcount SMALLINT, - lpupcount SMALLINT, - leggcount SMALLINT, - ldomstage fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, - comments VARCHAR(250), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - processed SMALLINT, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fieldspecies IS 'Field Species'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.flarvcount IS 'Field Larva Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fpupcount IS 'Field Pupa Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.feggcount IS 'Field Egg Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.flstages IS 'Field Larval Stages'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fdomstage IS 'Field Dominant Stage'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fadultact IS 'Field Adult Activity'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.labspecies IS 'Lab Species'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.llarvcount IS 'Lab Larva Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.lpupcount IS 'Lab Pupa Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.leggcount IS 'Lab Egg Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.ldomstage IS 'Lab Dominant Stage'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.comments IS 'Comments'; - --- See insert/insert_inspectionsampledetail_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/linelocation.sql b/db/fieldseeker-schema/linelocation.sql deleted file mode 100644 index 82b62a61..00000000 --- a/db/fieldseeker-schema/linelocation.sql +++ /dev/null @@ -1,198 +0,0 @@ --- Table definition for fieldseeker.LineLocation --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.linelocation_linelocation_habitat_fc51bdc4f1954df58206d69ce14182f3_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetland', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point' -); - -CREATE TYPE fieldseeker.linelocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.linelocation_linelocation_usetype_2aeca2e60d2f455c86fc34895dc80a02_enum AS ENUM ( - 'residential', - 'commercial', - 'industrial', - 'agricultural', - 'mixed_use', - 'public_domain', - 'natural', - 'municipal' -); - -CREATE TYPE fieldseeker.linelocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.linelocation_locationsymbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - -CREATE TYPE fieldseeker.linelocation_linelocation_waterorigin_84723d92_306a_46f4_8ef1_69b55a916008_enum AS ENUM ( - 'flood_irrigation', - 'furrow_irrigation', - 'drip_irrigation', - 'sprinkler_irrigation', - 'wastewater_irrigation', - 'irrigation_runoff', - 'rainwater_accumulation', - 'leak', - 'seepage', - 'stored_water', - 'wastewater_system', - 'permanent_natural_water', - 'temporary_natural_water', - 'recreational_or_ornamental_water', - 'water_conveyance' -); - -CREATE TABLE fieldseeker.linelocation ( - objectid BIGSERIAL NOT NULL, - name VARCHAR(25), - zone VARCHAR(25), - habitat fieldseeker.linelocation_linelocation_habitat_fc51bdc4f1954df58206d69ce14182f3_enum, - priority fieldseeker.linelocation_locationpriority_enum, - usetype fieldseeker.linelocation_linelocation_usetype_2aeca2e60d2f455c86fc34895dc80a02_enum, - active fieldseeker.linelocation_notinuit_f_enum, - description VARCHAR(250), - accessdesc VARCHAR(250), - comments VARCHAR(250), - symbology fieldseeker.linelocation_locationsymbology_enum, - externalid VARCHAR(50), - acres DOUBLE PRECISION, - nextactiondatescheduled TIMESTAMP, - larvinspectinterval SMALLINT, - length_ft DOUBLE PRECISION, - width_ft DOUBLE PRECISION, - zone2 VARCHAR(25), - locationnumber INTEGER, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - lastinspectdate TIMESTAMP, - lastinspectbreeding VARCHAR(25), - lastinspectavglarvae DOUBLE PRECISION, - lastinspectavgpupae DOUBLE PRECISION, - lastinspectlstages VARCHAR(25), - lastinspectactiontaken VARCHAR(50), - lastinspectfieldspecies VARCHAR(25), - lasttreatdate TIMESTAMP, - lasttreatproduct VARCHAR(25), - lasttreatqty DOUBLE PRECISION, - lasttreatqtyunit VARCHAR(10), - hectares DOUBLE PRECISION, - lastinspectactivity VARCHAR(25), - lasttreatactivity VARCHAR(25), - length_meters DOUBLE PRECISION, - width_meters DOUBLE PRECISION, - lastinspectconditions VARCHAR(250), - waterorigin fieldseeker.linelocation_linelocation_waterorigin_84723d92_306a_46f4_8ef1_69b55a916008_enum, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - jurisdiction VARCHAR(25), - shape__length DOUBLE PRECISION, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.linelocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.linelocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.linelocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.linelocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.linelocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.linelocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.linelocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.linelocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.linelocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.linelocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.linelocation.symbology IS 'Symbology'; -COMMENT ON COLUMN fieldseeker.linelocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.linelocation.acres IS 'Acres'; -COMMENT ON COLUMN fieldseeker.linelocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.linelocation.larvinspectinterval IS 'Larval Inspection Interval'; -COMMENT ON COLUMN fieldseeker.linelocation.length_ft IS 'Length'; -COMMENT ON COLUMN fieldseeker.linelocation.width_ft IS 'Width'; -COMMENT ON COLUMN fieldseeker.linelocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectbreeding IS 'Last Inspection Breeding'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectavglarvae IS 'Last Inspection Average Larvae'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectavgpupae IS 'Last Inspection Average Pupae'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectlstages IS 'Last Inspection Larval Stages'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectactiontaken IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectfieldspecies IS 'Last Inspection Field Species'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.linelocation.hectares IS 'Hectares'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectactivity IS 'Last Inspection Activity'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.linelocation.length_meters IS 'Length Meters'; -COMMENT ON COLUMN fieldseeker.linelocation.width_meters IS 'Width Meters'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.linelocation.waterorigin IS 'Water Origin'; -COMMENT ON COLUMN fieldseeker.linelocation.jurisdiction IS 'Jurisdiction'; - --- Field active has default value: 1 - --- Field symbology has default value: 'NONE' - --- See insert/insert_linelocation_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/locationtracking.sql b/db/fieldseeker-schema/locationtracking.sql deleted file mode 100644 index e243dd54..00000000 --- a/db/fieldseeker-schema/locationtracking.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Table definition for fieldseeker.LocationTracking --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TABLE fieldseeker.locationtracking ( - objectid BIGSERIAL NOT NULL, - accuracy DOUBLE PRECISION, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - globalid UUID, - fieldtech VARCHAR(25), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.locationtracking.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.locationtracking.accuracy IS 'Accuracy(m)'; -COMMENT ON COLUMN fieldseeker.locationtracking.fieldtech IS 'Field Tech'; - --- See insert/insert_locationtracking_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/mosquitoinspection.sql b/db/fieldseeker-schema/mosquitoinspection.sql deleted file mode 100644 index c6e1c780..00000000 --- a/db/fieldseeker-schema/mosquitoinspection.sql +++ /dev/null @@ -1,224 +0,0 @@ --- Table definition for fieldseeker.MosquitoInspection --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_adminaction_b74ae1bb_c98b_40f6_8cfa_40e4fd16c270_enum AS ENUM ( - 'yes', - 'no' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoactivity_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TYPE fieldseeker.mosquitoinspection_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitofieldspecies_enum AS ENUM ( - 'Aedes', - 'Culex' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitobreeding_enum AS ENUM ( - 'None', - 'Light', - 'Moderate', - 'Intense' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoadultactivity_enum AS ENUM ( - 'None', - 'Light', - 'Moderate', - 'Intense' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_domstage_b7a6c36bccde49a292020de4812cf5ae_enum AS ENUM ( - '1', - '2', - '3', - '4', - '5', - '1-2', - '2-3', - '3-4' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_actiontaken_252243d69b0b44ddbdc229c04ec3a8d5_enum AS ENUM ( - 'Treatment', - 'Mechanical or Biological Treatment', - 'Resident Schedule Request', - 'Administrative' -); - -CREATE TYPE fieldseeker.mosquitoinspection_notinuiwinddirection_enum AS ENUM ( - 'N', - 'NE', - 'E', - 'SE', - 'S', - 'SW', - 'W', - 'NW' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_sitecond_db7350bc_81e5_401e_858f_cd3e5e5d8a34_enum AS ENUM ( - 'Dry', - 'Flowing', - 'Maintained', - 'Unmaintained', - 'High Organic', - 'Unknown', - 'Stagnant', - 'Needs Monitoring', - 'Drying Out', - 'Appears Vacant', - 'Entry Denied', - 'Pool Removed', - 'False Pool' -); - -CREATE TABLE fieldseeker.mosquitoinspection ( - objectid BIGSERIAL NOT NULL, - numdips SMALLINT, - activity fieldseeker.mosquitoinspection_mosquitoactivity_enum, - breeding fieldseeker.mosquitoinspection_mosquitobreeding_enum, - totlarvae SMALLINT, - totpupae SMALLINT, - eggs SMALLINT, - posdips SMALLINT, - adultact fieldseeker.mosquitoinspection_mosquitoadultactivity_enum, - lstages VARCHAR(25), - domstage fieldseeker.mosquitoinspection_mosquitoinspection_domstage_b7a6c36bccde49a292020de4812cf5ae_enum, - actiontaken fieldseeker.mosquitoinspection_mosquitoinspection_actiontaken_252243d69b0b44ddbdc229c04ec3a8d5_enum, - comments VARCHAR(250), - avetemp DOUBLE PRECISION, - windspeed DOUBLE PRECISION, - raingauge DOUBLE PRECISION, - startdatetime TIMESTAMP, - enddatetime TIMESTAMP, - winddir fieldseeker.mosquitoinspection_notinuiwinddirection_enum, - avglarvae DOUBLE PRECISION, - avgpupae DOUBLE PRECISION, - reviewed fieldseeker.mosquitoinspection_notinuit_f_enum, - reviewedby VARCHAR(25), - revieweddate TIMESTAMP, - locationname VARCHAR(25), - zone VARCHAR(25), - recordstatus SMALLINT, - zone2 VARCHAR(25), - personalcontact fieldseeker.mosquitoinspection_notinuit_f_enum, - tirecount SMALLINT, - cbcount SMALLINT, - containercount SMALLINT, - fieldspecies fieldseeker.mosquitoinspection_mosquitofieldspecies_enum, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - linelocid UUID, - pointlocid UUID, - polygonlocid UUID, - srid UUID, - fieldtech VARCHAR(25), - larvaepresent fieldseeker.mosquitoinspection_notinuit_f_enum, - pupaepresent fieldseeker.mosquitoinspection_notinuit_f_enum, - sdid UUID, - sitecond fieldseeker.mosquitoinspection_mosquitoinspection_sitecond_db7350bc_81e5_401e_858f_cd3e5e5d8a34_enum, - positivecontainercount SMALLINT, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - jurisdiction VARCHAR(25), - visualmonitoring fieldseeker.mosquitoinspection_notinuit_f_enum, - vmcomments VARCHAR(250), - adminaction fieldseeker.mosquitoinspection_mosquitoinspection_adminaction_b74ae1bb_c98b_40f6_8cfa_40e4fd16c270_enum, - ptaid UUID, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.mosquitoinspection.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.mosquitoinspection.numdips IS '# Dips'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.breeding IS 'Breeding'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.totlarvae IS 'Total Larvae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.totpupae IS 'Total Pupae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.eggs IS 'Eggs'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.posdips IS 'Positive Dips'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.adultact IS 'Adult Activity'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.lstages IS 'Larval Stages'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.domstage IS 'Dominant Stage'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.actiontaken IS 'Action'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.avglarvae IS 'Average Larvae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.avgpupae IS 'Average Pupae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.personalcontact IS 'Personal Contact'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.tirecount IS 'Tire Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.cbcount IS 'Catch Basin Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.containercount IS 'Container Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.fieldspecies IS 'Field Species'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.larvaepresent IS 'Larvae Present'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.pupaepresent IS 'Pupae Present'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.sdid IS 'Storm Drain ID'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.sitecond IS 'Conditions'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.positivecontainercount IS 'Positive Container Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.jurisdiction IS 'Jurisdiction'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.visualmonitoring IS 'Visual Monitoring'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.vmcomments IS 'VM Comments'; - --- Field adminaction has default value: 'no' - --- See insert/insert_mosquitoinspection_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/pointlocation.sql b/db/fieldseeker-schema/pointlocation.sql deleted file mode 100644 index aac7b03e..00000000 --- a/db/fieldseeker-schema/pointlocation.sql +++ /dev/null @@ -1,236 +0,0 @@ --- Table definition for fieldseeker.PointLocation --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.pointlocation_pointlocation_deactivate_reason_dd303085_b33c_4894_8c47_fa847dd9d7c5_enum AS ENUM ( - 'Source Removed', - 'Pool Maintained', - 'Source Screened', - 'Crop Change', - 'Low or No Mosquito Activity', - 'Consistent Fish Presence' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_habitat_b4d8135a_4979_49c8_8bb3_67ec7230e661_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetlands', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point' -); - -CREATE TYPE fieldseeker.pointlocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_usetype_58d62d18ef4f47fc8cb9874df867f89e_enum AS ENUM ( - 'residential', - 'commercial', - 'agricultural', - 'industrial', - 'mixed_use', - 'public_domain', - 'natural', - 'municipal' -); - -CREATE TYPE fieldseeker.pointlocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.pointlocation_locationsymbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_waterorigin_197b22bf_f3eb_4dad_8899_986460f6ea97_enum AS ENUM ( - 'flood_irrigation', - 'furrow_irrigation', - 'drip_irrigation', - 'sprinkler_irrigation', - 'wastewater_irrigation', - 'irrigation_runoff', - 'stormwater_or_municipal_runoff', - 'industrial_runoff', - 'rainwater_accumulation', - 'leak', - 'seepage', - 'stored_water', - 'wastewater_system', - 'permanent_natural_water', - 'temporary_natural_water', - 'recreational_or_orenamental_water', - 'water_conveyance' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_assignedtech_9393a162_2474_429d_85be_daa44e4c091f_enum AS ENUM ( - 'Bryan Feguson', - 'Rick Alverez', - 'Alysia Davis', - 'Bryan Ruiz', - 'Kory Wilson', - 'Adrian Sifuentes', - 'Marco Martinez', - 'Carlos Rodriguez', - 'Landon McGill', - 'Ted McGill', - 'Mario Sanchez', - 'Jorge Perez', - 'Arturo Garcia-Trejo', - 'Lisa Salgado', - 'Lawrence Guzman', - 'Tricia Snowden', - 'Ryan Spratt', - 'Andrea Troupin', - 'Mark Nakata', - 'Pablo Ortega', - 'Benjamin Sperry', - 'Fatima Hidalgo', - 'Zackery Barragan', - 'Yajaira Godinez', - 'Jake Maldonado', - 'Rafael Ramirez', - 'Carlos Palacios', - 'Aaron Fredrick', - 'Josh Malone', - 'Alec Caposella', - 'Laura Ramos' -); - -CREATE TABLE fieldseeker.pointlocation ( - objectid BIGSERIAL NOT NULL, - name VARCHAR(25), - zone VARCHAR(25), - habitat fieldseeker.pointlocation_pointlocation_habitat_b4d8135a_4979_49c8_8bb3_67ec7230e661_enum, - priority fieldseeker.pointlocation_locationpriority_enum, - usetype fieldseeker.pointlocation_pointlocation_usetype_58d62d18ef4f47fc8cb9874df867f89e_enum, - active fieldseeker.pointlocation_notinuit_f_enum, - description VARCHAR(250), - accessdesc VARCHAR(250), - comments VARCHAR(250), - symbology fieldseeker.pointlocation_locationsymbology_enum, - externalid VARCHAR(50), - nextactiondatescheduled TIMESTAMP, - larvinspectinterval SMALLINT, - zone2 VARCHAR(25), - locationnumber INTEGER, - globalid UUID, - stype VARCHAR(3), - lastinspectdate TIMESTAMP, - lastinspectbreeding VARCHAR(25), - lastinspectavglarvae DOUBLE PRECISION, - lastinspectavgpupae DOUBLE PRECISION, - lastinspectlstages VARCHAR(25), - lastinspectactiontaken VARCHAR(50), - lastinspectfieldspecies VARCHAR(25), - lasttreatdate TIMESTAMP, - lasttreatproduct VARCHAR(25), - lasttreatqty DOUBLE PRECISION, - lasttreatqtyunit VARCHAR(10), - lastinspectactivity VARCHAR(25), - lasttreatactivity VARCHAR(25), - lastinspectconditions VARCHAR(250), - waterorigin fieldseeker.pointlocation_pointlocation_waterorigin_197b22bf_f3eb_4dad_8899_986460f6ea97_enum, - x DOUBLE PRECISION, - y DOUBLE PRECISION, - assignedtech fieldseeker.pointlocation_pointlocation_assignedtech_9393a162_2474_429d_85be_daa44e4c091f_enum, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - jurisdiction VARCHAR(25), - deactivate_reason fieldseeker.pointlocation_pointlocation_deactivate_reason_dd303085_b33c_4894_8c47_fa847dd9d7c5_enum, - scalarpriority INTEGER, - sourcestatus VARCHAR(255), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.pointlocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.pointlocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.pointlocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.pointlocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.pointlocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.pointlocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.pointlocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.pointlocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.pointlocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.pointlocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.pointlocation.symbology IS 'Symbology'; -COMMENT ON COLUMN fieldseeker.pointlocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.pointlocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.pointlocation.larvinspectinterval IS 'Larval Inspection Interval'; -COMMENT ON COLUMN fieldseeker.pointlocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.pointlocation.stype IS 'SourceType'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectbreeding IS 'Last Inspection Breeding'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectavglarvae IS 'Last Inspection Average Larvae'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectavgpupae IS 'Last Inspection Average Pupae'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectlstages IS 'Last Inspection Larval Stages'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectactiontaken IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectfieldspecies IS 'Last Inspection Field Species'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectactivity IS 'Last Inspection Activity'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.pointlocation.waterorigin IS 'Water Origin'; -COMMENT ON COLUMN fieldseeker.pointlocation.assignedtech IS 'Assigned Tech'; -COMMENT ON COLUMN fieldseeker.pointlocation.jurisdiction IS 'Jurisdiction'; -COMMENT ON COLUMN fieldseeker.pointlocation.deactivate_reason IS 'Reason for Deactivation'; - --- Field active has default value: 1 - --- Field symbology has default value: 'NONE' - --- See insert/insert_pointlocation_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/polygonlocation.sql b/db/fieldseeker-schema/polygonlocation.sql deleted file mode 100644 index dac31d47..00000000 --- a/db/fieldseeker-schema/polygonlocation.sql +++ /dev/null @@ -1,186 +0,0 @@ --- Table definition for fieldseeker.PolygonLocation --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.polygonlocation_polygonlocation_usetype_e546154cb9544b9aa8e7b13e8e258b27_enum AS ENUM ( - 'residential', - 'commercial', - 'industrial', - 'agricultural', - 'mixed_use', - 'public_domain', - 'natural', - 'municipal' -); - -CREATE TYPE fieldseeker.polygonlocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.polygonlocation_locationsymbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - -CREATE TYPE fieldseeker.polygonlocation_polygonlocation_waterorigin_e9018e92_5f47_4ff9_8a7c_b818d848dc7a_enum AS ENUM ( - 'flood_irrigation', - 'furrow_irrigation', - 'drip_irritation', - 'sprinkler_irrigation', - 'wastewater_irrigation', - 'irrigation_runoff', - 'rainwater_accumulation', - 'leak', - 'seepage', - 'stored_water', - 'wastewater_system', - 'permanent_natural_water', - 'temporary_natural_water', - 'recreational_or_ornamental_water', - 'water_conveyance' -); - -CREATE TYPE fieldseeker.polygonlocation_polygonlocation_habitat_45e9dde79ac84d959df8b65ba7d5dafd_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetland', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point', - 'unknown' -); - -CREATE TYPE fieldseeker.polygonlocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TABLE fieldseeker.polygonlocation ( - objectid BIGSERIAL NOT NULL, - name VARCHAR(25), - zone VARCHAR(25), - habitat fieldseeker.polygonlocation_polygonlocation_habitat_45e9dde79ac84d959df8b65ba7d5dafd_enum, - priority fieldseeker.polygonlocation_locationpriority_enum, - usetype fieldseeker.polygonlocation_polygonlocation_usetype_e546154cb9544b9aa8e7b13e8e258b27_enum, - active fieldseeker.polygonlocation_notinuit_f_enum, - description VARCHAR(250), - accessdesc VARCHAR(250), - comments VARCHAR(250), - symbology fieldseeker.polygonlocation_locationsymbology_enum, - externalid VARCHAR(50), - acres DOUBLE PRECISION, - nextactiondatescheduled TIMESTAMP, - larvinspectinterval SMALLINT, - zone2 VARCHAR(25), - locationnumber INTEGER, - globalid UUID, - lastinspectdate TIMESTAMP, - lastinspectbreeding VARCHAR(25), - lastinspectavglarvae DOUBLE PRECISION, - lastinspectavgpupae DOUBLE PRECISION, - lastinspectlstages VARCHAR(25), - lastinspectactiontaken VARCHAR(50), - lastinspectfieldspecies VARCHAR(25), - lasttreatdate TIMESTAMP, - lasttreatproduct VARCHAR(25), - lasttreatqty DOUBLE PRECISION, - lasttreatqtyunit VARCHAR(10), - hectares DOUBLE PRECISION, - lastinspectactivity VARCHAR(25), - lasttreatactivity VARCHAR(25), - lastinspectconditions VARCHAR(250), - waterorigin fieldseeker.polygonlocation_polygonlocation_waterorigin_e9018e92_5f47_4ff9_8a7c_b818d848dc7a_enum, - filter VARCHAR(255), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - jurisdiction VARCHAR(25), - shape__area DOUBLE PRECISION, - shape__length DOUBLE PRECISION, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.polygonlocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.polygonlocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.polygonlocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.polygonlocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.polygonlocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.polygonlocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.polygonlocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.polygonlocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.polygonlocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.polygonlocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.polygonlocation.symbology IS 'Symbology'; -COMMENT ON COLUMN fieldseeker.polygonlocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.polygonlocation.acres IS 'Acres'; -COMMENT ON COLUMN fieldseeker.polygonlocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.polygonlocation.larvinspectinterval IS 'Larval Inspection Interval'; -COMMENT ON COLUMN fieldseeker.polygonlocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectbreeding IS 'Last Inspection Breeding'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectavglarvae IS 'Last Inspection Average Larvae'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectavgpupae IS 'Last Inspection Average Pupae'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectlstages IS 'Last Inspection Larval Stages'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectactiontaken IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectfieldspecies IS 'Last Inspection Field Species'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.polygonlocation.hectares IS 'Hectares'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectactivity IS 'Last Inspection Activity'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.polygonlocation.waterorigin IS 'Water Origin'; -COMMENT ON COLUMN fieldseeker.polygonlocation.jurisdiction IS 'Jurisdiction'; - --- Field active has default value: 1 - --- Field symbology has default value: 'NONE' - --- See insert/insert_polygonlocation_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/pool.sql b/db/fieldseeker-schema/pool.sql deleted file mode 100644 index 9e6503ee..00000000 --- a/db/fieldseeker-schema/pool.sql +++ /dev/null @@ -1,93 +0,0 @@ --- Table definition for fieldseeker.Pool --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.pool_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.pool_pool_testmethod_670efbfba86d41ba8e2d3cab5d749e7f_enum AS ENUM ( - 'RT-PCR' -); - -CREATE TYPE fieldseeker.pool_pool_diseasetested_0f02232949c04c7e8de820b9b515ed97_enum AS ENUM ( - 'WNV', - 'SLEV', - 'WEEV', - 'DENV', - 'ZIKV', - 'CHIKV' -); - -CREATE TYPE fieldseeker.pool_pool_diseasepos_6889f8dd00074874aa726907e78497fa_enum AS ENUM ( - 'WNV', - 'SLEV', - 'WEEV', - 'DENV', - 'ZIKV', - 'CHIKV', - 'WNV/SLEV' -); - -CREATE TYPE fieldseeker.pool_mosquitolabname_enum AS ENUM ( - 'Internal Lab', - 'State Lab' -); - -CREATE TABLE fieldseeker.pool ( - objectid BIGSERIAL NOT NULL, - trapdata_id UUID, - datesent TIMESTAMP, - survtech VARCHAR(25), - datetested TIMESTAMP, - testtech VARCHAR(25), - comments VARCHAR(250), - sampleid VARCHAR(50), - processed fieldseeker.pool_notinuit_f_enum, - lab_id UUID, - testmethod fieldseeker.pool_pool_testmethod_670efbfba86d41ba8e2d3cab5d749e7f_enum, - diseasetested fieldseeker.pool_pool_diseasetested_0f02232949c04c7e8de820b9b515ed97_enum, - diseasepos fieldseeker.pool_pool_diseasepos_6889f8dd00074874aa726907e78497fa_enum, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - lab fieldseeker.pool_mosquitolabname_enum, - poolyear SMALLINT, - gatewaysync SMALLINT, - vectorsurvcollectionid VARCHAR(50), - vectorsurvpoolid VARCHAR(50), - vectorsurvtrapdataid VARCHAR(50), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.pool.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.pool.trapdata_id IS 'Trap Data ID'; -COMMENT ON COLUMN fieldseeker.pool.datesent IS 'Date Sent'; -COMMENT ON COLUMN fieldseeker.pool.survtech IS 'Survey Tech'; -COMMENT ON COLUMN fieldseeker.pool.datetested IS 'Date Tested'; -COMMENT ON COLUMN fieldseeker.pool.testtech IS 'Test Tech'; -COMMENT ON COLUMN fieldseeker.pool.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.pool.sampleid IS 'Sample ID'; -COMMENT ON COLUMN fieldseeker.pool.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.pool.testmethod IS 'Test Methods'; -COMMENT ON COLUMN fieldseeker.pool.diseasetested IS 'Diseases Tested'; -COMMENT ON COLUMN fieldseeker.pool.diseasepos IS 'Diseases Positive'; -COMMENT ON COLUMN fieldseeker.pool.poolyear IS 'Pool Year'; -COMMENT ON COLUMN fieldseeker.pool.gatewaysync IS 'Gateway Sync'; - --- See insert/insert_pool_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/pooldetail.sql b/db/fieldseeker-schema/pooldetail.sql deleted file mode 100644 index 5662d44a..00000000 --- a/db/fieldseeker-schema/pooldetail.sql +++ /dev/null @@ -1,37 +0,0 @@ --- Table definition for fieldseeker.PoolDetail --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TABLE fieldseeker.pooldetail ( - objectid BIGSERIAL NOT NULL, - trapdata_id UUID, - pool_id UUID, - species VARCHAR(50), - females SMALLINT, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.pooldetail.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.pooldetail.trapdata_id IS 'Trap Data ID'; -COMMENT ON COLUMN fieldseeker.pooldetail.pool_id IS 'Pool ID'; -COMMENT ON COLUMN fieldseeker.pooldetail.species IS 'Species'; -COMMENT ON COLUMN fieldseeker.pooldetail.females IS 'Females'; - --- See insert/insert_pooldetail_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/proposedtreatmentarea.sql b/db/fieldseeker-schema/proposedtreatmentarea.sql deleted file mode 100644 index 44d65b55..00000000 --- a/db/fieldseeker-schema/proposedtreatmentarea.sql +++ /dev/null @@ -1,99 +0,0 @@ --- Table definition for fieldseeker.ProposedTreatmentArea --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.proposedtreatmentarea_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.proposedtreatmentarea_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.proposedtreatmentarea_mosquitotreatmentmethod_enum AS ENUM ( - 'Argo', - 'ATV', - 'Backpack', - 'Drone', - 'Manual', - 'Truck', - 'ULV', - 'Enhanced_Surveillance' -); - -CREATE TABLE fieldseeker.proposedtreatmentarea ( - objectid BIGSERIAL NOT NULL, - method fieldseeker.proposedtreatmentarea_mosquitotreatmentmethod_enum, - comments VARCHAR(250), - zone VARCHAR(25), - reviewed fieldseeker.proposedtreatmentarea_notinuit_f_enum, - reviewedby VARCHAR(25), - revieweddate TIMESTAMP, - zone2 VARCHAR(25), - completeddate TIMESTAMP, - completedby VARCHAR(25), - completed fieldseeker.proposedtreatmentarea_notinuit_f_enum, - issprayroute fieldseeker.proposedtreatmentarea_notinuit_f_enum, - name VARCHAR(25), - acres DOUBLE PRECISION, - globalid UUID, - exported fieldseeker.proposedtreatmentarea_notinuit_f_enum, - targetproduct VARCHAR(25), - targetapprate DOUBLE PRECISION, - hectares DOUBLE PRECISION, - lasttreatactivity VARCHAR(25), - lasttreatdate TIMESTAMP, - lasttreatproduct VARCHAR(25), - lasttreatqty DOUBLE PRECISION, - lasttreatqtyunit VARCHAR(10), - priority fieldseeker.proposedtreatmentarea_locationpriority_enum, - duedate TIMESTAMP, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - targetspecies VARCHAR(250), - shape__area DOUBLE PRECISION, - shape__length DOUBLE PRECISION, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.method IS 'Method'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completeddate IS 'Completed Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completedby IS 'Completed By'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completed IS 'Completed'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.issprayroute IS 'Is Spray Route'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.acres IS 'Acres'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetproduct IS 'Target Product'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetapprate IS 'Target App Rate'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.hectares IS 'Hectares'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.duedate IS 'Due Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetspecies IS 'Target Species'; - --- See insert/insert_proposedtreatmentarea_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/qamosquitoinspection.sql b/db/fieldseeker-schema/qamosquitoinspection.sql deleted file mode 100644 index 4cb7f60a..00000000 --- a/db/fieldseeker-schema/qamosquitoinspection.sql +++ /dev/null @@ -1,254 +0,0 @@ --- Table definition for fieldseeker.QAMosquitoInspection --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.qamosquitoinspection_mosquitoaction_enum AS ENUM ( - 'Treatment', - 'Covered container', - 'Cleared debris', - 'Maintenance' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qasitetype_enum AS ENUM ( - 'Detention Pond', - 'Ditch', - 'Low Area', - 'Mangrove Edge', - 'Pond', - 'Pond Edge', - 'Swale' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qabreedingpotential_enum AS ENUM ( - 'High', - 'Low', - 'Medium', - 'Rare' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qamosquitohabitat_enum AS ENUM ( - 'Depressions', - 'Detritus present', - 'Fast', - 'Few predators', - 'Fluctuating levels', - 'H20<6"', - 'Low wave potential', - 'No fish', - 'Shallow edges', - 'Still water edges', - 'Still water whole', - 'Veg. on edges' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qaaquaticorganisms_enum AS ENUM ( - 'fish', - 'scuds', - 'snails' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qasoilcondition_enum AS ENUM ( - 'Cracked', - 'Dry', - 'Inundated', - 'Saturated', - 'Surface Moist' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawaterduration_enum AS ENUM ( - '~month', - '~week', - '<1 week', - 'month', - '>week' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawaterconditions_enum AS ENUM ( - '"rust" material', - 'Clear', - 'Cloudy/fines', - 'Floating debris', - 'Submerged/decom. debris' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qalarvaereason_enum AS ENUM ( - 'Missed Area', - 'New Site', - 'Not Visited', - 'Rate Low', - 'Treated Recently', - 'Unknown', - 'Wrong Product' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qavegetation_enum AS ENUM ( - 'Algae', - 'Cattails', - 'Duckweed', - 'Glasswort', - 'Grass on edge', - 'Mangrove', - 'Mosquito fern', - 'Muskgrass', - 'Myriophyllum', - 'Other', - 'Rotting vegetation', - 'Saltwort', - 'Sedges' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qasourcereduction_enum AS ENUM ( - '1 tractor < day', - 'adjust flood irrigation', - 'adjust turf irrigation', - 'clear outflow', - 'cut ditch', - 'hand grading', - 'laser leveling', - 'multiple loads soil', - 'none' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawatermovement_enum AS ENUM ( - 'Fast', - 'Medium', - 'None', - 'Slow', - 'Very Slow' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawatersource_enum AS ENUM ( - 'Irrigation', - 'Manually Controlled', - 'Percolation', - 'Rain Runoff', - 'Tidal', - 'Water Table' -); - -CREATE TABLE fieldseeker.qamosquitoinspection ( - objectid BIGSERIAL NOT NULL, - posdips SMALLINT, - actiontaken fieldseeker.qamosquitoinspection_mosquitoaction_enum, - comments VARCHAR(250), - avetemp DOUBLE PRECISION, - windspeed DOUBLE PRECISION, - raingauge DOUBLE PRECISION, - globalid UUID, - startdatetime TIMESTAMP, - enddatetime TIMESTAMP, - winddir VARCHAR(3), - reviewed fieldseeker.qamosquitoinspection_notinuit_f_enum, - reviewedby VARCHAR(25), - revieweddate TIMESTAMP, - locationname VARCHAR(25), - zone VARCHAR(25), - recordstatus SMALLINT, - zone2 VARCHAR(25), - lr SMALLINT, - negdips SMALLINT, - totalacres DOUBLE PRECISION, - acresbreeding DOUBLE PRECISION, - fish fieldseeker.qamosquitoinspection_notinuit_f_enum, - sitetype fieldseeker.qamosquitoinspection_qasitetype_enum, - breedingpotential fieldseeker.qamosquitoinspection_qabreedingpotential_enum, - movingwater fieldseeker.qamosquitoinspection_notinuit_f_enum, - nowaterever fieldseeker.qamosquitoinspection_notinuit_f_enum, - mosquitohabitat fieldseeker.qamosquitoinspection_qamosquitohabitat_enum, - habvalue1 SMALLINT, - habvalue1percent SMALLINT, - habvalue2 SMALLINT, - habvalue2percent SMALLINT, - potential SMALLINT, - larvaepresent fieldseeker.qamosquitoinspection_notinuit_f_enum, - larvaeinsidetreatedarea fieldseeker.qamosquitoinspection_notinuit_f_enum, - larvaeoutsidetreatedarea fieldseeker.qamosquitoinspection_notinuit_f_enum, - larvaereason fieldseeker.qamosquitoinspection_qalarvaereason_enum, - aquaticorganisms fieldseeker.qamosquitoinspection_qaaquaticorganisms_enum, - vegetation fieldseeker.qamosquitoinspection_qavegetation_enum, - sourcereduction fieldseeker.qamosquitoinspection_qasourcereduction_enum, - waterpresent fieldseeker.qamosquitoinspection_notinuit_f_enum, - watermovement1 fieldseeker.qamosquitoinspection_qawatermovement_enum, - watermovement1percent SMALLINT, - watermovement2 fieldseeker.qamosquitoinspection_qawatermovement_enum, - watermovement2percent SMALLINT, - soilconditions fieldseeker.qamosquitoinspection_qasoilcondition_enum, - waterduration fieldseeker.qamosquitoinspection_qawaterduration_enum, - watersource fieldseeker.qamosquitoinspection_qawatersource_enum, - waterconditions fieldseeker.qamosquitoinspection_qawaterconditions_enum, - adultactivity fieldseeker.qamosquitoinspection_notinuit_f_enum, - linelocid UUID, - pointlocid UUID, - polygonlocid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - fieldtech VARCHAR(25), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.posdips IS 'Positive Dips'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.actiontaken IS 'Action'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.lr IS 'Landing Rate'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.negdips IS 'Negative Dips'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.totalacres IS 'Total Acres'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.acresbreeding IS 'Acres Breeding'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.fish IS 'Fish Present?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.sitetype IS 'Site Type'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.breedingpotential IS 'Breeding Potential'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.movingwater IS 'Moving Water'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.nowaterever IS 'No Evidence of Water Ever'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.mosquitohabitat IS 'Mosquito Habitat Indicators'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue1 IS 'Habitat Value'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue1percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue2 IS 'Habitat Value'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue2percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.potential IS 'Potential'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaepresent IS 'Larvae Present'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaeinsidetreatedarea IS 'Larvae Inside Treated Area?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaeoutsidetreatedarea IS 'Larvae Outside Treated Area?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaereason IS 'Reason Larvae Present'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.aquaticorganisms IS 'Aquatic Organisms'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.vegetation IS 'Vegetation'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.sourcereduction IS 'Source Reduction'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterpresent IS 'Water Present?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement1 IS 'Water Movement'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement1percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement2 IS 'Water Movement'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement2percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.soilconditions IS 'Soil Conditions'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterduration IS 'How Long Water Present?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watersource IS 'Water Source'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterconditions IS 'Water Conditions'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.adultactivity IS 'Adult Activity'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.fieldtech IS 'Field Tech'; - --- See insert/insert_qamosquitoinspection_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/rodentlocation.sql b/db/fieldseeker-schema/rodentlocation.sql deleted file mode 100644 index 64f52b83..00000000 --- a/db/fieldseeker-schema/rodentlocation.sql +++ /dev/null @@ -1,94 +0,0 @@ --- Table definition for fieldseeker.RodentLocation --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.rodentlocation_locationusetype_1_enum AS ENUM ( - 'Residential', - 'Commercial', - 'Industrial', - 'Agricultural', - 'Mixed use' -); - -CREATE TYPE fieldseeker.rodentlocation_notinuit_f_1_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.rodentlocation_rodentlocation_symbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - -CREATE TYPE fieldseeker.rodentlocation_rodentlocationhabitat_enum AS ENUM ( - 'Commercial', - 'Industrial', - 'Residential', - 'Wood Pile' -); - -CREATE TYPE fieldseeker.rodentlocation_locationpriority_1_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TABLE fieldseeker.rodentlocation ( - objectid BIGSERIAL NOT NULL, - locationname VARCHAR(25), - zone VARCHAR(25), - zone2 VARCHAR(25), - habitat fieldseeker.rodentlocation_rodentlocationhabitat_enum, - priority fieldseeker.rodentlocation_locationpriority_1_enum, - usetype fieldseeker.rodentlocation_locationusetype_1_enum, - active fieldseeker.rodentlocation_notinuit_f_1_enum, - description VARCHAR(250), - accessdesc VARCHAR(250), - comments VARCHAR(250), - symbology fieldseeker.rodentlocation_rodentlocation_symbology_enum, - externalid VARCHAR(50), - nextactiondatescheduled TIMESTAMP, - locationnumber INTEGER, - lastinspectdate TIMESTAMP, - lastinspectspecies VARCHAR(25), - lastinspectaction VARCHAR(50), - lastinspectconditions VARCHAR(250), - lastinspectrodentevidence VARCHAR(250), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - jurisdiction VARCHAR(25), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.rodentlocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.rodentlocation.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.rodentlocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectspecies IS 'Last Inspection Species'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectaction IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectrodentevidence IS 'Last Inspection Rodent Evidence'; -COMMENT ON COLUMN fieldseeker.rodentlocation.jurisdiction IS 'Jurisdiction'; - --- Field active has default value: 1 - --- Field symbology has default value: 'NONE' - --- See insert/insert_rodentlocation_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/samplecollection.sql b/db/fieldseeker-schema/samplecollection.sql deleted file mode 100644 index b5557178..00000000 --- a/db/fieldseeker-schema/samplecollection.sql +++ /dev/null @@ -1,197 +0,0 @@ --- Table definition for fieldseeker.SampleCollection --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.samplecollection_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitosampletype_enum AS ENUM ( - 'Blood', - 'Tissue', - 'Specimen', - 'Carcass' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitosamplecondition_enum AS ENUM ( - 'Usable', - 'Unusable' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitosamplespecies_enum AS ENUM ( - 'Chicken', - 'Wild bird', - 'Horse', - 'Human' -); - -CREATE TYPE fieldseeker.samplecollection_notinuisex_enum AS ENUM ( - 'M', - 'F', - 'U' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitoactivity_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitolabname_enum AS ENUM ( - 'Internal Lab', - 'State Lab' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitositecondition_enum AS ENUM ( - 'Dry', - 'Clean', - 'Full', - 'Low' -); - -CREATE TYPE fieldseeker.samplecollection_notinuiwinddirection_enum AS ENUM ( - 'N', - 'NE', - 'E', - 'SE', - 'S', - 'SW', - 'W', - 'NW' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitotestmethod_enum AS ENUM ( - 'RAMP', - 'VecTest', - 'ELISA', - 'RT-PCR' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitodisease_enum AS ENUM ( - 'EEE', - 'WNV', - 'Dengue', - 'Zika' -); - -CREATE TABLE fieldseeker.samplecollection ( - objectid BIGSERIAL NOT NULL, - loc_id UUID, - startdatetime TIMESTAMP, - enddatetime TIMESTAMP, - sitecond fieldseeker.samplecollection_mosquitositecondition_enum, - sampleid VARCHAR(25), - survtech VARCHAR(25), - datesent TIMESTAMP, - datetested TIMESTAMP, - testtech VARCHAR(25), - comments VARCHAR(250), - processed fieldseeker.samplecollection_notinuit_f_enum, - sampletype fieldseeker.samplecollection_mosquitosampletype_enum, - samplecond fieldseeker.samplecollection_mosquitosamplecondition_enum, - species fieldseeker.samplecollection_mosquitosamplespecies_enum, - sex fieldseeker.samplecollection_notinuisex_enum, - avetemp DOUBLE PRECISION, - windspeed DOUBLE PRECISION, - winddir fieldseeker.samplecollection_notinuiwinddirection_enum, - raingauge DOUBLE PRECISION, - activity fieldseeker.samplecollection_mosquitoactivity_enum, - testmethod fieldseeker.samplecollection_mosquitotestmethod_enum, - diseasetested fieldseeker.samplecollection_mosquitodisease_enum, - diseasepos fieldseeker.samplecollection_mosquitodisease_enum, - reviewed fieldseeker.samplecollection_notinuit_f_enum, - reviewedby VARCHAR(25), - revieweddate TIMESTAMP, - locationname VARCHAR(25), - zone VARCHAR(25), - recordstatus SMALLINT, - zone2 VARCHAR(25), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - lab fieldseeker.samplecollection_mosquitolabname_enum, - fieldtech VARCHAR(25), - flockid UUID, - samplecount SMALLINT, - chickenid UUID, - gatewaysync SMALLINT, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.samplecollection.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.samplecollection.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.samplecollection.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.samplecollection.sitecond IS 'Conditions'; -COMMENT ON COLUMN fieldseeker.samplecollection.sampleid IS 'Sample ID'; -COMMENT ON COLUMN fieldseeker.samplecollection.survtech IS 'Surveillance Technician'; -COMMENT ON COLUMN fieldseeker.samplecollection.datesent IS 'Sent'; -COMMENT ON COLUMN fieldseeker.samplecollection.datetested IS 'Tested'; -COMMENT ON COLUMN fieldseeker.samplecollection.testtech IS 'Test Technician'; -COMMENT ON COLUMN fieldseeker.samplecollection.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.samplecollection.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.samplecollection.sampletype IS 'Sample Type'; -COMMENT ON COLUMN fieldseeker.samplecollection.samplecond IS 'Sample Condition'; -COMMENT ON COLUMN fieldseeker.samplecollection.species IS 'Species'; -COMMENT ON COLUMN fieldseeker.samplecollection.sex IS 'Sex'; -COMMENT ON COLUMN fieldseeker.samplecollection.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.samplecollection.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.samplecollection.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.samplecollection.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.samplecollection.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.samplecollection.testmethod IS 'Test Method'; -COMMENT ON COLUMN fieldseeker.samplecollection.diseasetested IS 'Disease Tested'; -COMMENT ON COLUMN fieldseeker.samplecollection.diseasepos IS 'Disease Positive'; -COMMENT ON COLUMN fieldseeker.samplecollection.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.samplecollection.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.samplecollection.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.samplecollection.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.samplecollection.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.samplecollection.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.samplecollection.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.samplecollection.lab IS 'Lab'; -COMMENT ON COLUMN fieldseeker.samplecollection.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.samplecollection.samplecount IS 'Sample Count'; -COMMENT ON COLUMN fieldseeker.samplecollection.chickenid IS 'ChickenID'; -COMMENT ON COLUMN fieldseeker.samplecollection.gatewaysync IS 'Gateway Sync'; - --- See insert/insert_samplecollection_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/samplelocation.sql b/db/fieldseeker-schema/samplelocation.sql deleted file mode 100644 index cf9e8a5d..00000000 --- a/db/fieldseeker-schema/samplelocation.sql +++ /dev/null @@ -1,93 +0,0 @@ --- Table definition for fieldseeker.SampleLocation --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.samplelocation_locationhabitattype_enum AS ENUM ( - 'Catch basin', - 'Creek', - 'Ditch', - 'Field/Pasture', - 'Pond', - 'Pond fish', - 'Pond marshy', - 'Pond ornamental', - 'Pond retention', - 'Pond sewage', - 'Pond woodland', - 'Tree hole', - 'Swimming pool', - 'Park', - 'Unknown' -); - -CREATE TYPE fieldseeker.samplelocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.samplelocation_samplelocationusetype_enum AS ENUM ( - 'Flock Site', - 'Dead Bird' -); - -CREATE TYPE fieldseeker.samplelocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TABLE fieldseeker.samplelocation ( - objectid BIGSERIAL NOT NULL, - name VARCHAR(25), - zone VARCHAR(25), - habitat fieldseeker.samplelocation_locationhabitattype_enum, - priority fieldseeker.samplelocation_locationpriority_enum, - usetype fieldseeker.samplelocation_samplelocationusetype_enum, - active fieldseeker.samplelocation_notinuit_f_enum, - description VARCHAR(250), - accessdesc VARCHAR(250), - comments VARCHAR(250), - externalid VARCHAR(50), - nextactiondatescheduled TIMESTAMP, - zone2 VARCHAR(25), - locationnumber INTEGER, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - gatewaysync SMALLINT, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.samplelocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.samplelocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.samplelocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.samplelocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.samplelocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.samplelocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.samplelocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.samplelocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.samplelocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.samplelocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.samplelocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.samplelocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.samplelocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.samplelocation.gatewaysync IS 'Gateway Sync'; - --- Field active has default value: 1 - --- See insert/insert_samplelocation_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/servicerequest.sql b/db/fieldseeker-schema/servicerequest.sql deleted file mode 100644 index 621724de..00000000 --- a/db/fieldseeker-schema/servicerequest.sql +++ /dev/null @@ -1,324 +0,0 @@ --- Table definition for fieldseeker.ServiceRequest --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.servicerequest_servicerequestnextaction_enum AS ENUM ( - 'Night spray', - 'Site visit' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_schedule_period_3f40c046_afd1_4abd_8bf4_389650d29a49_enum AS ENUM ( - 'AM', - 'PM' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestsource_enum AS ENUM ( - 'Phone', - 'Email', - 'Website', - 'Drop-in', - '2025_pools' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_supervisor_eba07b90_c885_4fe6_8080_7aa775403b9a_enum AS ENUM ( - 'Rick Alverez', - 'Bryan Ferguson', - 'Bryan Ruiz', - 'Andrea Troupin', - 'Conlin Reis' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestregion_enum AS ENUM ( - 'FL', - 'ID' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_spanish_aaa3dc66_9f9a_4527_8ecd_c9f76db33879_enum AS ENUM ( - '0', - '1' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequeststatus_enum AS ENUM ( - 'Assigned', - 'Closed', - 'FieldRectified', - 'Open', - 'Rejected', - 'Unverified', - 'Accepted' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestcontactpreferences_enum AS ENUM ( - 'None', - 'Call', - 'Email', - 'Text' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestrejectedreason_enum AS ENUM ( - 'Distance', - 'Workload' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_dog_2b95ec97_1286_4fcd_88f4_f0e31113f696_enum AS ENUM ( - '0', - '1', - '2', - '3' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestissues_enum AS ENUM ( - 'Beehive Related', - 'Unsanitary Accumulations', - 'Rooster or Noise', - 'Rats Attracted', - 'Odor', - 'Number of Animals Over Limit', - 'Location', - 'Violation', - 'Inadequate Enclosure', - 'Escaped Animal', - 'Illegal Animal' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'Follow up Visit', - 'HTC Response', - 'Disease Activity Response' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequesttarget_enum AS ENUM ( - 'mosquitofish', - 'neglected pool or spa', - 'standing water', - 'mosquito presence', - 'biting mosquitoes', - 'event', - 'fish', - 'mosquito', - 'source', - 'bird' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_assignedtech_71d0d685_868f_4b7a_87e2_3661a3ee67c5_enum AS ENUM ( - 'Alysia Davis', - 'Alejandra Gill', - 'Andrea Troupin', - 'Brenda Rodriguez', - 'Bryan Ferguson', - 'Bryan Ruiz', - 'Conlin Reis', - 'Carlos Rodriguez', - 'Erick Arriga', - 'Landon McGill', - 'Marco Martinez', - 'Mark Nakata', - 'Mario Sanchez', - 'Juan Pablo Ortega', - 'Ryan Spratt', - 'Ted McGill', - 'Benjamin Sperry', - 'Zachery Barragan', - 'Arturo Garcia-Trejo', - 'Jesus Jolano', - 'Yajaira Godinez', - 'Jake Maldonado', - 'Rafael Ramirez', - 'Lisa Salgado', - 'Kory Wilson', - 'Carlos Palacios', - 'Fatima Hidalgo', - 'Aaron Fredrick', - 'Josh Malone', - 'Jorge Perez', - 'Laura Romos' -); - -CREATE TYPE fieldseeker.servicerequest_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TABLE fieldseeker.servicerequest ( - objectid BIGSERIAL NOT NULL, - recdatetime TIMESTAMP, - source fieldseeker.servicerequest_servicerequestsource_enum, - entrytech VARCHAR(25), - priority fieldseeker.servicerequest_servicerequestpriority_enum, - supervisor fieldseeker.servicerequest_servicerequest_supervisor_eba07b90_c885_4fe6_8080_7aa775403b9a_enum, - assignedtech fieldseeker.servicerequest_servicerequest_assignedtech_71d0d685_868f_4b7a_87e2_3661a3ee67c5_enum, - status fieldseeker.servicerequest_servicerequeststatus_enum, - clranon fieldseeker.servicerequest_notinuit_f_enum, - clrfname VARCHAR(25), - clrphone1 VARCHAR(25), - clrphone2 VARCHAR(25), - clremail VARCHAR(50), - clrcompany VARCHAR(25), - clraddr1 VARCHAR(50), - clraddr2 VARCHAR(50), - clrcity VARCHAR(25), - clrstate fieldseeker.servicerequest_servicerequestregion_enum, - clrzip VARCHAR(25), - clrother VARCHAR(25), - clrcontpref fieldseeker.servicerequest_servicerequestcontactpreferences_enum, - reqcompany VARCHAR(25), - reqaddr1 VARCHAR(50), - reqaddr2 VARCHAR(50), - reqcity VARCHAR(25), - reqstate fieldseeker.servicerequest_servicerequestregion_enum, - reqzip VARCHAR(25), - reqcrossst VARCHAR(25), - reqsubdiv VARCHAR(25), - reqmapgrid VARCHAR(25), - reqpermission fieldseeker.servicerequest_notinuit_f_enum, - reqtarget fieldseeker.servicerequest_servicerequesttarget_enum, - reqdescr VARCHAR(1000), - reqnotesfortech VARCHAR(250), - reqnotesforcust VARCHAR(250), - reqfldnotes VARCHAR(250), - reqprogramactions VARCHAR(250), - datetimeclosed TIMESTAMP, - techclosed VARCHAR(25), - sr_number INTEGER, - reviewed fieldseeker.servicerequest_notinuit_f_enum, - reviewedby VARCHAR(25), - revieweddate TIMESTAMP, - accepted fieldseeker.servicerequest_notinuit_f_enum, - accepteddate TIMESTAMP, - rejectedby VARCHAR(25), - rejecteddate TIMESTAMP, - rejectedreason fieldseeker.servicerequest_servicerequestrejectedreason_enum, - duedate TIMESTAMP, - acceptedby VARCHAR(25), - comments VARCHAR(2500), - estcompletedate TIMESTAMP, - nextaction fieldseeker.servicerequest_servicerequestnextaction_enum, - recordstatus SMALLINT, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - firstresponsedate TIMESTAMP, - responsedaycount SMALLINT, - allowed VARCHAR(25), - xvalue VARCHAR(25), - yvalue VARCHAR(25), - validx VARCHAR(25), - validy VARCHAR(25), - externalid VARCHAR(25), - externalerror VARCHAR(500), - pointlocid UUID, - notified SMALLINT, - notifieddate TIMESTAMP, - scheduled SMALLINT, - scheduleddate TIMESTAMP, - dog fieldseeker.servicerequest_servicerequest_dog_2b95ec97_1286_4fcd_88f4_f0e31113f696_enum, - schedule_period fieldseeker.servicerequest_servicerequest_schedule_period_3f40c046_afd1_4abd_8bf4_389650d29a49_enum, - schedule_notes VARCHAR(256), - spanish fieldseeker.servicerequest_servicerequest_spanish_aaa3dc66_9f9a_4527_8ecd_c9f76db33879_enum, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - issuesreported fieldseeker.servicerequest_servicerequestissues_enum, - jurisdiction VARCHAR(25), - notificationtimestamp VARCHAR(250), - zone VARCHAR(50), - zone2 VARCHAR(50), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.servicerequest.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.servicerequest.recdatetime IS 'Received'; -COMMENT ON COLUMN fieldseeker.servicerequest.source IS 'Source'; -COMMENT ON COLUMN fieldseeker.servicerequest.entrytech IS 'Entered By'; -COMMENT ON COLUMN fieldseeker.servicerequest.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.servicerequest.supervisor IS 'Supervisor'; -COMMENT ON COLUMN fieldseeker.servicerequest.assignedtech IS 'Assigned To'; -COMMENT ON COLUMN fieldseeker.servicerequest.status IS 'Status'; -COMMENT ON COLUMN fieldseeker.servicerequest.clranon IS 'Anonymous Caller'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrfname IS 'Caller Name'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrphone1 IS 'Caller Phone'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrphone2 IS 'Caller Alternate Phone'; -COMMENT ON COLUMN fieldseeker.servicerequest.clremail IS 'Caller Email'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrcompany IS 'Caller Company'; -COMMENT ON COLUMN fieldseeker.servicerequest.clraddr1 IS 'Caller Address'; -COMMENT ON COLUMN fieldseeker.servicerequest.clraddr2 IS 'Caller Address 2'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrcity IS 'Caller City'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrstate IS 'Caller State'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrzip IS 'Caller ZIP'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrother IS 'Caller Other'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrcontpref IS 'Caller Contact Preference'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqcompany IS 'Request Company'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqaddr1 IS 'Request Address'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqaddr2 IS 'Request Address 2'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqcity IS 'Request City'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqstate IS 'Request State'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqzip IS 'Request ZIP'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqcrossst IS 'Request Cross Street'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqsubdiv IS 'Request Subdivision'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqmapgrid IS 'Request Map Grid'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqpermission IS 'Permission to Enter'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqtarget IS 'Request Target'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqdescr IS 'Request Description'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqnotesfortech IS 'Notes for Field Technician'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqnotesforcust IS 'Notes for Customer'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqfldnotes IS 'Request Field Notes'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqprogramactions IS 'Request Program Actions'; -COMMENT ON COLUMN fieldseeker.servicerequest.datetimeclosed IS 'Closed'; -COMMENT ON COLUMN fieldseeker.servicerequest.techclosed IS 'Closed By'; -COMMENT ON COLUMN fieldseeker.servicerequest.sr_number IS 'SR#'; -COMMENT ON COLUMN fieldseeker.servicerequest.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.servicerequest.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.servicerequest.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.accepted IS 'Accepted'; -COMMENT ON COLUMN fieldseeker.servicerequest.accepteddate IS 'Accepted Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.rejectedby IS 'Rejected By'; -COMMENT ON COLUMN fieldseeker.servicerequest.rejecteddate IS 'Rejected Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.rejectedreason IS 'Rejected Reason'; -COMMENT ON COLUMN fieldseeker.servicerequest.duedate IS 'Due Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.acceptedby IS 'Accepted By'; -COMMENT ON COLUMN fieldseeker.servicerequest.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.servicerequest.estcompletedate IS 'Estimated Completion Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.nextaction IS 'Next Action'; -COMMENT ON COLUMN fieldseeker.servicerequest.recordstatus IS 'Record Status'; -COMMENT ON COLUMN fieldseeker.servicerequest.firstresponsedate IS 'First Response Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.responsedaycount IS 'Response Day Count'; -COMMENT ON COLUMN fieldseeker.servicerequest.allowed IS 'Verify Correct Location'; -COMMENT ON COLUMN fieldseeker.servicerequest.xvalue IS 'Xvalue'; -COMMENT ON COLUMN fieldseeker.servicerequest.yvalue IS 'Yvalue'; -COMMENT ON COLUMN fieldseeker.servicerequest.validx IS 'ValidX'; -COMMENT ON COLUMN fieldseeker.servicerequest.validy IS 'ValidY'; -COMMENT ON COLUMN fieldseeker.servicerequest.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.servicerequest.externalerror IS 'External Error'; -COMMENT ON COLUMN fieldseeker.servicerequest.notified IS 'Notified'; -COMMENT ON COLUMN fieldseeker.servicerequest.notifieddate IS 'Notified Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.scheduled IS 'Scheduled'; -COMMENT ON COLUMN fieldseeker.servicerequest.scheduleddate IS 'Scheduled Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.dog IS 'Dog'; -COMMENT ON COLUMN fieldseeker.servicerequest.schedule_period IS 'Schedule Period'; -COMMENT ON COLUMN fieldseeker.servicerequest.schedule_notes IS 'Schedule Notes'; -COMMENT ON COLUMN fieldseeker.servicerequest.spanish IS 'Prefer speaking Spanish'; -COMMENT ON COLUMN fieldseeker.servicerequest.issuesreported IS 'Issues Reported'; -COMMENT ON COLUMN fieldseeker.servicerequest.jurisdiction IS 'Jurisdiction'; -COMMENT ON COLUMN fieldseeker.servicerequest.notificationtimestamp IS 'Notification Timestamp'; -COMMENT ON COLUMN fieldseeker.servicerequest.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.servicerequest.zone2 IS 'Zone2'; - --- Field dog has default value: 0 - --- Field spanish has default value: 0 - --- See insert/insert_servicerequest_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/speciesabundance.sql b/db/fieldseeker-schema/speciesabundance.sql deleted file mode 100644 index bada4217..00000000 --- a/db/fieldseeker-schema/speciesabundance.sql +++ /dev/null @@ -1,66 +0,0 @@ --- Table definition for fieldseeker.SpeciesAbundance --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.speciesabundance_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TABLE fieldseeker.speciesabundance ( - objectid BIGSERIAL NOT NULL, - trapdata_id UUID, - species VARCHAR(50), - males SMALLINT, - unknown SMALLINT, - bloodedfem SMALLINT, - gravidfem SMALLINT, - larvae SMALLINT, - poolstogen SMALLINT, - processed fieldseeker.speciesabundance_notinuit_f_enum, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - pupae SMALLINT, - eggs SMALLINT, - females INTEGER, - total INTEGER, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - yearweek INTEGER, - globalzscore DOUBLE PRECISION, - r7score DOUBLE PRECISION, - r8score DOUBLE PRECISION, - h3r7 VARCHAR(256), - h3r8 VARCHAR(256), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.speciesabundance.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.speciesabundance.trapdata_id IS 'Trap Data ID'; -COMMENT ON COLUMN fieldseeker.speciesabundance.species IS 'Species'; -COMMENT ON COLUMN fieldseeker.speciesabundance.males IS 'Males'; -COMMENT ON COLUMN fieldseeker.speciesabundance.unknown IS 'Unknown'; -COMMENT ON COLUMN fieldseeker.speciesabundance.bloodedfem IS 'Blooded Females'; -COMMENT ON COLUMN fieldseeker.speciesabundance.gravidfem IS 'Gravid Females'; -COMMENT ON COLUMN fieldseeker.speciesabundance.larvae IS 'Larvae'; -COMMENT ON COLUMN fieldseeker.speciesabundance.poolstogen IS 'Pools to Generate'; -COMMENT ON COLUMN fieldseeker.speciesabundance.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.speciesabundance.pupae IS 'Pupae'; -COMMENT ON COLUMN fieldseeker.speciesabundance.eggs IS 'Eggs'; -COMMENT ON COLUMN fieldseeker.speciesabundance.females IS 'Females'; -COMMENT ON COLUMN fieldseeker.speciesabundance.total IS 'Total Adults'; - --- See insert/insert_speciesabundance_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/stormdrain.sql b/db/fieldseeker-schema/stormdrain.sql deleted file mode 100644 index 70527317..00000000 --- a/db/fieldseeker-schema/stormdrain.sql +++ /dev/null @@ -1,48 +0,0 @@ --- Table definition for fieldseeker.StormDrain --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.stormdrain_stormdrainsymbology_enum AS ENUM ( - 'Dry', - 'Needs Treatment', - 'Treated' -); - -CREATE TABLE fieldseeker.stormdrain ( - objectid BIGSERIAL NOT NULL, - nexttreatmentdate TIMESTAMP, - lasttreatdate TIMESTAMP, - lastaction VARCHAR(25), - symbology fieldseeker.stormdrain_stormdrainsymbology_enum, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - laststatus VARCHAR(25), - zone VARCHAR(25), - zone2 VARCHAR(25), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - type VARCHAR(25), - jurisdiction VARCHAR(25), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.stormdrain.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.stormdrain.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.stormdrain.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.stormdrain.type IS 'Type'; -COMMENT ON COLUMN fieldseeker.stormdrain.jurisdiction IS 'Jurisdiction'; - --- See insert/insert_stormdrain_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/timecard.sql b/db/fieldseeker-schema/timecard.sql deleted file mode 100644 index 29f99b23..00000000 --- a/db/fieldseeker-schema/timecard.sql +++ /dev/null @@ -1,93 +0,0 @@ --- Table definition for fieldseeker.TimeCard --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.timecard_timecardequipmenttype_enum AS ENUM ( - 'Spreader', - 'ATV', - 'Truck' -); - -CREATE TYPE fieldseeker.timecard_timecard_activity_451e67260c084304a35457170dc13366_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TABLE fieldseeker.timecard ( - objectid BIGSERIAL NOT NULL, - activity fieldseeker.timecard_timecard_activity_451e67260c084304a35457170dc13366_enum, - startdatetime TIMESTAMP, - enddatetime TIMESTAMP, - comments VARCHAR(250), - externalid VARCHAR(25), - equiptype fieldseeker.timecard_timecardequipmenttype_enum, - locationname VARCHAR(25), - zone VARCHAR(25), - zone2 VARCHAR(25), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - linelocid UUID, - pointlocid UUID, - polygonlocid UUID, - lclocid UUID, - samplelocid UUID, - srid UUID, - traplocid UUID, - fieldtech VARCHAR(25), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - rodentlocid UUID, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.timecard.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.timecard.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.timecard.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.timecard.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.timecard.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.timecard.equiptype IS 'Equipment Type'; -COMMENT ON COLUMN fieldseeker.timecard.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.timecard.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.timecard.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.timecard.fieldtech IS 'Field Tech'; - --- See insert/insert_timecard_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/trapdata.sql b/db/fieldseeker-schema/trapdata.sql deleted file mode 100644 index f50ca43f..00000000 --- a/db/fieldseeker-schema/trapdata.sql +++ /dev/null @@ -1,131 +0,0 @@ --- Table definition for fieldseeker.TrapData --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.trapdata_mosquitotraptype_enum AS ENUM ( - 'GRVD', - 'BGSENT', - 'CO2' -); - -CREATE TYPE fieldseeker.trapdata_notinuitrapactivitytype_enum AS ENUM ( - 'S', - 'R' -); - -CREATE TYPE fieldseeker.trapdata_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.trapdata_mosquitositecondition_enum AS ENUM ( - 'Dry', - 'Clean', - 'Full', - 'Low' -); - -CREATE TYPE fieldseeker.trapdata_mosquitotrapcondition_enum AS ENUM ( - 'Damaged', - 'Missing', - 'Fan Off', - 'Fan Slow' -); - -CREATE TYPE fieldseeker.trapdata_trapdata_winddir_c1a31e05_d0b9_4b22_8800_be127bb3f166_enum AS ENUM ( - 'E', - 'N', - 'NE', - 'NW', - 'S', - 'SE', - 'SW', - 'W' -); - -CREATE TYPE fieldseeker.trapdata_trapdata_lure_25fe542f_077f_4254_8681_76e8f436354b_enum AS ENUM ( - 'CO2 (Dry Ice)', - 'CO2 (Sugar Yeast)', - 'BG-Lure', - 'Gravid Water' -); - -CREATE TABLE fieldseeker.trapdata ( - objectid BIGSERIAL NOT NULL, - traptype fieldseeker.trapdata_mosquitotraptype_enum, - trapactivitytype fieldseeker.trapdata_notinuitrapactivitytype_enum, - startdatetime TIMESTAMP, - enddatetime TIMESTAMP, - comments VARCHAR(250), - idbytech VARCHAR(25), - sortbytech VARCHAR(25), - processed fieldseeker.trapdata_notinuit_f_enum, - sitecond fieldseeker.trapdata_mosquitositecondition_enum, - locationname VARCHAR(25), - recordstatus SMALLINT, - reviewed fieldseeker.trapdata_notinuit_f_enum, - reviewedby VARCHAR(25), - revieweddate TIMESTAMP, - trapcondition fieldseeker.trapdata_mosquitotrapcondition_enum, - trapnights SMALLINT, - zone VARCHAR(25), - zone2 VARCHAR(25), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - srid UUID, - fieldtech VARCHAR(25), - gatewaysync SMALLINT, - loc_id UUID, - voltage DOUBLE PRECISION, - winddir fieldseeker.trapdata_trapdata_winddir_c1a31e05_d0b9_4b22_8800_be127bb3f166_enum, - windspeed DOUBLE PRECISION, - avetemp DOUBLE PRECISION, - raingauge DOUBLE PRECISION, - lr SMALLINT, - field INTEGER, - vectorsurvtrapdataid VARCHAR(50), - vectorsurvtraplocationid VARCHAR(50), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - lure fieldseeker.trapdata_trapdata_lure_25fe542f_077f_4254_8681_76e8f436354b_enum, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.trapdata.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.trapdata.traptype IS 'Trap Type'; -COMMENT ON COLUMN fieldseeker.trapdata.trapactivitytype IS 'Trap Activity Type'; -COMMENT ON COLUMN fieldseeker.trapdata.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.trapdata.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.trapdata.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.trapdata.idbytech IS 'Tech Identifying Species in Lab'; -COMMENT ON COLUMN fieldseeker.trapdata.sortbytech IS 'Tech Sorting Trap Results in Lab'; -COMMENT ON COLUMN fieldseeker.trapdata.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.trapdata.sitecond IS 'Site Conditions'; -COMMENT ON COLUMN fieldseeker.trapdata.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.trapdata.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.trapdata.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.trapdata.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.trapdata.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.trapdata.trapcondition IS 'Trap Condition'; -COMMENT ON COLUMN fieldseeker.trapdata.trapnights IS 'Trap Nights'; -COMMENT ON COLUMN fieldseeker.trapdata.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.trapdata.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.trapdata.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.trapdata.gatewaysync IS 'Gateway Sync'; -COMMENT ON COLUMN fieldseeker.trapdata.voltage IS 'Voltage'; -COMMENT ON COLUMN fieldseeker.trapdata.lr IS 'Landing Rate'; - --- See insert/insert_trapdata_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/traplocation.sql b/db/fieldseeker-schema/traplocation.sql deleted file mode 100644 index 8e74970d..00000000 --- a/db/fieldseeker-schema/traplocation.sql +++ /dev/null @@ -1,98 +0,0 @@ --- Table definition for fieldseeker.TrapLocation --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.traplocation_traplocation_habitat_5c349680f5ff40b1aeca88c17993e8f3_enum AS ENUM ( - 'Trap' -); - -CREATE TYPE fieldseeker.traplocation_traplocation_priority_680fb011063b41d59f39271c959b857f_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None', - 'Project', - 'Fixed', - 'Response ' -); - -CREATE TYPE fieldseeker.traplocation_traplocation_usetype_5e0eff9231fb404c98cc53c1d49a2193_enum AS ENUM ( - 'Fixed Trapping', - 'Response Trapping', - 'Service Request', - 'Project Trap' -); - -CREATE TYPE fieldseeker.traplocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.traplocation_traplocation_accessdesc_154cbd10_4524_4e3a_8ca0_f099ec86556a_enum AS ENUM ( - 'homeowner preference', - 'no longer needed' -); - -CREATE TABLE fieldseeker.traplocation ( - objectid BIGSERIAL NOT NULL, - name VARCHAR(25), - zone VARCHAR(25), - habitat fieldseeker.traplocation_traplocation_habitat_5c349680f5ff40b1aeca88c17993e8f3_enum, - priority fieldseeker.traplocation_traplocation_priority_680fb011063b41d59f39271c959b857f_enum, - usetype fieldseeker.traplocation_traplocation_usetype_5e0eff9231fb404c98cc53c1d49a2193_enum, - active fieldseeker.traplocation_notinuit_f_enum, - description VARCHAR(250), - accessdesc fieldseeker.traplocation_traplocation_accessdesc_154cbd10_4524_4e3a_8ca0_f099ec86556a_enum, - comments VARCHAR(250), - externalid VARCHAR(50), - nextactiondatescheduled TIMESTAMP, - zone2 VARCHAR(25), - locationnumber INTEGER, - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - gatewaysync SMALLINT, - route INTEGER, - set_dow INTEGER, - route_order INTEGER, - vectorsurvsiteid VARCHAR(50), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - h3r7 VARCHAR(255), - h3r8 VARCHAR(255), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.traplocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.traplocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.traplocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.traplocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.traplocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.traplocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.traplocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.traplocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.traplocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.traplocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.traplocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.traplocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.traplocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.traplocation.gatewaysync IS 'Gateway Sync'; -COMMENT ON COLUMN fieldseeker.traplocation.route IS 'Route'; -COMMENT ON COLUMN fieldseeker.traplocation.set_dow IS 'Set Day of Week'; -COMMENT ON COLUMN fieldseeker.traplocation.route_order IS 'Route order'; - --- Field active has default value: 1 - --- See insert/insert_traplocation_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/treatment.sql b/db/fieldseeker-schema/treatment.sql deleted file mode 100644 index 3393e9a4..00000000 --- a/db/fieldseeker-schema/treatment.sql +++ /dev/null @@ -1,259 +0,0 @@ --- Table definition for fieldseeker.Treatment --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TYPE fieldseeker.treatment_treatment_method_d558ca3ccf43440c8160758253967621_enum AS ENUM ( - 'Argo', - 'ATV', - 'Backpack', - 'Drone', - 'Manual', - 'Truck', - 'ULV', - 'WALS', - 'Administrative Action' -); - -CREATE TYPE fieldseeker.treatment_treatment_equiptype_45694d79_ff21_42cc_be4f_a0d1def4fba0_enum AS ENUM ( - 'Backpack #1', - 'A1 Mist Sprayer (T-3) ', - 'Spreader #2', - 'Guardian #73 ', - 'ULV #74 (Grizzly)', - 'Clark ULV Sprayer #71', - 'Clark ULV Sprayer #72', - 'Spray bottle' -); - -CREATE TYPE fieldseeker.treatment_notinuiwinddirection_enum AS ENUM ( - 'N', - 'NE', - 'E', - 'SE', - 'S', - 'SW', - 'W', - 'NW' -); - -CREATE TYPE fieldseeker.treatment_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.treatment_treatment_habitat_0afee7eb_f9ea_4707_8483_cccfe60f0d16_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grass_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'Utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetlands', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'foutain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'applicance', - 'flooded_structure', - 'low_point' -); - -CREATE TYPE fieldseeker.treatment_treatment_sitecond_f812e1f64dcb4dc9a75da9d00abe6169_enum AS ENUM ( - 'Dry', - 'Flowing', - 'Maintained', - 'Unmaintained', - 'High Organic', - 'Fish Present' -); - -CREATE TYPE fieldseeker.treatment_treatment_sitecond_5a15bf36fa124280b961f31cd1a9b571_enum AS ENUM ( - 'Dry', - 'Flowing', - 'Maintained', - 'Unmaintained', - 'High Organic', - 'Fish Present', - 'Stagnant' -); - -CREATE TYPE fieldseeker.treatment_mosquitoactivity_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TYPE fieldseeker.treatment_mosquitoproductareaunit_enum AS ENUM ( - 'acre', - 'sq ft' -); - -CREATE TYPE fieldseeker.treatment_mosquitoproductmeasureunit_enum AS ENUM ( - 'briquet', - 'dry oz', - 'each', - 'fl oz', - 'gal', - 'lb', - 'packet', - 'pouch' -); - -CREATE TABLE fieldseeker.treatment ( - objectid BIGSERIAL NOT NULL, - activity fieldseeker.treatment_mosquitoactivity_enum, - treatarea DOUBLE PRECISION, - areaunit fieldseeker.treatment_mosquitoproductareaunit_enum, - product VARCHAR(25), - qty DOUBLE PRECISION, - qtyunit fieldseeker.treatment_mosquitoproductmeasureunit_enum, - method fieldseeker.treatment_treatment_method_d558ca3ccf43440c8160758253967621_enum, - equiptype fieldseeker.treatment_treatment_equiptype_45694d79_ff21_42cc_be4f_a0d1def4fba0_enum, - comments VARCHAR(250), - avetemp DOUBLE PRECISION, - windspeed DOUBLE PRECISION, - winddir fieldseeker.treatment_notinuiwinddirection_enum, - raingauge DOUBLE PRECISION, - startdatetime TIMESTAMP, - enddatetime TIMESTAMP, - insp_id UUID, - reviewed fieldseeker.treatment_notinuit_f_enum, - reviewedby VARCHAR(25), - revieweddate TIMESTAMP, - locationname VARCHAR(25), - zone VARCHAR(25), - warningoverride fieldseeker.treatment_notinuit_f_enum, - recordstatus SMALLINT, - zone2 VARCHAR(25), - treatacres DOUBLE PRECISION, - tirecount SMALLINT, - cbcount SMALLINT, - containercount SMALLINT, - globalid UUID, - treatmentlength DOUBLE PRECISION, - treatmenthours DOUBLE PRECISION, - treatmentlengthunits VARCHAR(5), - linelocid UUID, - pointlocid UUID, - polygonlocid UUID, - srid UUID, - sdid UUID, - barrierrouteid UUID, - ulvrouteid UUID, - fieldtech VARCHAR(25), - ptaid UUID, - flowrate DOUBLE PRECISION, - habitat fieldseeker.treatment_treatment_habitat_0afee7eb_f9ea_4707_8483_cccfe60f0d16_enum, - treathectares DOUBLE PRECISION, - invloc VARCHAR(25), - temp_sitecond fieldseeker.treatment_treatment_sitecond_f812e1f64dcb4dc9a75da9d00abe6169_enum, - sitecond fieldseeker.treatment_treatment_sitecond_5a15bf36fa124280b961f31cd1a9b571_enum, - totalcostprodcut DOUBLE PRECISION, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - targetspecies VARCHAR(250), - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.treatment.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.treatment.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.treatment.treatarea IS 'Area Treated'; -COMMENT ON COLUMN fieldseeker.treatment.areaunit IS 'Area Unit'; -COMMENT ON COLUMN fieldseeker.treatment.product IS 'Product'; -COMMENT ON COLUMN fieldseeker.treatment.qty IS 'Quantity'; -COMMENT ON COLUMN fieldseeker.treatment.qtyunit IS 'Quantity Unit'; -COMMENT ON COLUMN fieldseeker.treatment.method IS 'Method'; -COMMENT ON COLUMN fieldseeker.treatment.equiptype IS 'Equipment Type'; -COMMENT ON COLUMN fieldseeker.treatment.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.treatment.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.treatment.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.treatment.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.treatment.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.treatment.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.treatment.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.treatment.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.treatment.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.treatment.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.treatment.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.treatment.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.treatment.warningoverride IS 'Warning Override'; -COMMENT ON COLUMN fieldseeker.treatment.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.treatment.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.treatment.treatacres IS 'Treated Acres'; -COMMENT ON COLUMN fieldseeker.treatment.tirecount IS 'Tire Count'; -COMMENT ON COLUMN fieldseeker.treatment.cbcount IS 'Catch Basin Count'; -COMMENT ON COLUMN fieldseeker.treatment.containercount IS 'Container Count'; -COMMENT ON COLUMN fieldseeker.treatment.treatmentlength IS 'Treatment Length'; -COMMENT ON COLUMN fieldseeker.treatment.treatmenthours IS 'Treatment Hours'; -COMMENT ON COLUMN fieldseeker.treatment.treatmentlengthunits IS 'Treatment Length Units'; -COMMENT ON COLUMN fieldseeker.treatment.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.treatment.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.treatment.treathectares IS 'Treat Hectares'; -COMMENT ON COLUMN fieldseeker.treatment.invloc IS 'Inventory Location'; -COMMENT ON COLUMN fieldseeker.treatment.temp_sitecond IS 'temp_Conditions'; -COMMENT ON COLUMN fieldseeker.treatment.sitecond IS 'Conditions'; -COMMENT ON COLUMN fieldseeker.treatment.totalcostprodcut IS 'TotalCostProduct'; -COMMENT ON COLUMN fieldseeker.treatment.targetspecies IS 'Target Species'; - --- See insert/insert_treatment_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/treatmentarea.sql b/db/fieldseeker-schema/treatmentarea.sql deleted file mode 100644 index 84f73d95..00000000 --- a/db/fieldseeker-schema/treatmentarea.sql +++ /dev/null @@ -1,38 +0,0 @@ --- Table definition for fieldseeker.TreatmentArea --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TABLE fieldseeker.treatmentarea ( - objectid BIGSERIAL NOT NULL, - treat_id UUID, - session_id UUID, - treatdate TIMESTAMP, - comments VARCHAR(250), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - notified SMALLINT, - type VARCHAR(25), - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - shape__area DOUBLE PRECISION, - shape__length DOUBLE PRECISION, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.treatmentarea.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.treatmentarea.treatdate IS 'Treatment Date'; - --- See insert/insert_treatmentarea_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/zones.sql b/db/fieldseeker-schema/zones.sql deleted file mode 100644 index f2facf05..00000000 --- a/db/fieldseeker-schema/zones.sql +++ /dev/null @@ -1,34 +0,0 @@ --- Table definition for fieldseeker.Zones --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TABLE fieldseeker.zones ( - objectid BIGSERIAL NOT NULL, - name VARCHAR(50), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - active INTEGER, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - shape__area DOUBLE PRECISION, - shape__length DOUBLE PRECISION, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.zones.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.zones.name IS 'Name'; - --- See insert/insert_zones_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker-schema/zones2.sql b/db/fieldseeker-schema/zones2.sql deleted file mode 100644 index 98d52648..00000000 --- a/db/fieldseeker-schema/zones2.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Table definition for fieldseeker.Zones2 --- Includes versioning for tracking changes - -CREATE SCHEMA IF NOT EXISTS fieldseeker; - -CREATE TABLE fieldseeker.zones2 ( - objectid BIGSERIAL NOT NULL, - name VARCHAR(50), - globalid UUID, - created_user VARCHAR(255), - created_date TIMESTAMP, - last_edited_user VARCHAR(255), - last_edited_date TIMESTAMP, - creationdate TIMESTAMP, - creator VARCHAR(128), - editdate TIMESTAMP, - editor VARCHAR(128), - shape__area DOUBLE PRECISION, - shape__length DOUBLE PRECISION, - VERSION INTEGER NOT NULL DEFAULT 1, - PRIMARY KEY (objectid, VERSION) -); - -COMMENT ON COLUMN fieldseeker.zones2.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; - -COMMENT ON COLUMN fieldseeker.zones2.name IS 'Name'; - --- See insert/insert_zones2_versioned.sql for prepared insert statement - --- Usage notes for versioning: --- When inserting a new row, VERSION defaults to 1 --- When updating a row, insert a new row with the same ID but incremented VERSION --- The most recent version of a row has the highest VERSION value diff --git a/db/fieldseeker.go b/db/fieldseeker.go index 8084531f..4acb4400 100644 --- a/db/fieldseeker.go +++ b/db/fieldseeker.go @@ -20,10 +20,10 @@ func SaveOrUpdateAerialSpraySession(ctx context.Context, org *models.Organizatio log.Warn().Msg("Ignoring AerialSpraySession data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "AerialSpraySession", "fieldseeker.insert_aerialspraysession", func(row *fslayer.AerialSpraySession) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "AerialSpraySession", "fieldseeker.insert_aerialspraysession", func(row *fslayer.AerialSpraySession) ([]SqlParam, error) { return []SqlParam{ //Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } @@ -31,9 +31,9 @@ func SaveOrUpdateAerialSprayLine(ctx context.Context, org *models.Organization, log.Warn().Msg("Ignoring AerialSprayLine data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "AerialSprayLine", "fieldseeker.insert_aerialsprayline", func(row *fslayer.AerialSprayLine) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "AerialSprayLine", "fieldseeker.insert_aerialsprayline", func(row *fslayer.AerialSprayLine) ([]SqlParam, error) { return []SqlParam{ - } + }, nil }) */ } @@ -41,9 +41,9 @@ func SaveOrUpdateBarrierSpray(ctx context.Context, org *models.Organization, fs log.Warn().Msg("Ignoring BarrierSpray data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "BarrierSpray", "fieldseeker.insert_barrierspray", func(row *fslayer.BarrierSpray) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "BarrierSpray", "fieldseeker.insert_barrierspray", func(row *fslayer.BarrierSpray) ([]SqlParam, error) { return []SqlParam{ - } + }, nil }) */ } @@ -51,14 +51,18 @@ func SaveOrUpdateBarrierSprayRoute(ctx context.Context, org *models.Organization log.Warn().Msg("Ignoring BarrierSprayRoute data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "BarrierSprayRoute", "fieldseeker.insert_barriersprayroute", func(row *fslayer.BarrierSprayRoute) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "BarrierSprayRoute", "fieldseeker.insert_barriersprayroute", func(row *fslayer.BarrierSprayRoute) ([]SqlParam, error) { return []SqlParam{ - } + }, nil }) */ } func SaveOrUpdateContainerRelate(ctx context.Context, org *models.Organization, fs []*fslayer.ContainerRelate) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "ContainerRelate", "fieldseeker.insert_containerrelate", func(row *fslayer.ContainerRelate) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "ContainerRelate", "fieldseeker.insert_containerrelate", func(row *fslayer.ContainerRelate) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_globalid", row.GlobalID), @@ -74,11 +78,17 @@ func SaveOrUpdateContainerRelate(ctx context.Context, org *models.Organization, String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) } func SaveOrUpdateFieldScoutingLog(ctx context.Context, org *models.Organization, fs []*fslayer.FieldScoutingLog) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "FieldScoutingLog", "fieldseeker.insert_fieldscoutinglog", func(row *fslayer.FieldScoutingLog) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "FieldScoutingLog", "fieldseeker.insert_fieldscoutinglog", func(row *fslayer.FieldScoutingLog) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), Int16("p_status", row.Status), @@ -91,12 +101,18 @@ func SaveOrUpdateFieldScoutingLog(ctx context.Context, org *models.Organization, String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateHabitatRelate(ctx context.Context, org *models.Organization, fs []*fslayer.HabitatRelate) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "HabitatRelate", "fieldseeker.insert_habitatrelate", func(row *fslayer.HabitatRelate) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "HabitatRelate", "fieldseeker.insert_habitatrelate", func(row *fslayer.HabitatRelate) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_foreign_id", row.ForeignID), @@ -110,12 +126,18 @@ func SaveOrUpdateHabitatRelate(ctx context.Context, org *models.Organization, fs String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateInspectionSample(ctx context.Context, org *models.Organization, fs []*fslayer.InspectionSample) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "InspectionSample", "fieldseeker.insert_inspectionsample", func(row *fslayer.InspectionSample) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "InspectionSample", "fieldseeker.insert_inspectionsample", func(row *fslayer.InspectionSample) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_insp_id", row.InspID), @@ -131,12 +153,18 @@ func SaveOrUpdateInspectionSample(ctx context.Context, org *models.Organization, String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateInspectionSampleDetail(ctx context.Context, org *models.Organization, fs []*fslayer.InspectionSampleDetail) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "InspectionSampleDetail", "fieldseeker.insert_inspectionsampledetail", func(row *fslayer.InspectionSampleDetail) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "InspectionSampleDetail", "fieldseeker.insert_inspectionsampledetail", func(row *fslayer.InspectionSampleDetail) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_inspsample_id", row.InspsampleID), @@ -163,7 +191,9 @@ func SaveOrUpdateInspectionSampleDetail(ctx context.Context, org *models.Organiz String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } @@ -171,10 +201,10 @@ func SaveOrUpdateLandingCount(ctx context.Context, org *models.Organization, fs log.Warn().Msg("Ignoring LandingCount data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "LandingCount", "fieldseeker.insert_landingcount", func(row *fslayer.LandingCount) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "LandingCount", "fieldseeker.insert_landingcount", func(row *fslayer.LandingCount) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } @@ -182,15 +212,19 @@ func SaveOrUpdateLandingCountLocation(ctx context.Context, org *models.Organizat log.Warn().Msg("Ignoring LandingCountLocation data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "LandingCountLocation", "fieldseeker.insert_landingcountlocation", func(row *fslayer.LandingCountLocation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "LandingCountLocation", "fieldseeker.insert_landingcountlocation", func(row *fslayer.LandingCountLocation) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } func SaveOrUpdateLineLocation(ctx context.Context, org *models.Organization, fs []*fslayer.LineLocation) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "LineLocation", "fieldseeker.insert_linelocation", func(row *fslayer.LineLocation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "LineLocation", "fieldseeker.insert_linelocation", func(row *fslayer.LineLocation) ([]SqlParam, error) { + gisPoint, err := lineOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_name", row.Name), @@ -240,12 +274,18 @@ func SaveOrUpdateLineLocation(ctx context.Context, org *models.Organization, fs String("p_editor", row.Editor), String("p_jurisdiction", row.Jurisdiction), Float64("p_shape__length", row.ShapeLength), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateLocationTracking(ctx context.Context, org *models.Organization, fs []*fslayer.LocationTracking) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "LocationTracking", "fieldseeker.insert_locationtracking", func(row *fslayer.LocationTracking) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "LocationTracking", "fieldseeker.insert_locationtracking", func(row *fslayer.LocationTracking) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), Float64("p_accuracy", row.Accuracym), @@ -259,12 +299,18 @@ func SaveOrUpdateLocationTracking(ctx context.Context, org *models.Organization, String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateMosquitoInspection(ctx context.Context, org *models.Organization, fs []*fslayer.MosquitoInspection) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "MosquitoInspection", "fieldseeker.insert_mosquitoinspection", func(row *fslayer.MosquitoInspection) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "MosquitoInspection", "fieldseeker.insert_mosquitoinspection", func(row *fslayer.MosquitoInspection) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), Int16("p_numdips", row.Dips), @@ -323,22 +369,31 @@ func SaveOrUpdateMosquitoInspection(ctx context.Context, org *models.Organizatio String("p_vmcomments", row.VmComments), String("p_adminaction", row.AdminAction), UUID("p_ptaid", row.PtaID), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) } func SaveOrUpdateOfflineMapAreas(ctx context.Context, org *models.Organization, fs []*fslayer.OfflineMapAreas) (inserts uint, updates uint, err error) { log.Warn().Msg("Ignoring OfflineMapAreas data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "OfflineMapAreas", "fieldseeker.insert_offlinemapareas", func(row *fslayer.OfflineMapAreas) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "OfflineMapAreas", "fieldseeker.insert_offlinemapareas", func(row *fslayer.OfflineMapAreas) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } func SaveOrUpdateProposedTreatmentArea(ctx context.Context, org *models.Organization, fs []*fslayer.ProposedTreatmentArea) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "ProposedTreatmentArea", "fieldseeker.insert_proposedtreatmentarea", func(row *fslayer.ProposedTreatmentArea) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "ProposedTreatmentArea", "fieldseeker.insert_proposedtreatmentarea", func(row *fslayer.ProposedTreatmentArea) ([]SqlParam, error) { + gisPoint, err := polygonOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } + // At this point we've got data that's bad and can't actually be inserted in the database + // so let's just always make the geo null + gisPoint = NullParam{"p_geospatial"} return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_method", row.Method), @@ -373,11 +428,17 @@ func SaveOrUpdateProposedTreatmentArea(ctx context.Context, org *models.Organiza String("p_targetspecies", row.TargetSpecies), Float64("p_shape__area", row.ShapeArea), Float64("p_shape__length", row.ShapeLength), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) } func SaveOrUpdatePointLocation(ctx context.Context, org *models.Organization, fs []*fslayer.PointLocation) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "PointLocation", "fieldseeker.insert_pointlocation", func(row *fslayer.PointLocation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "PointLocation", "fieldseeker.insert_pointlocation", func(row *fslayer.PointLocation) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_name", row.Name), @@ -423,12 +484,21 @@ func SaveOrUpdatePointLocation(ctx context.Context, org *models.Organization, fs String("p_deactivate_reason", row.ReasonForDeactivation), Int32("p_scalarpriority", row.ScalarPriority), String("p_sourcestatus", row.SourceStatus), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdatePolygonLocation(ctx context.Context, org *models.Organization, fs []*fslayer.PolygonLocation) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "PolygonLocation", "fieldseeker.insert_polygonlocation", func(row *fslayer.PolygonLocation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "PolygonLocation", "fieldseeker.insert_polygonlocation", func(row *fslayer.PolygonLocation) ([]SqlParam, error) { + gisPoint, err := polygonOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } + // At this point we've got data that's bad and can't actually be inserted in the database + // so let's just always make the geo null + gisPoint = NullParam{"p_geospatial"} return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_name", row.Name), @@ -472,12 +542,18 @@ func SaveOrUpdatePolygonLocation(ctx context.Context, org *models.Organization, String("p_jurisdiction", row.Jurisdiction), Float64("p_shape__area", row.ShapeArea), Float64("p_shape__length", row.ShapeLength), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdatePoolDetail(ctx context.Context, org *models.Organization, fs []*fslayer.PoolDetail) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "PoolDetail", "fieldseeker.insert_pooldetail", func(row *fslayer.PoolDetail) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "PoolDetail", "fieldseeker.insert_pooldetail", func(row *fslayer.PoolDetail) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_trapdata_id", row.TrapDataID), @@ -493,12 +569,18 @@ func SaveOrUpdatePoolDetail(ctx context.Context, org *models.Organization, fs [] String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdatePool(ctx context.Context, org *models.Organization, fs []*fslayer.Pool) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "Pool", "fieldseeker.insert_pool", func(row *fslayer.Pool) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "Pool", "fieldseeker.insert_pool", func(row *fslayer.Pool) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_trapdata_id", row.TrapDataID), @@ -528,7 +610,9 @@ func SaveOrUpdatePool(ctx context.Context, org *models.Organization, fs []*fslay String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } @@ -536,10 +620,10 @@ func SaveOrUpdatePoolBuffer(ctx context.Context, org *models.Organization, fs [] log.Warn().Msg("Ignoring PoolBuffer data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "PoolBuffer", "fieldseeker.insert_poolbuffer", func(row *fslayer.PoolBuffer) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "PoolBuffer", "fieldseeker.insert_poolbuffer", func(row *fslayer.PoolBuffer) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } @@ -547,15 +631,19 @@ func SaveOrUpdateQALarvCount(ctx context.Context, org *models.Organization, fs [ log.Warn().Msg("Ignoring QALarvCount data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "QALarvCount", "fieldseeker.insert_qalarvcount", func(row *fslayer.QALarvCount) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "QALarvCount", "fieldseeker.insert_qalarvcount", func(row *fslayer.QALarvCount) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } func SaveOrUpdateQAMosquitoInspection(ctx context.Context, org *models.Organization, fs []*fslayer.QAMosquitoInspection) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "QAMosquitoInspection", "fieldseeker.insert_qamosquitoinspection", func(row *fslayer.QAMosquitoInspection) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "QAMosquitoInspection", "fieldseeker.insert_qamosquitoinspection", func(row *fslayer.QAMosquitoInspection) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), Int16("p_posdips", row.PositiveDips), @@ -619,7 +707,9 @@ func SaveOrUpdateQAMosquitoInspection(ctx context.Context, org *models.Organizat String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } @@ -627,10 +717,10 @@ func SaveOrUpdateQAProductObservation(ctx context.Context, org *models.Organizat log.Warn().Msg("Ignoring QAProductObservation data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "QAProductObservation", "fieldseeker.insert_qaproductobservation", func(row *fslayer.QAProductObservation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "QAProductObservation", "fieldseeker.insert_qaproductobservation", func(row *fslayer.QAProductObservation) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } @@ -638,10 +728,10 @@ func SaveOrUpdateRestrictedArea(ctx context.Context, org *models.Organization, f log.Warn().Msg("Ignoring RestrictedArea data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "RestrictedArea", "fieldseeker.insert_restrictedarea", func(row *fslayer.RestrictedArea) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "RestrictedArea", "fieldseeker.insert_restrictedarea", func(row *fslayer.RestrictedArea) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } @@ -649,15 +739,19 @@ func SaveOrUpdateRodentInspection(ctx context.Context, org *models.Organization, log.Warn().Msg("Ignoring RodentInspection data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "RodentInspection", "fieldseeker.insert_rodentinspection", func(row *fslayer.RodentInspection) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "RodentInspection", "fieldseeker.insert_rodentinspection", func(row *fslayer.RodentInspection) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } func SaveOrUpdateRodentLocation(ctx context.Context, org *models.Organization, fs []*fslayer.RodentLocation) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "RodentLocation", "fieldseeker.insert_rodentlocation", func(row *fslayer.RodentLocation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "RodentLocation", "fieldseeker.insert_rodentlocation", func(row *fslayer.RodentLocation) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_locationname", row.LocationName), @@ -689,12 +783,18 @@ func SaveOrUpdateRodentLocation(ctx context.Context, org *models.Organization, f Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), String("p_jurisdiction", row.Jurisdiction), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) } func SaveOrUpdateSampleCollection(ctx context.Context, org *models.Organization, fs []*fslayer.SampleCollection) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "SampleCollection", "fieldseeker.insert_samplecollection", func(row *fslayer.SampleCollection) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "SampleCollection", "fieldseeker.insert_samplecollection", func(row *fslayer.SampleCollection) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_loc_id", row.LocID), @@ -742,12 +842,18 @@ func SaveOrUpdateSampleCollection(ctx context.Context, org *models.Organization, String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateSampleLocation(ctx context.Context, org *models.Organization, fs []*fslayer.SampleLocation) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "SampleLocation", "fieldseeker.insert_samplelocation", func(row *fslayer.SampleLocation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "SampleLocation", "fieldseeker.insert_samplelocation", func(row *fslayer.SampleLocation) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_name", row.Name), @@ -773,12 +879,18 @@ func SaveOrUpdateSampleLocation(ctx context.Context, org *models.Organization, f String("p_creator", row.Creator), Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateServiceRequest(ctx context.Context, org *models.Organization, fs []*fslayer.ServiceRequest) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "ServiceRequest", "fieldseeker.insert_servicerequest", func(row *fslayer.ServiceRequest) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "ServiceRequest", "fieldseeker.insert_servicerequest", func(row *fslayer.ServiceRequest) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), Timestamp("p_recdatetime", row.Received), @@ -866,12 +978,18 @@ func SaveOrUpdateServiceRequest(ctx context.Context, org *models.Organization, f String("p_notificationtimestamp", row.NotificationTimestamp), String("p_zone", row.Zone), String("p_zone2", row.Zone2), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateSpeciesAbundance(ctx context.Context, org *models.Organization, fs []*fslayer.SpeciesAbundance) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "SpeciesAbundance", "fieldseeker.insert_speciesabundance", func(row *fslayer.SpeciesAbundance) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "SpeciesAbundance", "fieldseeker.insert_speciesabundance", func(row *fslayer.SpeciesAbundance) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_trapdata_id", row.TrapDataID), @@ -902,12 +1020,18 @@ func SaveOrUpdateSpeciesAbundance(ctx context.Context, org *models.Organization, Float64("p_r8score", row.R8Score), String("p_h3r7", row.H3r7), String("p_h3r8", row.H3r8), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateStormDrain(ctx context.Context, org *models.Organization, fs []*fslayer.StormDrain) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "StormDrain", "fieldseeker.insert_stormdrain", func(row *fslayer.StormDrain) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "StormDrain", "fieldseeker.insert_stormdrain", func(row *fslayer.StormDrain) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), Timestamp("p_nexttreatmentdate", row.NextTreatmentDate), @@ -928,7 +1052,9 @@ func SaveOrUpdateStormDrain(ctx context.Context, org *models.Organization, fs [] String("p_editor", row.Editor), String("p_type", row.Type), String("p_jurisdiction", row.Jurisdiction), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } @@ -936,15 +1062,19 @@ func SaveOrUpdateTracklog(ctx context.Context, org *models.Organization, fs []*f log.Warn().Msg("Ignoring RodentInspection data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "Tracklog", "fieldseeker.insert_tracklog", func(row *fslayer.Tracklog) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "Tracklog", "fieldseeker.insert_tracklog", func(row *fslayer.Tracklog) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } func SaveOrUpdateTrapLocation(ctx context.Context, org *models.Organization, fs []*fslayer.TrapLocation) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "TrapLocation", "fieldseeker.insert_traplocation", func(row *fslayer.TrapLocation) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "TrapLocation", "fieldseeker.insert_traplocation", func(row *fslayer.TrapLocation) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_name", row.Name), @@ -976,12 +1106,18 @@ func SaveOrUpdateTrapLocation(ctx context.Context, org *models.Organization, fs String("p_editor", row.Editor), String("p_h3r7", row.H3r7), String("p_h3r8", row.H3r8), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateTrapData(ctx context.Context, org *models.Organization, fs []*fslayer.TrapData) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "TrapData", "fieldseeker.insert_trapdata", func(row *fslayer.TrapData) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "TrapData", "fieldseeker.insert_trapdata", func(row *fslayer.TrapData) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_traptype", row.TrapType), @@ -1025,12 +1161,18 @@ func SaveOrUpdateTrapData(ctx context.Context, org *models.Organization, fs []*f Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), String("p_lure", row.Lure), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateTimeCard(ctx context.Context, org *models.Organization, fs []*fslayer.TimeCard) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "TimeCard", "fieldseeker.insert_timecard", func(row *fslayer.TimeCard) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "TimeCard", "fieldseeker.insert_timecard", func(row *fslayer.TimeCard) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_activity", row.Activity), @@ -1060,12 +1202,18 @@ func SaveOrUpdateTimeCard(ctx context.Context, org *models.Organization, fs []*f Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), UUID("p_rodentlocid", row.RodentlocID), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateTreatment(ctx context.Context, org *models.Organization, fs []*fslayer.Treatment) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "Treatment", "fieldseeker.insert_treatment", func(row *fslayer.Treatment) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "Treatment", "fieldseeker.insert_treatment", func(row *fslayer.Treatment) ([]SqlParam, error) { + gisPoint, err := pointOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_activity", row.Activity), @@ -1121,12 +1269,19 @@ func SaveOrUpdateTreatment(ctx context.Context, org *models.Organization, fs []* Timestamp("p_editdate", row.EditDate), String("p_editor", row.Editor), String("p_targetspecies", row.TargetSpecies), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateTreatmentArea(ctx context.Context, org *models.Organization, fs []*fslayer.TreatmentArea) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "TreatmentArea", "fieldseeker.insert_treatmentarea", func(row *fslayer.TreatmentArea) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "TreatmentArea", "fieldseeker.insert_treatmentarea", func(row *fslayer.TreatmentArea) ([]SqlParam, error) { + gisPoint, err := polygonOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } + gisPoint = NullParam{"p_geospatial"} return []SqlParam{ Uint("p_objectid", row.ObjectID), UUID("p_treat_id", row.TreatID), @@ -1146,7 +1301,9 @@ func SaveOrUpdateTreatmentArea(ctx context.Context, org *models.Organization, fs String("p_editor", row.Editor), Float64("p_shape__area", row.ShapeArea), Float64("p_shape__length", row.ShapeLength), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } @@ -1154,15 +1311,22 @@ func SaveOrUpdateULVSprayRoute(ctx context.Context, org *models.Organization, fs log.Warn().Msg("Ignoring RodentInspection data") return 0, 0, nil /* - return doUpdatesViaFunction(ctx, org, fs, "ULVSprayRoute", "fieldseeker.insert_ulvsprayroute", func(row *fslayer.ULVSprayRoute) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "ULVSprayRoute", "fieldseeker.insert_ulvsprayroute", func(row *fslayer.ULVSprayRoute) ([]SqlParam, error) { return []SqlParam{ Uint("p_objectid", row.ObjectID), - } + }, nil }) */ } func SaveOrUpdateZones(ctx context.Context, org *models.Organization, fs []*fslayer.Zones) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "Zones", "fieldseeker.insert_zones", func(row *fslayer.Zones) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "Zones", "fieldseeker.insert_zones", func(row *fslayer.Zones) ([]SqlParam, error) { + gisPoint, err := polygonOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } + // At this point we've got data that's bad and can't actually be inserted in the database + // so let's just always make the geo null + gisPoint = NullParam{"p_geospatial"} return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_name", row.Name), @@ -1178,12 +1342,21 @@ func SaveOrUpdateZones(ctx context.Context, org *models.Organization, fs []*fsla String("p_editor", row.Editor), Float64("p_shape__area", row.ShapeArea), Float64("p_shape__length", row.ShapeLength), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } func SaveOrUpdateZones2(ctx context.Context, org *models.Organization, fs []*fslayer.Zones2) (inserts uint, updates uint, err error) { - return doUpdatesViaFunction(ctx, org, fs, "Zones2", "fieldseeker.insert_zones2", func(row *fslayer.Zones2) []SqlParam { + return doUpdatesViaFunction(ctx, org, fs, "Zones2", "fieldseeker.insert_zones2", func(row *fslayer.Zones2) ([]SqlParam, error) { + gisPoint, err := polygonOrNull(row.Geometry) + if err != nil { + return []SqlParam{}, err + } + // At this point we've got data that's bad and can't actually be inserted in the database + // so let's just always make the geo null + gisPoint = NullParam{"p_geospatial"} return []SqlParam{ Uint("p_objectid", row.ObjectID), String("p_name", row.Name), @@ -1198,7 +1371,9 @@ func SaveOrUpdateZones2(ctx context.Context, org *models.Organization, fs []*fsl String("p_editor", row.Editor), Float64("p_shape__area", row.ShapeArea), Float64("p_shape__length", row.ShapeLength), - } + JsonB("p_geometry", row.Geometry), + gisPoint, + }, nil }) return 0, 0, nil } @@ -1208,17 +1383,20 @@ type InsertResultRow struct { Version int `db:"version_num"` } -type rowConverter[T any] func(*T) []SqlParam +type rowConverter[T any] func(*T) ([]SqlParam, error) func doUpdatesViaFunction[T any](ctx context.Context, org *models.Organization, fs []*T, table string, procedure string, converter rowConverter[T]) (inserts uint, updates uint, err error) { //log.Info().Int("rows", len(fs)).Msg("Processing RodentLocation") for _, row := range fs { - params := converter(row) + params, err := converter(row) + if err != nil { + return inserts, updates, fmt.Errorf("Failed to convert row '%s': %w", row, err) + } q := queryStoredProcedure(procedure, params...) query := psql.RawQuery(q) - log.Info().Str("query", q).Msg("querying") result, err := bob.One[InsertResultRow](ctx, PGInstance.BobDB, query, scan.StructMapper[InsertResultRow]()) if err != nil { + log.Error().Str("query", q).Msg("Query failed") return inserts, updates, fmt.Errorf("Failed to execute %s: %w", procedure, err) } if result.Inserted { @@ -1228,7 +1406,6 @@ func doUpdatesViaFunction[T any](ctx context.Context, org *models.Organization, updates += 1 } } - log.Info().Bool("inserted", result.Inserted).Int("version", result.Version).Msg("querying") } return inserts, updates, err diff --git a/db/migrations/00016_fieldseeker_schema.sql b/db/migrations/00016_fieldseeker_schema.sql index 460c55c9..517cadbe 100644 --- a/db/migrations/00016_fieldseeker_schema.sql +++ b/db/migrations/00016_fieldseeker_schema.sql @@ -1,19 +1,15 @@ -- +goose Up --- Table definition for fieldseeker.ContainerRelate +-- Table definition for fieldseeker.containerrelate -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.containerrelate_mosquitocontainertype_enum AS ENUM ( - 'Aquarium', - 'Flower pot', - '5 gallon bucket', - 'Fountain', - 'Bird bath' -); - CREATE TABLE fieldseeker.containerrelate ( objectid BIGSERIAL NOT NULL, + globalid UUID, created_user VARCHAR(255), created_date TIMESTAMP, @@ -22,81 +18,44 @@ CREATE TABLE fieldseeker.containerrelate ( inspsampleid UUID, mosquitoinspid UUID, treatmentid UUID, - containertype fieldseeker.containerrelate_mosquitocontainertype_enum, + containertype VARCHAR(250), creationdate TIMESTAMP, creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.containerrelate.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.containerrelate.containertype IS 'Container Type'; +COMMENT ON COLUMN fieldseeker.containerrelate.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.containerrelate.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.containerrelate.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.containerrelate.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.containerrelate.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.containerrelate.inspsampleid IS 'Original attribute from ArcGIS API is INSPSAMPLEID'; +COMMENT ON COLUMN fieldseeker.containerrelate.mosquitoinspid IS 'Original attribute from ArcGIS API is MOSQUITOINSPID'; +COMMENT ON COLUMN fieldseeker.containerrelate.treatmentid IS 'Original attribute from ArcGIS API is TREATMENTID'; +COMMENT ON COLUMN fieldseeker.containerrelate.containertype IS 'Original attribute from ArcGIS API is CONTAINERTYPE'; +COMMENT ON COLUMN fieldseeker.containerrelate.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.containerrelate.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.containerrelate.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.containerrelate.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_containerrelate_versioned(bigint, uuid, varchar, timestamp, varchar, timestamp, uuid, uuid, uuid, fieldseeker.containerrelate_mosquitocontainertype_enum, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.containerrelate - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.containerrelate - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.containerrelate ( - objectid, globalid, created_user, created_date, last_edited_user, last_edited_date, inspsampleid, mosquitoinspid, treatmentid, containertype, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.globalid IS NOT DISTINCT FROM $2 AND - lv.created_user IS NOT DISTINCT FROM $3 AND - lv.created_date IS NOT DISTINCT FROM $4 AND - lv.last_edited_user IS NOT DISTINCT FROM $5 AND - lv.last_edited_date IS NOT DISTINCT FROM $6 AND - lv.inspsampleid IS NOT DISTINCT FROM $7 AND - lv.mosquitoinspid IS NOT DISTINCT FROM $8 AND - lv.treatmentid IS NOT DISTINCT FROM $9 AND - lv.containertype IS NOT DISTINCT FROM $10 AND - lv.creationdate IS NOT DISTINCT FROM $11 AND - lv.creator IS NOT DISTINCT FROM $12 AND - lv.editdate IS NOT DISTINCT FROM $13 AND - lv.editor IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_containerrelate_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.FieldScoutingLog +-- Table definition for fieldseeker.fieldscoutinglog -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.fieldscoutinglog_fieldscoutingsymbology_enum AS ENUM ( - '0', - '1', - '2', - '3' -); - CREATE TABLE fieldseeker.fieldscoutinglog ( objectid BIGSERIAL NOT NULL, - status fieldseeker.fieldscoutinglog_fieldscoutingsymbology_enum, + + status SMALLINT, globalid UUID, created_user VARCHAR(255), created_date TIMESTAMP, @@ -106,188 +65,79 @@ CREATE TABLE fieldseeker.fieldscoutinglog ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.fieldscoutinglog.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.fieldscoutinglog.status IS 'Status'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.status IS 'Original attribute from ArcGIS API is STATUS'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.fieldscoutinglog.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_fieldscoutinglog_versioned(bigint, fieldseeker.fieldscoutinglog_fieldscoutingsymbology_enum, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.fieldscoutinglog - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.fieldscoutinglog - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.fieldscoutinglog ( - objectid, status, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.status IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.creationdate IS NOT DISTINCT FROM $8 AND - lv.creator IS NOT DISTINCT FROM $9 AND - lv.editdate IS NOT DISTINCT FROM $10 AND - lv.editor IS NOT DISTINCT FROM $11 - ) -RETURNING *; - --- Example usage: EXECUTE insert_fieldscoutinglog_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.HabitatRelate +-- Table definition for fieldseeker.habitatrelate -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.habitatrelate_habitatrelate_habitattype_2e81cf2f550e400783cf284f3cec3953_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetlands', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point' -); - CREATE TABLE fieldseeker.habitatrelate ( objectid BIGSERIAL NOT NULL, + foreign_id UUID, globalid UUID, created_user VARCHAR(255), created_date TIMESTAMP, last_edited_user VARCHAR(255), last_edited_date TIMESTAMP, - habitattype fieldseeker.habitatrelate_habitatrelate_habitattype_2e81cf2f550e400783cf284f3cec3953_enum, + habitattype VARCHAR(250), creationdate TIMESTAMP, creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.habitatrelate.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.habitatrelate.habitattype IS 'Habitat Type'; +COMMENT ON COLUMN fieldseeker.habitatrelate.foreign_id IS 'Original attribute from ArcGIS API is FOREIGN_ID'; +COMMENT ON COLUMN fieldseeker.habitatrelate.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.habitatrelate.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.habitatrelate.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.habitatrelate.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.habitatrelate.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.habitatrelate.habitattype IS 'Original attribute from ArcGIS API is HABITATTYPE'; +COMMENT ON COLUMN fieldseeker.habitatrelate.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.habitatrelate.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.habitatrelate.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.habitatrelate.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_habitatrelate_versioned(bigint, uuid, uuid, varchar, timestamp, varchar, timestamp, fieldseeker.habitatrelate_habitatrelate_habitattype_2e81cf2f550e400783cf284f3cec3953_enum, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.habitatrelate - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.habitatrelate - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.habitatrelate ( - objectid, foreign_id, globalid, created_user, created_date, last_edited_user, last_edited_date, habitattype, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.foreign_id IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.habitattype IS NOT DISTINCT FROM $8 AND - lv.creationdate IS NOT DISTINCT FROM $9 AND - lv.creator IS NOT DISTINCT FROM $10 AND - lv.editdate IS NOT DISTINCT FROM $11 AND - lv.editor IS NOT DISTINCT FROM $12 - ) -RETURNING *; - --- Example usage: EXECUTE insert_habitatrelate_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.InspectionSample +-- Table definition for fieldseeker.inspectionsample -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.inspectionsample_notinuit_f_enum AS ENUM ( - '1', - '0' -); - CREATE TABLE fieldseeker.inspectionsample ( objectid BIGSERIAL NOT NULL, + insp_id UUID, sampleid VARCHAR(25), - processed fieldseeker.inspectionsample_notinuit_f_enum, + processed SMALLINT, idbytech VARCHAR(25), globalid UUID, created_user VARCHAR(255), @@ -298,104 +148,51 @@ CREATE TABLE fieldseeker.inspectionsample ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.inspectionsample.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.inspectionsample.sampleid IS 'Sample ID'; -COMMENT ON COLUMN fieldseeker.inspectionsample.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.inspectionsample.idbytech IS 'Tech Identifying Species in Lab'; +COMMENT ON COLUMN fieldseeker.inspectionsample.insp_id IS 'Original attribute from ArcGIS API is INSP_ID'; +COMMENT ON COLUMN fieldseeker.inspectionsample.sampleid IS 'Original attribute from ArcGIS API is SAMPLEID'; +COMMENT ON COLUMN fieldseeker.inspectionsample.processed IS 'Original attribute from ArcGIS API is PROCESSED'; +COMMENT ON COLUMN fieldseeker.inspectionsample.idbytech IS 'Original attribute from ArcGIS API is IDBYTECH'; +COMMENT ON COLUMN fieldseeker.inspectionsample.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.inspectionsample.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.inspectionsample.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.inspectionsample.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.inspectionsample.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.inspectionsample.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.inspectionsample.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.inspectionsample.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.inspectionsample.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_inspectionsample_versioned(bigint, uuid, varchar, fieldseeker.inspectionsample_notinuit_f_enum, varchar, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.inspectionsample - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.inspectionsample - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.inspectionsample ( - objectid, insp_id, sampleid, processed, idbytech, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.insp_id IS NOT DISTINCT FROM $2 AND - lv.sampleid IS NOT DISTINCT FROM $3 AND - lv.processed IS NOT DISTINCT FROM $4 AND - lv.idbytech IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.creationdate IS NOT DISTINCT FROM $11 AND - lv.creator IS NOT DISTINCT FROM $12 AND - lv.editdate IS NOT DISTINCT FROM $13 AND - lv.editor IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_inspectionsample_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.InspectionSampleDetail +-- Table definition for fieldseeker.inspectionsampledetail -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.inspectionsampledetail_mosquitofieldspecies_enum AS ENUM ( - 'Aedes', - 'Culex' -); - -CREATE TYPE fieldseeker.inspectionsampledetail_mosquitodominantstage_enum AS ENUM ( - '1', - '2', - '3', - '4', - '1-2', - '3-4' -); - -CREATE TYPE fieldseeker.inspectionsampledetail_mosquitoadultactivity_enum AS ENUM ( - 'None', - 'Light', - 'Moderate', - 'Intense' -); - CREATE TABLE fieldseeker.inspectionsampledetail ( objectid BIGSERIAL NOT NULL, + inspsample_id UUID, - fieldspecies fieldseeker.inspectionsampledetail_mosquitofieldspecies_enum, + fieldspecies VARCHAR(25), flarvcount SMALLINT, fpupcount SMALLINT, feggcount SMALLINT, flstages VARCHAR(25), - fdomstage fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, - fadultact fieldseeker.inspectionsampledetail_mosquitoadultactivity_enum, + fdomstage VARCHAR(25), + fadultact VARCHAR(25), labspecies VARCHAR(50), llarvcount SMALLINT, lpupcount SMALLINT, leggcount SMALLINT, - ldomstage fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, + ldomstage VARCHAR(25), comments VARCHAR(250), globalid UUID, created_user VARCHAR(255), @@ -407,192 +204,59 @@ CREATE TABLE fieldseeker.inspectionsampledetail ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fieldspecies IS 'Field Species'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.flarvcount IS 'Field Larva Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fpupcount IS 'Field Pupa Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.feggcount IS 'Field Egg Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.flstages IS 'Field Larval Stages'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fdomstage IS 'Field Dominant Stage'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fadultact IS 'Field Adult Activity'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.labspecies IS 'Lab Species'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.llarvcount IS 'Lab Larva Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.lpupcount IS 'Lab Pupa Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.leggcount IS 'Lab Egg Count'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.ldomstage IS 'Lab Dominant Stage'; -COMMENT ON COLUMN fieldseeker.inspectionsampledetail.comments IS 'Comments'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.inspsample_id IS 'Original attribute from ArcGIS API is INSPSAMPLE_ID'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fieldspecies IS 'Original attribute from ArcGIS API is FIELDSPECIES'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.flarvcount IS 'Original attribute from ArcGIS API is FLARVCOUNT'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fpupcount IS 'Original attribute from ArcGIS API is FPUPCOUNT'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.feggcount IS 'Original attribute from ArcGIS API is FEGGCOUNT'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.flstages IS 'Original attribute from ArcGIS API is FLSTAGES'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fdomstage IS 'Original attribute from ArcGIS API is FDOMSTAGE'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.fadultact IS 'Original attribute from ArcGIS API is FADULTACT'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.labspecies IS 'Original attribute from ArcGIS API is LABSPECIES'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.llarvcount IS 'Original attribute from ArcGIS API is LLARVCOUNT'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.lpupcount IS 'Original attribute from ArcGIS API is LPUPCOUNT'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.leggcount IS 'Original attribute from ArcGIS API is LEGGCOUNT'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.ldomstage IS 'Original attribute from ArcGIS API is LDOMSTAGE'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.processed IS 'Original attribute from ArcGIS API is PROCESSED'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.inspectionsampledetail.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_inspectionsampledetail_versioned(bigint, uuid, fieldseeker.inspectionsampledetail_mosquitofieldspecies_enum, smallint, smallint, smallint, varchar, fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, fieldseeker.inspectionsampledetail_mosquitoadultactivity_enum, varchar, smallint, smallint, smallint, fieldseeker.inspectionsampledetail_mosquitodominantstage_enum, varchar, uuid, varchar, timestamp, varchar, timestamp, smallint, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.inspectionsampledetail - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.inspectionsampledetail - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.inspectionsampledetail ( - objectid, inspsample_id, fieldspecies, flarvcount, fpupcount, feggcount, flstages, fdomstage, fadultact, labspecies, llarvcount, lpupcount, leggcount, ldomstage, comments, globalid, created_user, created_date, last_edited_user, last_edited_date, processed, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.inspsample_id IS NOT DISTINCT FROM $2 AND - lv.fieldspecies IS NOT DISTINCT FROM $3 AND - lv.flarvcount IS NOT DISTINCT FROM $4 AND - lv.fpupcount IS NOT DISTINCT FROM $5 AND - lv.feggcount IS NOT DISTINCT FROM $6 AND - lv.flstages IS NOT DISTINCT FROM $7 AND - lv.fdomstage IS NOT DISTINCT FROM $8 AND - lv.fadultact IS NOT DISTINCT FROM $9 AND - lv.labspecies IS NOT DISTINCT FROM $10 AND - lv.llarvcount IS NOT DISTINCT FROM $11 AND - lv.lpupcount IS NOT DISTINCT FROM $12 AND - lv.leggcount IS NOT DISTINCT FROM $13 AND - lv.ldomstage IS NOT DISTINCT FROM $14 AND - lv.comments IS NOT DISTINCT FROM $15 AND - lv.globalid IS NOT DISTINCT FROM $16 AND - lv.created_user IS NOT DISTINCT FROM $17 AND - lv.created_date IS NOT DISTINCT FROM $18 AND - lv.last_edited_user IS NOT DISTINCT FROM $19 AND - lv.last_edited_date IS NOT DISTINCT FROM $20 AND - lv.processed IS NOT DISTINCT FROM $21 AND - lv.creationdate IS NOT DISTINCT FROM $22 AND - lv.creator IS NOT DISTINCT FROM $23 AND - lv.editdate IS NOT DISTINCT FROM $24 AND - lv.editor IS NOT DISTINCT FROM $25 - ) -RETURNING *; - --- Example usage: EXECUTE insert_inspectionsampledetail_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.LineLocation +-- Table definition for fieldseeker.linelocation -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.linelocation_linelocation_habitat_fc51bdc4f1954df58206d69ce14182f3_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetland', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point' -); - -CREATE TYPE fieldseeker.linelocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.linelocation_linelocation_usetype_2aeca2e60d2f455c86fc34895dc80a02_enum AS ENUM ( - 'residential', - 'commercial', - 'industrial', - 'agricultural', - 'mixed_use', - 'public_domain', - 'natural', - 'municipal' -); - -CREATE TYPE fieldseeker.linelocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.linelocation_locationsymbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - -CREATE TYPE fieldseeker.linelocation_linelocation_waterorigin_84723d92_306a_46f4_8ef1_69b55a916008_enum AS ENUM ( - 'flood_irrigation', - 'furrow_irrigation', - 'drip_irrigation', - 'sprinkler_irrigation', - 'wastewater_irrigation', - 'irrigation_runoff', - 'rainwater_accumulation', - 'leak', - 'seepage', - 'stored_water', - 'wastewater_system', - 'permanent_natural_water', - 'temporary_natural_water', - 'recreational_or_ornamental_water', - 'water_conveyance' -); - CREATE TABLE fieldseeker.linelocation ( objectid BIGSERIAL NOT NULL, + name VARCHAR(25), zone VARCHAR(25), - habitat fieldseeker.linelocation_linelocation_habitat_fc51bdc4f1954df58206d69ce14182f3_enum, - priority fieldseeker.linelocation_locationpriority_enum, - usetype fieldseeker.linelocation_linelocation_usetype_2aeca2e60d2f455c86fc34895dc80a02_enum, - active fieldseeker.linelocation_notinuit_f_enum, + habitat VARCHAR(25), + priority VARCHAR(25), + usetype VARCHAR(25), + active SMALLINT, description VARCHAR(250), accessdesc VARCHAR(250), comments VARCHAR(250), - symbology fieldseeker.linelocation_locationsymbology_enum, + symbology VARCHAR(10), externalid VARCHAR(50), acres DOUBLE PRECISION, nextactiondatescheduled TIMESTAMP, @@ -623,148 +287,79 @@ CREATE TABLE fieldseeker.linelocation ( length_meters DOUBLE PRECISION, width_meters DOUBLE PRECISION, lastinspectconditions VARCHAR(250), - waterorigin fieldseeker.linelocation_linelocation_waterorigin_84723d92_306a_46f4_8ef1_69b55a916008_enum, + waterorigin VARCHAR(50), creationdate TIMESTAMP, creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), jurisdiction VARCHAR(25), shape__length DOUBLE PRECISION, + geometry JSONB NOT NULL, + geospatial GEOMETRY(LINESTRING, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.linelocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.linelocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.linelocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.linelocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.linelocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.linelocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.linelocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.linelocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.linelocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.linelocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.linelocation.symbology IS 'Symbology'; -COMMENT ON COLUMN fieldseeker.linelocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.linelocation.acres IS 'Acres'; -COMMENT ON COLUMN fieldseeker.linelocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.linelocation.larvinspectinterval IS 'Larval Inspection Interval'; -COMMENT ON COLUMN fieldseeker.linelocation.length_ft IS 'Length'; -COMMENT ON COLUMN fieldseeker.linelocation.width_ft IS 'Width'; -COMMENT ON COLUMN fieldseeker.linelocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectbreeding IS 'Last Inspection Breeding'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectavglarvae IS 'Last Inspection Average Larvae'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectavgpupae IS 'Last Inspection Average Pupae'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectlstages IS 'Last Inspection Larval Stages'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectactiontaken IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectfieldspecies IS 'Last Inspection Field Species'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.linelocation.hectares IS 'Hectares'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectactivity IS 'Last Inspection Activity'; -COMMENT ON COLUMN fieldseeker.linelocation.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.linelocation.length_meters IS 'Length Meters'; -COMMENT ON COLUMN fieldseeker.linelocation.width_meters IS 'Width Meters'; -COMMENT ON COLUMN fieldseeker.linelocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.linelocation.waterorigin IS 'Water Origin'; -COMMENT ON COLUMN fieldseeker.linelocation.jurisdiction IS 'Jurisdiction'; +COMMENT ON COLUMN fieldseeker.linelocation.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.linelocation.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.linelocation.habitat IS 'Original attribute from ArcGIS API is HABITAT'; +COMMENT ON COLUMN fieldseeker.linelocation.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.linelocation.usetype IS 'Original attribute from ArcGIS API is USETYPE'; +COMMENT ON COLUMN fieldseeker.linelocation.active IS 'Original attribute from ArcGIS API is ACTIVE'; +COMMENT ON COLUMN fieldseeker.linelocation.description IS 'Original attribute from ArcGIS API is DESCRIPTION'; +COMMENT ON COLUMN fieldseeker.linelocation.accessdesc IS 'Original attribute from ArcGIS API is ACCESSDESC'; +COMMENT ON COLUMN fieldseeker.linelocation.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.linelocation.symbology IS 'Original attribute from ArcGIS API is SYMBOLOGY'; +COMMENT ON COLUMN fieldseeker.linelocation.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.linelocation.acres IS 'Original attribute from ArcGIS API is ACRES'; +COMMENT ON COLUMN fieldseeker.linelocation.nextactiondatescheduled IS 'Original attribute from ArcGIS API is NEXTACTIONDATESCHEDULED'; +COMMENT ON COLUMN fieldseeker.linelocation.larvinspectinterval IS 'Original attribute from ArcGIS API is LARVINSPECTINTERVAL'; +COMMENT ON COLUMN fieldseeker.linelocation.length_ft IS 'Original attribute from ArcGIS API is LENGTH_FT'; +COMMENT ON COLUMN fieldseeker.linelocation.width_ft IS 'Original attribute from ArcGIS API is WIDTH_FT'; +COMMENT ON COLUMN fieldseeker.linelocation.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.linelocation.locationnumber IS 'Original attribute from ArcGIS API is LOCATIONNUMBER'; +COMMENT ON COLUMN fieldseeker.linelocation.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.linelocation.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.linelocation.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.linelocation.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.linelocation.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectdate IS 'Original attribute from ArcGIS API is LASTINSPECTDATE'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectbreeding IS 'Original attribute from ArcGIS API is LASTINSPECTBREEDING'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectavglarvae IS 'Original attribute from ArcGIS API is LASTINSPECTAVGLARVAE'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectavgpupae IS 'Original attribute from ArcGIS API is LASTINSPECTAVGPUPAE'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectlstages IS 'Original attribute from ArcGIS API is LASTINSPECTLSTAGES'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectactiontaken IS 'Original attribute from ArcGIS API is LASTINSPECTACTIONTAKEN'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectfieldspecies IS 'Original attribute from ArcGIS API is LASTINSPECTFIELDSPECIES'; +COMMENT ON COLUMN fieldseeker.linelocation.lasttreatdate IS 'Original attribute from ArcGIS API is LASTTREATDATE'; +COMMENT ON COLUMN fieldseeker.linelocation.lasttreatproduct IS 'Original attribute from ArcGIS API is LASTTREATPRODUCT'; +COMMENT ON COLUMN fieldseeker.linelocation.lasttreatqty IS 'Original attribute from ArcGIS API is LASTTREATQTY'; +COMMENT ON COLUMN fieldseeker.linelocation.lasttreatqtyunit IS 'Original attribute from ArcGIS API is LASTTREATQTYUNIT'; +COMMENT ON COLUMN fieldseeker.linelocation.hectares IS 'Original attribute from ArcGIS API is HECTARES'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectactivity IS 'Original attribute from ArcGIS API is LASTINSPECTACTIVITY'; +COMMENT ON COLUMN fieldseeker.linelocation.lasttreatactivity IS 'Original attribute from ArcGIS API is LASTTREATACTIVITY'; +COMMENT ON COLUMN fieldseeker.linelocation.length_meters IS 'Original attribute from ArcGIS API is LENGTH_METERS'; +COMMENT ON COLUMN fieldseeker.linelocation.width_meters IS 'Original attribute from ArcGIS API is WIDTH_METERS'; +COMMENT ON COLUMN fieldseeker.linelocation.lastinspectconditions IS 'Original attribute from ArcGIS API is LASTINSPECTCONDITIONS'; +COMMENT ON COLUMN fieldseeker.linelocation.waterorigin IS 'Original attribute from ArcGIS API is WATERORIGIN'; +COMMENT ON COLUMN fieldseeker.linelocation.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.linelocation.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.linelocation.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.linelocation.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.linelocation.jurisdiction IS 'Original attribute from ArcGIS API is JURISDICTION'; +COMMENT ON COLUMN fieldseeker.linelocation.shape__length IS 'Original attribute from ArcGIS API is Shape__Length'; --- Field active has default value: 1 - --- Field symbology has default value: 'NONE' - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_linelocation_versioned(bigint, varchar, varchar, fieldseeker.linelocation_linelocation_habitat_fc51bdc4f1954df58206d69ce14182f3_enum, fieldseeker.linelocation_locationpriority_enum, fieldseeker.linelocation_linelocation_usetype_2aeca2e60d2f455c86fc34895dc80a02_enum, fieldseeker.linelocation_notinuit_f_enum, varchar, varchar, varchar, fieldseeker.linelocation_locationsymbology_enum, varchar, double precision, timestamp, smallint, double precision, double precision, varchar, integer, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, double precision, double precision, varchar, varchar, varchar, timestamp, varchar, double precision, varchar, double precision, varchar, varchar, double precision, double precision, varchar, fieldseeker.linelocation_linelocation_waterorigin_84723d92_306a_46f4_8ef1_69b55a916008_enum, timestamp, varchar, timestamp, varchar, varchar, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.linelocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.linelocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.linelocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, acres, nextactiondatescheduled, larvinspectinterval, length_ft, width_ft, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, hectares, lastinspectactivity, lasttreatactivity, length_meters, width_meters, lastinspectconditions, waterorigin, creationdate, creator, editdate, editor, jurisdiction, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.symbology IS NOT DISTINCT FROM $11 AND - lv.externalid IS NOT DISTINCT FROM $12 AND - lv.acres IS NOT DISTINCT FROM $13 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $14 AND - lv.larvinspectinterval IS NOT DISTINCT FROM $15 AND - lv.length_ft IS NOT DISTINCT FROM $16 AND - lv.width_ft IS NOT DISTINCT FROM $17 AND - lv.zone2 IS NOT DISTINCT FROM $18 AND - lv.locationnumber IS NOT DISTINCT FROM $19 AND - lv.globalid IS NOT DISTINCT FROM $20 AND - lv.created_user IS NOT DISTINCT FROM $21 AND - lv.created_date IS NOT DISTINCT FROM $22 AND - lv.last_edited_user IS NOT DISTINCT FROM $23 AND - lv.last_edited_date IS NOT DISTINCT FROM $24 AND - lv.lastinspectdate IS NOT DISTINCT FROM $25 AND - lv.lastinspectbreeding IS NOT DISTINCT FROM $26 AND - lv.lastinspectavglarvae IS NOT DISTINCT FROM $27 AND - lv.lastinspectavgpupae IS NOT DISTINCT FROM $28 AND - lv.lastinspectlstages IS NOT DISTINCT FROM $29 AND - lv.lastinspectactiontaken IS NOT DISTINCT FROM $30 AND - lv.lastinspectfieldspecies IS NOT DISTINCT FROM $31 AND - lv.lasttreatdate IS NOT DISTINCT FROM $32 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $33 AND - lv.lasttreatqty IS NOT DISTINCT FROM $34 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $35 AND - lv.hectares IS NOT DISTINCT FROM $36 AND - lv.lastinspectactivity IS NOT DISTINCT FROM $37 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $38 AND - lv.length_meters IS NOT DISTINCT FROM $39 AND - lv.width_meters IS NOT DISTINCT FROM $40 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $41 AND - lv.waterorigin IS NOT DISTINCT FROM $42 AND - lv.creationdate IS NOT DISTINCT FROM $43 AND - lv.creator IS NOT DISTINCT FROM $44 AND - lv.editdate IS NOT DISTINCT FROM $45 AND - lv.editor IS NOT DISTINCT FROM $46 AND - lv.jurisdiction IS NOT DISTINCT FROM $47 AND - lv.shape__length IS NOT DISTINCT FROM $48 - ) -RETURNING *; - --- Example usage: EXECUTE insert_linelocation_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.LocationTracking +-- Table definition for fieldseeker.locationtracking -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; CREATE TABLE fieldseeker.locationtracking ( objectid BIGSERIAL NOT NULL, + accuracy DOUBLE PRECISION, created_user VARCHAR(255), created_date TIMESTAMP, @@ -776,204 +371,68 @@ CREATE TABLE fieldseeker.locationtracking ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.locationtracking.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.locationtracking.accuracy IS 'Accuracy(m)'; -COMMENT ON COLUMN fieldseeker.locationtracking.fieldtech IS 'Field Tech'; +COMMENT ON COLUMN fieldseeker.locationtracking.accuracy IS 'Original attribute from ArcGIS API is Accuracy'; +COMMENT ON COLUMN fieldseeker.locationtracking.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.locationtracking.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.locationtracking.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.locationtracking.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.locationtracking.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.locationtracking.fieldtech IS 'Original attribute from ArcGIS API is FIELDTECH'; +COMMENT ON COLUMN fieldseeker.locationtracking.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.locationtracking.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.locationtracking.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.locationtracking.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_locationtracking_versioned(bigint, double precision, varchar, timestamp, varchar, timestamp, uuid, varchar, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.locationtracking - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.locationtracking - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.locationtracking ( - objectid, accuracy, created_user, created_date, last_edited_user, last_edited_date, globalid, fieldtech, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.accuracy IS NOT DISTINCT FROM $2 AND - lv.created_user IS NOT DISTINCT FROM $3 AND - lv.created_date IS NOT DISTINCT FROM $4 AND - lv.last_edited_user IS NOT DISTINCT FROM $5 AND - lv.last_edited_date IS NOT DISTINCT FROM $6 AND - lv.globalid IS NOT DISTINCT FROM $7 AND - lv.fieldtech IS NOT DISTINCT FROM $8 AND - lv.creationdate IS NOT DISTINCT FROM $9 AND - lv.creator IS NOT DISTINCT FROM $10 AND - lv.editdate IS NOT DISTINCT FROM $11 AND - lv.editor IS NOT DISTINCT FROM $12 - ) -RETURNING *; - --- Example usage: EXECUTE insert_locationtracking_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.MosquitoInspection +-- Table definition for fieldseeker.mosquitoinspection -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_adminaction_b74ae1bb_c98b_40f6_8cfa_40e4fd16c270_enum AS ENUM ( - 'yes', - 'no' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitobreeding_enum AS ENUM ( - 'None', - 'Light', - 'Moderate', - 'Intense' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_domstage_b7a6c36bccde49a292020de4812cf5ae_enum AS ENUM ( - '1', - '2', - '3', - '4', - '5', - '1-2', - '2-3', - '3-4' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_actiontaken_252243d69b0b44ddbdc229c04ec3a8d5_enum AS ENUM ( - 'Treatment', - 'Mechanical or Biological Treatment', - 'Resident Schedule Request', - 'Administrative' -); - -CREATE TYPE fieldseeker.mosquitoinspection_notinuiwinddirection_enum AS ENUM ( - 'N', - 'NE', - 'E', - 'SE', - 'S', - 'SW', - 'W', - 'NW' -); - -CREATE TYPE fieldseeker.mosquitoinspection_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitofieldspecies_enum AS ENUM ( - 'Aedes', - 'Culex' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoactivity_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoadultactivity_enum AS ENUM ( - 'None', - 'Light', - 'Moderate', - 'Intense' -); - -CREATE TYPE fieldseeker.mosquitoinspection_mosquitoinspection_sitecond_db7350bc_81e5_401e_858f_cd3e5e5d8a34_enum AS ENUM ( - 'Dry', - 'Flowing', - 'Maintained', - 'Unmaintained', - 'High Organic', - 'Unknown', - 'Stagnant', - 'Needs Monitoring', - 'Drying Out', - 'Appears Vacant', - 'Entry Denied', - 'Pool Removed', - 'False Pool' -); - CREATE TABLE fieldseeker.mosquitoinspection ( objectid BIGSERIAL NOT NULL, + numdips SMALLINT, - activity fieldseeker.mosquitoinspection_mosquitoactivity_enum, - breeding fieldseeker.mosquitoinspection_mosquitobreeding_enum, + activity VARCHAR(25), + breeding VARCHAR(25), totlarvae SMALLINT, totpupae SMALLINT, eggs SMALLINT, posdips SMALLINT, - adultact fieldseeker.mosquitoinspection_mosquitoadultactivity_enum, + adultact VARCHAR(25), lstages VARCHAR(25), - domstage fieldseeker.mosquitoinspection_mosquitoinspection_domstage_b7a6c36bccde49a292020de4812cf5ae_enum, - actiontaken fieldseeker.mosquitoinspection_mosquitoinspection_actiontaken_252243d69b0b44ddbdc229c04ec3a8d5_enum, + domstage VARCHAR(25), + actiontaken VARCHAR(50), comments VARCHAR(250), avetemp DOUBLE PRECISION, windspeed DOUBLE PRECISION, raingauge DOUBLE PRECISION, startdatetime TIMESTAMP, enddatetime TIMESTAMP, - winddir fieldseeker.mosquitoinspection_notinuiwinddirection_enum, + winddir VARCHAR(3), avglarvae DOUBLE PRECISION, avgpupae DOUBLE PRECISION, - reviewed fieldseeker.mosquitoinspection_notinuit_f_enum, + reviewed SMALLINT, reviewedby VARCHAR(25), revieweddate TIMESTAMP, locationname VARCHAR(25), zone VARCHAR(25), recordstatus SMALLINT, zone2 VARCHAR(25), - personalcontact fieldseeker.mosquitoinspection_notinuit_f_enum, + personalcontact SMALLINT, tirecount SMALLINT, cbcount SMALLINT, containercount SMALLINT, - fieldspecies fieldseeker.mosquitoinspection_mosquitofieldspecies_enum, + fieldspecies VARCHAR(25), globalid UUID, created_user VARCHAR(255), created_date TIMESTAMP, @@ -984,313 +443,105 @@ CREATE TABLE fieldseeker.mosquitoinspection ( polygonlocid UUID, srid UUID, fieldtech VARCHAR(25), - larvaepresent fieldseeker.mosquitoinspection_notinuit_f_enum, - pupaepresent fieldseeker.mosquitoinspection_notinuit_f_enum, + larvaepresent SMALLINT, + pupaepresent SMALLINT, sdid UUID, - sitecond fieldseeker.mosquitoinspection_mosquitoinspection_sitecond_db7350bc_81e5_401e_858f_cd3e5e5d8a34_enum, + sitecond VARCHAR(250), positivecontainercount SMALLINT, creationdate TIMESTAMP, creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), jurisdiction VARCHAR(25), - visualmonitoring fieldseeker.mosquitoinspection_notinuit_f_enum, + visualmonitoring SMALLINT, vmcomments VARCHAR(250), - adminaction fieldseeker.mosquitoinspection_mosquitoinspection_adminaction_b74ae1bb_c98b_40f6_8cfa_40e4fd16c270_enum, + adminaction VARCHAR(256), ptaid UUID, + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.mosquitoinspection.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.numdips IS '# Dips'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.breeding IS 'Breeding'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.totlarvae IS 'Total Larvae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.totpupae IS 'Total Pupae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.eggs IS 'Eggs'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.posdips IS 'Positive Dips'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.adultact IS 'Adult Activity'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.lstages IS 'Larval Stages'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.domstage IS 'Dominant Stage'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.actiontaken IS 'Action'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.avglarvae IS 'Average Larvae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.avgpupae IS 'Average Pupae'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.personalcontact IS 'Personal Contact'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.tirecount IS 'Tire Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.cbcount IS 'Catch Basin Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.containercount IS 'Container Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.fieldspecies IS 'Field Species'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.larvaepresent IS 'Larvae Present'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.pupaepresent IS 'Pupae Present'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.sdid IS 'Storm Drain ID'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.sitecond IS 'Conditions'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.positivecontainercount IS 'Positive Container Count'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.jurisdiction IS 'Jurisdiction'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.visualmonitoring IS 'Visual Monitoring'; -COMMENT ON COLUMN fieldseeker.mosquitoinspection.vmcomments IS 'VM Comments'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.numdips IS 'Original attribute from ArcGIS API is NUMDIPS'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.activity IS 'Original attribute from ArcGIS API is ACTIVITY'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.breeding IS 'Original attribute from ArcGIS API is BREEDING'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.totlarvae IS 'Original attribute from ArcGIS API is TOTLARVAE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.totpupae IS 'Original attribute from ArcGIS API is TOTPUPAE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.eggs IS 'Original attribute from ArcGIS API is EGGS'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.posdips IS 'Original attribute from ArcGIS API is POSDIPS'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.adultact IS 'Original attribute from ArcGIS API is ADULTACT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.lstages IS 'Original attribute from ArcGIS API is LSTAGES'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.domstage IS 'Original attribute from ArcGIS API is DOMSTAGE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.actiontaken IS 'Original attribute from ArcGIS API is ACTIONTAKEN'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.avetemp IS 'Original attribute from ArcGIS API is AVETEMP'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.windspeed IS 'Original attribute from ArcGIS API is WINDSPEED'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.raingauge IS 'Original attribute from ArcGIS API is RAINGAUGE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.startdatetime IS 'Original attribute from ArcGIS API is STARTDATETIME'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.enddatetime IS 'Original attribute from ArcGIS API is ENDDATETIME'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.winddir IS 'Original attribute from ArcGIS API is WINDDIR'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.avglarvae IS 'Original attribute from ArcGIS API is AVGLARVAE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.avgpupae IS 'Original attribute from ArcGIS API is AVGPUPAE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.reviewed IS 'Original attribute from ArcGIS API is REVIEWED'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.reviewedby IS 'Original attribute from ArcGIS API is REVIEWEDBY'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.revieweddate IS 'Original attribute from ArcGIS API is REVIEWEDDATE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.locationname IS 'Original attribute from ArcGIS API is LOCATIONNAME'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.recordstatus IS 'Original attribute from ArcGIS API is RECORDSTATUS'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.personalcontact IS 'Original attribute from ArcGIS API is PERSONALCONTACT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.tirecount IS 'Original attribute from ArcGIS API is TIRECOUNT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.cbcount IS 'Original attribute from ArcGIS API is CBCOUNT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.containercount IS 'Original attribute from ArcGIS API is CONTAINERCOUNT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.fieldspecies IS 'Original attribute from ArcGIS API is FIELDSPECIES'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.linelocid IS 'Original attribute from ArcGIS API is LINELOCID'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.pointlocid IS 'Original attribute from ArcGIS API is POINTLOCID'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.polygonlocid IS 'Original attribute from ArcGIS API is POLYGONLOCID'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.srid IS 'Original attribute from ArcGIS API is SRID'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.fieldtech IS 'Original attribute from ArcGIS API is FIELDTECH'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.larvaepresent IS 'Original attribute from ArcGIS API is LARVAEPRESENT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.pupaepresent IS 'Original attribute from ArcGIS API is PUPAEPRESENT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.sdid IS 'Original attribute from ArcGIS API is SDID'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.sitecond IS 'Original attribute from ArcGIS API is SITECOND'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.positivecontainercount IS 'Original attribute from ArcGIS API is POSITIVECONTAINERCOUNT'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.jurisdiction IS 'Original attribute from ArcGIS API is JURISDICTION'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.visualmonitoring IS 'Original attribute from ArcGIS API is VISUALMONITORING'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.vmcomments IS 'Original attribute from ArcGIS API is VMCOMMENTS'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.adminaction IS 'Original attribute from ArcGIS API is adminAction'; +COMMENT ON COLUMN fieldseeker.mosquitoinspection.ptaid IS 'Original attribute from ArcGIS API is PTAID'; --- Field adminaction has default value: 'no' - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_mosquitoinspection_versioned(bigint, smallint, fieldseeker.mosquitoinspection_mosquitoactivity_enum, fieldseeker.mosquitoinspection_mosquitobreeding_enum, smallint, smallint, smallint, smallint, fieldseeker.mosquitoinspection_mosquitoadultactivity_enum, varchar, fieldseeker.mosquitoinspection_mosquitoinspection_domstage_b7a6c36bccde49a292020de4812cf5ae_enum, fieldseeker.mosquitoinspection_mosquitoinspection_actiontaken_252243d69b0b44ddbdc229c04ec3a8d5_enum, varchar, double precision, double precision, double precision, timestamp, timestamp, fieldseeker.mosquitoinspection_notinuiwinddirection_enum, double precision, double precision, fieldseeker.mosquitoinspection_notinuit_f_enum, varchar, timestamp, varchar, varchar, smallint, varchar, fieldseeker.mosquitoinspection_notinuit_f_enum, smallint, smallint, smallint, fieldseeker.mosquitoinspection_mosquitofieldspecies_enum, uuid, varchar, timestamp, varchar, timestamp, uuid, uuid, uuid, uuid, varchar, fieldseeker.mosquitoinspection_notinuit_f_enum, fieldseeker.mosquitoinspection_notinuit_f_enum, uuid, fieldseeker.mosquitoinspection_mosquitoinspection_sitecond_db7350bc_81e5_401e_858f_cd3e5e5d8a34_enum, smallint, timestamp, varchar, timestamp, varchar, varchar, fieldseeker.mosquitoinspection_notinuit_f_enum, varchar, fieldseeker.mosquitoinspection_mosquitoinspection_adminaction_b74ae1bb_c98b_40f6_8cfa_40e4fd16c270_enum, uuid) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.mosquitoinspection - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.mosquitoinspection - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.mosquitoinspection ( - objectid, numdips, activity, breeding, totlarvae, totpupae, eggs, posdips, adultact, lstages, domstage, actiontaken, comments, avetemp, windspeed, raingauge, startdatetime, enddatetime, winddir, avglarvae, avgpupae, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, personalcontact, tirecount, cbcount, containercount, fieldspecies, globalid, created_user, created_date, last_edited_user, last_edited_date, linelocid, pointlocid, polygonlocid, srid, fieldtech, larvaepresent, pupaepresent, sdid, sitecond, positivecontainercount, creationdate, creator, editdate, editor, jurisdiction, visualmonitoring, vmcomments, adminaction, ptaid, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.numdips IS NOT DISTINCT FROM $2 AND - lv.activity IS NOT DISTINCT FROM $3 AND - lv.breeding IS NOT DISTINCT FROM $4 AND - lv.totlarvae IS NOT DISTINCT FROM $5 AND - lv.totpupae IS NOT DISTINCT FROM $6 AND - lv.eggs IS NOT DISTINCT FROM $7 AND - lv.posdips IS NOT DISTINCT FROM $8 AND - lv.adultact IS NOT DISTINCT FROM $9 AND - lv.lstages IS NOT DISTINCT FROM $10 AND - lv.domstage IS NOT DISTINCT FROM $11 AND - lv.actiontaken IS NOT DISTINCT FROM $12 AND - lv.comments IS NOT DISTINCT FROM $13 AND - lv.avetemp IS NOT DISTINCT FROM $14 AND - lv.windspeed IS NOT DISTINCT FROM $15 AND - lv.raingauge IS NOT DISTINCT FROM $16 AND - lv.startdatetime IS NOT DISTINCT FROM $17 AND - lv.enddatetime IS NOT DISTINCT FROM $18 AND - lv.winddir IS NOT DISTINCT FROM $19 AND - lv.avglarvae IS NOT DISTINCT FROM $20 AND - lv.avgpupae IS NOT DISTINCT FROM $21 AND - lv.reviewed IS NOT DISTINCT FROM $22 AND - lv.reviewedby IS NOT DISTINCT FROM $23 AND - lv.revieweddate IS NOT DISTINCT FROM $24 AND - lv.locationname IS NOT DISTINCT FROM $25 AND - lv.zone IS NOT DISTINCT FROM $26 AND - lv.recordstatus IS NOT DISTINCT FROM $27 AND - lv.zone2 IS NOT DISTINCT FROM $28 AND - lv.personalcontact IS NOT DISTINCT FROM $29 AND - lv.tirecount IS NOT DISTINCT FROM $30 AND - lv.cbcount IS NOT DISTINCT FROM $31 AND - lv.containercount IS NOT DISTINCT FROM $32 AND - lv.fieldspecies IS NOT DISTINCT FROM $33 AND - lv.globalid IS NOT DISTINCT FROM $34 AND - lv.created_user IS NOT DISTINCT FROM $35 AND - lv.created_date IS NOT DISTINCT FROM $36 AND - lv.last_edited_user IS NOT DISTINCT FROM $37 AND - lv.last_edited_date IS NOT DISTINCT FROM $38 AND - lv.linelocid IS NOT DISTINCT FROM $39 AND - lv.pointlocid IS NOT DISTINCT FROM $40 AND - lv.polygonlocid IS NOT DISTINCT FROM $41 AND - lv.srid IS NOT DISTINCT FROM $42 AND - lv.fieldtech IS NOT DISTINCT FROM $43 AND - lv.larvaepresent IS NOT DISTINCT FROM $44 AND - lv.pupaepresent IS NOT DISTINCT FROM $45 AND - lv.sdid IS NOT DISTINCT FROM $46 AND - lv.sitecond IS NOT DISTINCT FROM $47 AND - lv.positivecontainercount IS NOT DISTINCT FROM $48 AND - lv.creationdate IS NOT DISTINCT FROM $49 AND - lv.creator IS NOT DISTINCT FROM $50 AND - lv.editdate IS NOT DISTINCT FROM $51 AND - lv.editor IS NOT DISTINCT FROM $52 AND - lv.jurisdiction IS NOT DISTINCT FROM $53 AND - lv.visualmonitoring IS NOT DISTINCT FROM $54 AND - lv.vmcomments IS NOT DISTINCT FROM $55 AND - lv.adminaction IS NOT DISTINCT FROM $56 AND - lv.ptaid IS NOT DISTINCT FROM $57 - ) -RETURNING *; - --- Example usage: EXECUTE insert_mosquitoinspection_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.PointLocation +-- Table definition for fieldseeker.pointlocation -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.pointlocation_pointlocation_habitat_b4d8135a_4979_49c8_8bb3_67ec7230e661_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetlands', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point' -); - -CREATE TYPE fieldseeker.pointlocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_usetype_58d62d18ef4f47fc8cb9874df867f89e_enum AS ENUM ( - 'residential', - 'commercial', - 'agricultural', - 'industrial', - 'mixed_use', - 'public_domain', - 'natural', - 'municipal' -); - -CREATE TYPE fieldseeker.pointlocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.pointlocation_locationsymbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_waterorigin_197b22bf_f3eb_4dad_8899_986460f6ea97_enum AS ENUM ( - 'flood_irrigation', - 'furrow_irrigation', - 'drip_irrigation', - 'sprinkler_irrigation', - 'wastewater_irrigation', - 'irrigation_runoff', - 'stormwater_or_municipal_runoff', - 'industrial_runoff', - 'rainwater_accumulation', - 'leak', - 'seepage', - 'stored_water', - 'wastewater_system', - 'permanent_natural_water', - 'temporary_natural_water', - 'recreational_or_orenamental_water', - 'water_conveyance' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_assignedtech_9393a162_2474_429d_85be_daa44e4c091f_enum AS ENUM ( - 'Bryan Feguson', - 'Rick Alverez', - 'Alysia Davis', - 'Bryan Ruiz', - 'Kory Wilson', - 'Adrian Sifuentes', - 'Marco Martinez', - 'Carlos Rodriguez', - 'Landon McGill', - 'Ted McGill', - 'Mario Sanchez', - 'Jorge Perez', - 'Arturo Garcia-Trejo', - 'Lisa Salgado', - 'Lawrence Guzman', - 'Tricia Snowden', - 'Ryan Spratt', - 'Andrea Troupin', - 'Mark Nakata', - 'Pablo Ortega', - 'Benjamin Sperry', - 'Fatima Hidalgo', - 'Zackery Barragan', - 'Yajaira Godinez', - 'Jake Maldonado', - 'Rafael Ramirez', - 'Carlos Palacios', - 'Aaron Fredrick', - 'Josh Malone', - 'Alec Caposella', - 'Laura Ramos' -); - -CREATE TYPE fieldseeker.pointlocation_pointlocation_deactivate_reason_dd303085_b33c_4894_8c47_fa847dd9d7c5_enum AS ENUM ( - 'Source Removed', - 'Pool Maintained', - 'Source Screened', - 'Crop Change', - 'Low or No Mosquito Activity', - 'Consistent Fish Presence' -); - CREATE TABLE fieldseeker.pointlocation ( objectid BIGSERIAL NOT NULL, + name VARCHAR(25), zone VARCHAR(25), - habitat fieldseeker.pointlocation_pointlocation_habitat_b4d8135a_4979_49c8_8bb3_67ec7230e661_enum, - priority fieldseeker.pointlocation_locationpriority_enum, - usetype fieldseeker.pointlocation_pointlocation_usetype_58d62d18ef4f47fc8cb9874df867f89e_enum, - active fieldseeker.pointlocation_notinuit_f_enum, + habitat VARCHAR(25), + priority VARCHAR(25), + usetype VARCHAR(25), + active SMALLINT, description VARCHAR(250), accessdesc VARCHAR(250), comments VARCHAR(250), - symbology fieldseeker.pointlocation_locationsymbology_enum, + symbology VARCHAR(10), externalid VARCHAR(50), nextactiondatescheduled TIMESTAMP, larvinspectinterval SMALLINT, @@ -1312,245 +563,90 @@ CREATE TABLE fieldseeker.pointlocation ( lastinspectactivity VARCHAR(25), lasttreatactivity VARCHAR(25), lastinspectconditions VARCHAR(250), - waterorigin fieldseeker.pointlocation_pointlocation_waterorigin_197b22bf_f3eb_4dad_8899_986460f6ea97_enum, + waterorigin VARCHAR(50), x DOUBLE PRECISION, y DOUBLE PRECISION, - assignedtech fieldseeker.pointlocation_pointlocation_assignedtech_9393a162_2474_429d_85be_daa44e4c091f_enum, + assignedtech VARCHAR(256), creationdate TIMESTAMP, creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), jurisdiction VARCHAR(25), - deactivate_reason fieldseeker.pointlocation_pointlocation_deactivate_reason_dd303085_b33c_4894_8c47_fa847dd9d7c5_enum, + deactivate_reason VARCHAR(256), scalarpriority INTEGER, sourcestatus VARCHAR(255), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.pointlocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.pointlocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.pointlocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.pointlocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.pointlocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.pointlocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.pointlocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.pointlocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.pointlocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.pointlocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.pointlocation.symbology IS 'Symbology'; -COMMENT ON COLUMN fieldseeker.pointlocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.pointlocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.pointlocation.larvinspectinterval IS 'Larval Inspection Interval'; -COMMENT ON COLUMN fieldseeker.pointlocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.pointlocation.stype IS 'SourceType'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectbreeding IS 'Last Inspection Breeding'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectavglarvae IS 'Last Inspection Average Larvae'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectavgpupae IS 'Last Inspection Average Pupae'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectlstages IS 'Last Inspection Larval Stages'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectactiontaken IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectfieldspecies IS 'Last Inspection Field Species'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectactivity IS 'Last Inspection Activity'; -COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.pointlocation.waterorigin IS 'Water Origin'; -COMMENT ON COLUMN fieldseeker.pointlocation.assignedtech IS 'Assigned Tech'; -COMMENT ON COLUMN fieldseeker.pointlocation.jurisdiction IS 'Jurisdiction'; -COMMENT ON COLUMN fieldseeker.pointlocation.deactivate_reason IS 'Reason for Deactivation'; +COMMENT ON COLUMN fieldseeker.pointlocation.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.pointlocation.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.pointlocation.habitat IS 'Original attribute from ArcGIS API is HABITAT'; +COMMENT ON COLUMN fieldseeker.pointlocation.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.pointlocation.usetype IS 'Original attribute from ArcGIS API is USETYPE'; +COMMENT ON COLUMN fieldseeker.pointlocation.active IS 'Original attribute from ArcGIS API is ACTIVE'; +COMMENT ON COLUMN fieldseeker.pointlocation.description IS 'Original attribute from ArcGIS API is DESCRIPTION'; +COMMENT ON COLUMN fieldseeker.pointlocation.accessdesc IS 'Original attribute from ArcGIS API is ACCESSDESC'; +COMMENT ON COLUMN fieldseeker.pointlocation.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.pointlocation.symbology IS 'Original attribute from ArcGIS API is SYMBOLOGY'; +COMMENT ON COLUMN fieldseeker.pointlocation.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.pointlocation.nextactiondatescheduled IS 'Original attribute from ArcGIS API is NEXTACTIONDATESCHEDULED'; +COMMENT ON COLUMN fieldseeker.pointlocation.larvinspectinterval IS 'Original attribute from ArcGIS API is LARVINSPECTINTERVAL'; +COMMENT ON COLUMN fieldseeker.pointlocation.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.pointlocation.locationnumber IS 'Original attribute from ArcGIS API is LOCATIONNUMBER'; +COMMENT ON COLUMN fieldseeker.pointlocation.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.pointlocation.stype IS 'Original attribute from ArcGIS API is STYPE'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectdate IS 'Original attribute from ArcGIS API is LASTINSPECTDATE'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectbreeding IS 'Original attribute from ArcGIS API is LASTINSPECTBREEDING'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectavglarvae IS 'Original attribute from ArcGIS API is LASTINSPECTAVGLARVAE'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectavgpupae IS 'Original attribute from ArcGIS API is LASTINSPECTAVGPUPAE'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectlstages IS 'Original attribute from ArcGIS API is LASTINSPECTLSTAGES'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectactiontaken IS 'Original attribute from ArcGIS API is LASTINSPECTACTIONTAKEN'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectfieldspecies IS 'Original attribute from ArcGIS API is LASTINSPECTFIELDSPECIES'; +COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatdate IS 'Original attribute from ArcGIS API is LASTTREATDATE'; +COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatproduct IS 'Original attribute from ArcGIS API is LASTTREATPRODUCT'; +COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatqty IS 'Original attribute from ArcGIS API is LASTTREATQTY'; +COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatqtyunit IS 'Original attribute from ArcGIS API is LASTTREATQTYUNIT'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectactivity IS 'Original attribute from ArcGIS API is LASTINSPECTACTIVITY'; +COMMENT ON COLUMN fieldseeker.pointlocation.lasttreatactivity IS 'Original attribute from ArcGIS API is LASTTREATACTIVITY'; +COMMENT ON COLUMN fieldseeker.pointlocation.lastinspectconditions IS 'Original attribute from ArcGIS API is LASTINSPECTCONDITIONS'; +COMMENT ON COLUMN fieldseeker.pointlocation.waterorigin IS 'Original attribute from ArcGIS API is WATERORIGIN'; +COMMENT ON COLUMN fieldseeker.pointlocation.x IS 'Original attribute from ArcGIS API is X'; +COMMENT ON COLUMN fieldseeker.pointlocation.y IS 'Original attribute from ArcGIS API is Y'; +COMMENT ON COLUMN fieldseeker.pointlocation.assignedtech IS 'Original attribute from ArcGIS API is ASSIGNEDTECH'; +COMMENT ON COLUMN fieldseeker.pointlocation.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.pointlocation.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.pointlocation.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.pointlocation.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.pointlocation.jurisdiction IS 'Original attribute from ArcGIS API is JURISDICTION'; +COMMENT ON COLUMN fieldseeker.pointlocation.deactivate_reason IS 'Original attribute from ArcGIS API is deactivate_reason'; +COMMENT ON COLUMN fieldseeker.pointlocation.scalarpriority IS 'Original attribute from ArcGIS API is scalarPriority'; +COMMENT ON COLUMN fieldseeker.pointlocation.sourcestatus IS 'Original attribute from ArcGIS API is sourceStatus'; --- Field active has default value: 1 - --- Field symbology has default value: 'NONE' - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_pointlocation_versioned(bigint, varchar, varchar, fieldseeker.pointlocation_pointlocation_habitat_b4d8135a_4979_49c8_8bb3_67ec7230e661_enum, fieldseeker.pointlocation_locationpriority_enum, fieldseeker.pointlocation_pointlocation_usetype_58d62d18ef4f47fc8cb9874df867f89e_enum, fieldseeker.pointlocation_notinuit_f_enum, varchar, varchar, varchar, fieldseeker.pointlocation_locationsymbology_enum, varchar, timestamp, smallint, varchar, integer, uuid, varchar, timestamp, varchar, double precision, double precision, varchar, varchar, varchar, timestamp, varchar, double precision, varchar, varchar, varchar, varchar, fieldseeker.pointlocation_pointlocation_waterorigin_197b22bf_f3eb_4dad_8899_986460f6ea97_enum, double precision, double precision, fieldseeker.pointlocation_pointlocation_assignedtech_9393a162_2474_429d_85be_daa44e4c091f_enum, timestamp, varchar, timestamp, varchar, varchar, fieldseeker.pointlocation_pointlocation_deactivate_reason_dd303085_b33c_4894_8c47_fa847dd9d7c5_enum, integer, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.pointlocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.pointlocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.pointlocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, nextactiondatescheduled, larvinspectinterval, zone2, locationnumber, globalid, stype, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, lastinspectactivity, lasttreatactivity, lastinspectconditions, waterorigin, x, y, assignedtech, creationdate, creator, editdate, editor, jurisdiction, deactivate_reason, scalarpriority, sourcestatus, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.symbology IS NOT DISTINCT FROM $11 AND - lv.externalid IS NOT DISTINCT FROM $12 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $13 AND - lv.larvinspectinterval IS NOT DISTINCT FROM $14 AND - lv.zone2 IS NOT DISTINCT FROM $15 AND - lv.locationnumber IS NOT DISTINCT FROM $16 AND - lv.globalid IS NOT DISTINCT FROM $17 AND - lv.stype IS NOT DISTINCT FROM $18 AND - lv.lastinspectdate IS NOT DISTINCT FROM $19 AND - lv.lastinspectbreeding IS NOT DISTINCT FROM $20 AND - lv.lastinspectavglarvae IS NOT DISTINCT FROM $21 AND - lv.lastinspectavgpupae IS NOT DISTINCT FROM $22 AND - lv.lastinspectlstages IS NOT DISTINCT FROM $23 AND - lv.lastinspectactiontaken IS NOT DISTINCT FROM $24 AND - lv.lastinspectfieldspecies IS NOT DISTINCT FROM $25 AND - lv.lasttreatdate IS NOT DISTINCT FROM $26 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $27 AND - lv.lasttreatqty IS NOT DISTINCT FROM $28 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $29 AND - lv.lastinspectactivity IS NOT DISTINCT FROM $30 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $31 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $32 AND - lv.waterorigin IS NOT DISTINCT FROM $33 AND - lv.x IS NOT DISTINCT FROM $34 AND - lv.y IS NOT DISTINCT FROM $35 AND - lv.assignedtech IS NOT DISTINCT FROM $36 AND - lv.creationdate IS NOT DISTINCT FROM $37 AND - lv.creator IS NOT DISTINCT FROM $38 AND - lv.editdate IS NOT DISTINCT FROM $39 AND - lv.editor IS NOT DISTINCT FROM $40 AND - lv.jurisdiction IS NOT DISTINCT FROM $41 AND - lv.deactivate_reason IS NOT DISTINCT FROM $42 AND - lv.scalarpriority IS NOT DISTINCT FROM $43 AND - lv.sourcestatus IS NOT DISTINCT FROM $44 - ) -RETURNING *; - --- Example usage: EXECUTE insert_pointlocation_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.PolygonLocation +-- Table definition for fieldseeker.polygonlocation -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.polygonlocation_polygonlocation_waterorigin_e9018e92_5f47_4ff9_8a7c_b818d848dc7a_enum AS ENUM ( - 'flood_irrigation', - 'furrow_irrigation', - 'drip_irritation', - 'sprinkler_irrigation', - 'wastewater_irrigation', - 'irrigation_runoff', - 'rainwater_accumulation', - 'leak', - 'seepage', - 'stored_water', - 'wastewater_system', - 'permanent_natural_water', - 'temporary_natural_water', - 'recreational_or_ornamental_water', - 'water_conveyance' -); - -CREATE TYPE fieldseeker.polygonlocation_polygonlocation_habitat_45e9dde79ac84d959df8b65ba7d5dafd_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grasses_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetland', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'fountain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'appliance', - 'tires', - 'flooded_structure', - 'low_point', - 'unknown' -); - -CREATE TYPE fieldseeker.polygonlocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.polygonlocation_polygonlocation_usetype_e546154cb9544b9aa8e7b13e8e258b27_enum AS ENUM ( - 'residential', - 'commercial', - 'industrial', - 'agricultural', - 'mixed_use', - 'public_domain', - 'natural', - 'municipal' -); - -CREATE TYPE fieldseeker.polygonlocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.polygonlocation_locationsymbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - CREATE TABLE fieldseeker.polygonlocation ( objectid BIGSERIAL NOT NULL, + name VARCHAR(25), zone VARCHAR(25), - habitat fieldseeker.polygonlocation_polygonlocation_habitat_45e9dde79ac84d959df8b65ba7d5dafd_enum, - priority fieldseeker.polygonlocation_locationpriority_enum, - usetype fieldseeker.polygonlocation_polygonlocation_usetype_e546154cb9544b9aa8e7b13e8e258b27_enum, - active fieldseeker.polygonlocation_notinuit_f_enum, + habitat VARCHAR(25), + priority VARCHAR(25), + usetype VARCHAR(25), + active SMALLINT, description VARCHAR(250), accessdesc VARCHAR(250), comments VARCHAR(250), - symbology fieldseeker.polygonlocation_locationsymbology_enum, + symbology VARCHAR(10), externalid VARCHAR(50), acres DOUBLE PRECISION, nextactiondatescheduled TIMESTAMP, @@ -1573,7 +669,7 @@ CREATE TABLE fieldseeker.polygonlocation ( lastinspectactivity VARCHAR(25), lasttreatactivity VARCHAR(25), lastinspectconditions VARCHAR(250), - waterorigin fieldseeker.polygonlocation_polygonlocation_waterorigin_e9018e92_5f47_4ff9_8a7c_b818d848dc7a_enum, + waterorigin VARCHAR(50), filter VARCHAR(255), creationdate TIMESTAMP, creator VARCHAR(128), @@ -1582,164 +678,66 @@ CREATE TABLE fieldseeker.polygonlocation ( jurisdiction VARCHAR(25), shape__area DOUBLE PRECISION, shape__length DOUBLE PRECISION, + geometry JSONB NOT NULL, + geospatial GEOMETRY(POLYGON, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.polygonlocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.polygonlocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.polygonlocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.polygonlocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.polygonlocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.polygonlocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.polygonlocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.polygonlocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.polygonlocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.polygonlocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.polygonlocation.symbology IS 'Symbology'; -COMMENT ON COLUMN fieldseeker.polygonlocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.polygonlocation.acres IS 'Acres'; -COMMENT ON COLUMN fieldseeker.polygonlocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.polygonlocation.larvinspectinterval IS 'Larval Inspection Interval'; -COMMENT ON COLUMN fieldseeker.polygonlocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectbreeding IS 'Last Inspection Breeding'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectavglarvae IS 'Last Inspection Average Larvae'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectavgpupae IS 'Last Inspection Average Pupae'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectlstages IS 'Last Inspection Larval Stages'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectactiontaken IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectfieldspecies IS 'Last Inspection Field Species'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.polygonlocation.hectares IS 'Hectares'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectactivity IS 'Last Inspection Activity'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.polygonlocation.waterorigin IS 'Water Origin'; -COMMENT ON COLUMN fieldseeker.polygonlocation.jurisdiction IS 'Jurisdiction'; +COMMENT ON COLUMN fieldseeker.polygonlocation.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.polygonlocation.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.polygonlocation.habitat IS 'Original attribute from ArcGIS API is HABITAT'; +COMMENT ON COLUMN fieldseeker.polygonlocation.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.polygonlocation.usetype IS 'Original attribute from ArcGIS API is USETYPE'; +COMMENT ON COLUMN fieldseeker.polygonlocation.active IS 'Original attribute from ArcGIS API is ACTIVE'; +COMMENT ON COLUMN fieldseeker.polygonlocation.description IS 'Original attribute from ArcGIS API is DESCRIPTION'; +COMMENT ON COLUMN fieldseeker.polygonlocation.accessdesc IS 'Original attribute from ArcGIS API is ACCESSDESC'; +COMMENT ON COLUMN fieldseeker.polygonlocation.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.polygonlocation.symbology IS 'Original attribute from ArcGIS API is SYMBOLOGY'; +COMMENT ON COLUMN fieldseeker.polygonlocation.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.polygonlocation.acres IS 'Original attribute from ArcGIS API is ACRES'; +COMMENT ON COLUMN fieldseeker.polygonlocation.nextactiondatescheduled IS 'Original attribute from ArcGIS API is NEXTACTIONDATESCHEDULED'; +COMMENT ON COLUMN fieldseeker.polygonlocation.larvinspectinterval IS 'Original attribute from ArcGIS API is LARVINSPECTINTERVAL'; +COMMENT ON COLUMN fieldseeker.polygonlocation.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.polygonlocation.locationnumber IS 'Original attribute from ArcGIS API is LOCATIONNUMBER'; +COMMENT ON COLUMN fieldseeker.polygonlocation.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectdate IS 'Original attribute from ArcGIS API is LASTINSPECTDATE'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectbreeding IS 'Original attribute from ArcGIS API is LASTINSPECTBREEDING'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectavglarvae IS 'Original attribute from ArcGIS API is LASTINSPECTAVGLARVAE'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectavgpupae IS 'Original attribute from ArcGIS API is LASTINSPECTAVGPUPAE'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectlstages IS 'Original attribute from ArcGIS API is LASTINSPECTLSTAGES'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectactiontaken IS 'Original attribute from ArcGIS API is LASTINSPECTACTIONTAKEN'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectfieldspecies IS 'Original attribute from ArcGIS API is LASTINSPECTFIELDSPECIES'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatdate IS 'Original attribute from ArcGIS API is LASTTREATDATE'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatproduct IS 'Original attribute from ArcGIS API is LASTTREATPRODUCT'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatqty IS 'Original attribute from ArcGIS API is LASTTREATQTY'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatqtyunit IS 'Original attribute from ArcGIS API is LASTTREATQTYUNIT'; +COMMENT ON COLUMN fieldseeker.polygonlocation.hectares IS 'Original attribute from ArcGIS API is HECTARES'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectactivity IS 'Original attribute from ArcGIS API is LASTINSPECTACTIVITY'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lasttreatactivity IS 'Original attribute from ArcGIS API is LASTTREATACTIVITY'; +COMMENT ON COLUMN fieldseeker.polygonlocation.lastinspectconditions IS 'Original attribute from ArcGIS API is LASTINSPECTCONDITIONS'; +COMMENT ON COLUMN fieldseeker.polygonlocation.waterorigin IS 'Original attribute from ArcGIS API is WATERORIGIN'; +COMMENT ON COLUMN fieldseeker.polygonlocation.filter IS 'Original attribute from ArcGIS API is Filter'; +COMMENT ON COLUMN fieldseeker.polygonlocation.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.polygonlocation.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.polygonlocation.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.polygonlocation.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.polygonlocation.jurisdiction IS 'Original attribute from ArcGIS API is JURISDICTION'; +COMMENT ON COLUMN fieldseeker.polygonlocation.shape__area IS 'Original attribute from ArcGIS API is Shape__Area'; +COMMENT ON COLUMN fieldseeker.polygonlocation.shape__length IS 'Original attribute from ArcGIS API is Shape__Length'; --- Field active has default value: 1 - --- Field symbology has default value: 'NONE' - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_polygonlocation_versioned(bigint, varchar, varchar, fieldseeker.polygonlocation_polygonlocation_habitat_45e9dde79ac84d959df8b65ba7d5dafd_enum, fieldseeker.polygonlocation_locationpriority_enum, fieldseeker.polygonlocation_polygonlocation_usetype_e546154cb9544b9aa8e7b13e8e258b27_enum, fieldseeker.polygonlocation_notinuit_f_enum, varchar, varchar, varchar, fieldseeker.polygonlocation_locationsymbology_enum, varchar, double precision, timestamp, smallint, varchar, integer, uuid, timestamp, varchar, double precision, double precision, varchar, varchar, varchar, timestamp, varchar, double precision, varchar, double precision, varchar, varchar, varchar, fieldseeker.polygonlocation_polygonlocation_waterorigin_e9018e92_5f47_4ff9_8a7c_b818d848dc7a_enum, varchar, timestamp, varchar, timestamp, varchar, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.polygonlocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.polygonlocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.polygonlocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, acres, nextactiondatescheduled, larvinspectinterval, zone2, locationnumber, globalid, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, hectares, lastinspectactivity, lasttreatactivity, lastinspectconditions, waterorigin, filter, creationdate, creator, editdate, editor, jurisdiction, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.symbology IS NOT DISTINCT FROM $11 AND - lv.externalid IS NOT DISTINCT FROM $12 AND - lv.acres IS NOT DISTINCT FROM $13 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $14 AND - lv.larvinspectinterval IS NOT DISTINCT FROM $15 AND - lv.zone2 IS NOT DISTINCT FROM $16 AND - lv.locationnumber IS NOT DISTINCT FROM $17 AND - lv.globalid IS NOT DISTINCT FROM $18 AND - lv.lastinspectdate IS NOT DISTINCT FROM $19 AND - lv.lastinspectbreeding IS NOT DISTINCT FROM $20 AND - lv.lastinspectavglarvae IS NOT DISTINCT FROM $21 AND - lv.lastinspectavgpupae IS NOT DISTINCT FROM $22 AND - lv.lastinspectlstages IS NOT DISTINCT FROM $23 AND - lv.lastinspectactiontaken IS NOT DISTINCT FROM $24 AND - lv.lastinspectfieldspecies IS NOT DISTINCT FROM $25 AND - lv.lasttreatdate IS NOT DISTINCT FROM $26 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $27 AND - lv.lasttreatqty IS NOT DISTINCT FROM $28 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $29 AND - lv.hectares IS NOT DISTINCT FROM $30 AND - lv.lastinspectactivity IS NOT DISTINCT FROM $31 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $32 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $33 AND - lv.waterorigin IS NOT DISTINCT FROM $34 AND - lv.filter IS NOT DISTINCT FROM $35 AND - lv.creationdate IS NOT DISTINCT FROM $36 AND - lv.creator IS NOT DISTINCT FROM $37 AND - lv.editdate IS NOT DISTINCT FROM $38 AND - lv.editor IS NOT DISTINCT FROM $39 AND - lv.jurisdiction IS NOT DISTINCT FROM $40 AND - lv.shape__area IS NOT DISTINCT FROM $41 AND - lv.shape__length IS NOT DISTINCT FROM $42 - ) -RETURNING *; - --- Example usage: EXECUTE insert_polygonlocation_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.Pool +-- Table definition for fieldseeker.pool -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.pool_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.pool_pool_testmethod_670efbfba86d41ba8e2d3cab5d749e7f_enum AS ENUM ( - 'RT-PCR' -); - -CREATE TYPE fieldseeker.pool_pool_diseasetested_0f02232949c04c7e8de820b9b515ed97_enum AS ENUM ( - 'WNV', - 'SLEV', - 'WEEV', - 'DENV', - 'ZIKV', - 'CHIKV' -); - -CREATE TYPE fieldseeker.pool_pool_diseasepos_6889f8dd00074874aa726907e78497fa_enum AS ENUM ( - 'WNV', - 'SLEV', - 'WEEV', - 'DENV', - 'ZIKV', - 'CHIKV', - 'WNV/SLEV' -); - -CREATE TYPE fieldseeker.pool_mosquitolabname_enum AS ENUM ( - 'Internal Lab', - 'State Lab' -); - CREATE TABLE fieldseeker.pool ( objectid BIGSERIAL NOT NULL, + trapdata_id UUID, datesent TIMESTAMP, survtech VARCHAR(25), @@ -1747,17 +745,17 @@ CREATE TABLE fieldseeker.pool ( testtech VARCHAR(25), comments VARCHAR(250), sampleid VARCHAR(50), - processed fieldseeker.pool_notinuit_f_enum, + processed SMALLINT, lab_id UUID, - testmethod fieldseeker.pool_pool_testmethod_670efbfba86d41ba8e2d3cab5d749e7f_enum, - diseasetested fieldseeker.pool_pool_diseasetested_0f02232949c04c7e8de820b9b515ed97_enum, - diseasepos fieldseeker.pool_pool_diseasepos_6889f8dd00074874aa726907e78497fa_enum, + testmethod VARCHAR(100), + diseasetested VARCHAR(100), + diseasepos VARCHAR(100), globalid UUID, created_user VARCHAR(255), created_date TIMESTAMP, last_edited_user VARCHAR(255), last_edited_date TIMESTAMP, - lab fieldseeker.pool_mosquitolabname_enum, + lab VARCHAR(25), poolyear SMALLINT, gatewaysync SMALLINT, vectorsurvcollectionid VARCHAR(50), @@ -1767,94 +765,52 @@ CREATE TABLE fieldseeker.pool ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.pool.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.pool.trapdata_id IS 'Trap Data ID'; -COMMENT ON COLUMN fieldseeker.pool.datesent IS 'Date Sent'; -COMMENT ON COLUMN fieldseeker.pool.survtech IS 'Survey Tech'; -COMMENT ON COLUMN fieldseeker.pool.datetested IS 'Date Tested'; -COMMENT ON COLUMN fieldseeker.pool.testtech IS 'Test Tech'; -COMMENT ON COLUMN fieldseeker.pool.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.pool.sampleid IS 'Sample ID'; -COMMENT ON COLUMN fieldseeker.pool.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.pool.testmethod IS 'Test Methods'; -COMMENT ON COLUMN fieldseeker.pool.diseasetested IS 'Diseases Tested'; -COMMENT ON COLUMN fieldseeker.pool.diseasepos IS 'Diseases Positive'; -COMMENT ON COLUMN fieldseeker.pool.poolyear IS 'Pool Year'; -COMMENT ON COLUMN fieldseeker.pool.gatewaysync IS 'Gateway Sync'; +COMMENT ON COLUMN fieldseeker.pool.trapdata_id IS 'Original attribute from ArcGIS API is TRAPDATA_ID'; +COMMENT ON COLUMN fieldseeker.pool.datesent IS 'Original attribute from ArcGIS API is DATESENT'; +COMMENT ON COLUMN fieldseeker.pool.survtech IS 'Original attribute from ArcGIS API is SURVTECH'; +COMMENT ON COLUMN fieldseeker.pool.datetested IS 'Original attribute from ArcGIS API is DATETESTED'; +COMMENT ON COLUMN fieldseeker.pool.testtech IS 'Original attribute from ArcGIS API is TESTTECH'; +COMMENT ON COLUMN fieldseeker.pool.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.pool.sampleid IS 'Original attribute from ArcGIS API is SAMPLEID'; +COMMENT ON COLUMN fieldseeker.pool.processed IS 'Original attribute from ArcGIS API is PROCESSED'; +COMMENT ON COLUMN fieldseeker.pool.lab_id IS 'Original attribute from ArcGIS API is LAB_ID'; +COMMENT ON COLUMN fieldseeker.pool.testmethod IS 'Original attribute from ArcGIS API is TESTMETHOD'; +COMMENT ON COLUMN fieldseeker.pool.diseasetested IS 'Original attribute from ArcGIS API is DISEASETESTED'; +COMMENT ON COLUMN fieldseeker.pool.diseasepos IS 'Original attribute from ArcGIS API is DISEASEPOS'; +COMMENT ON COLUMN fieldseeker.pool.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.pool.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.pool.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.pool.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.pool.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.pool.lab IS 'Original attribute from ArcGIS API is LAB'; +COMMENT ON COLUMN fieldseeker.pool.poolyear IS 'Original attribute from ArcGIS API is POOLYEAR'; +COMMENT ON COLUMN fieldseeker.pool.gatewaysync IS 'Original attribute from ArcGIS API is GATEWAYSYNC'; +COMMENT ON COLUMN fieldseeker.pool.vectorsurvcollectionid IS 'Original attribute from ArcGIS API is VECTORSURVCOLLECTIONID'; +COMMENT ON COLUMN fieldseeker.pool.vectorsurvpoolid IS 'Original attribute from ArcGIS API is VECTORSURVPOOLID'; +COMMENT ON COLUMN fieldseeker.pool.vectorsurvtrapdataid IS 'Original attribute from ArcGIS API is VECTORSURVTRAPDATAID'; +COMMENT ON COLUMN fieldseeker.pool.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.pool.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.pool.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.pool.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_pool_versioned(bigint, uuid, timestamp, varchar, timestamp, varchar, varchar, varchar, fieldseeker.pool_notinuit_f_enum, uuid, fieldseeker.pool_pool_testmethod_670efbfba86d41ba8e2d3cab5d749e7f_enum, fieldseeker.pool_pool_diseasetested_0f02232949c04c7e8de820b9b515ed97_enum, fieldseeker.pool_pool_diseasepos_6889f8dd00074874aa726907e78497fa_enum, uuid, varchar, timestamp, varchar, timestamp, fieldseeker.pool_mosquitolabname_enum, smallint, smallint, varchar, varchar, varchar, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.pool - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.pool - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.pool ( - objectid, trapdata_id, datesent, survtech, datetested, testtech, comments, sampleid, processed, lab_id, testmethod, diseasetested, diseasepos, globalid, created_user, created_date, last_edited_user, last_edited_date, lab, poolyear, gatewaysync, vectorsurvcollectionid, vectorsurvpoolid, vectorsurvtrapdataid, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.trapdata_id IS NOT DISTINCT FROM $2 AND - lv.datesent IS NOT DISTINCT FROM $3 AND - lv.survtech IS NOT DISTINCT FROM $4 AND - lv.datetested IS NOT DISTINCT FROM $5 AND - lv.testtech IS NOT DISTINCT FROM $6 AND - lv.comments IS NOT DISTINCT FROM $7 AND - lv.sampleid IS NOT DISTINCT FROM $8 AND - lv.processed IS NOT DISTINCT FROM $9 AND - lv.lab_id IS NOT DISTINCT FROM $10 AND - lv.testmethod IS NOT DISTINCT FROM $11 AND - lv.diseasetested IS NOT DISTINCT FROM $12 AND - lv.diseasepos IS NOT DISTINCT FROM $13 AND - lv.globalid IS NOT DISTINCT FROM $14 AND - lv.created_user IS NOT DISTINCT FROM $15 AND - lv.created_date IS NOT DISTINCT FROM $16 AND - lv.last_edited_user IS NOT DISTINCT FROM $17 AND - lv.last_edited_date IS NOT DISTINCT FROM $18 AND - lv.lab IS NOT DISTINCT FROM $19 AND - lv.poolyear IS NOT DISTINCT FROM $20 AND - lv.gatewaysync IS NOT DISTINCT FROM $21 AND - lv.vectorsurvcollectionid IS NOT DISTINCT FROM $22 AND - lv.vectorsurvpoolid IS NOT DISTINCT FROM $23 AND - lv.vectorsurvtrapdataid IS NOT DISTINCT FROM $24 AND - lv.creationdate IS NOT DISTINCT FROM $25 AND - lv.creator IS NOT DISTINCT FROM $26 AND - lv.editdate IS NOT DISTINCT FROM $27 AND - lv.editor IS NOT DISTINCT FROM $28 - ) -RETURNING *; - --- Example usage: EXECUTE insert_pool_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.PoolDetail +-- Table definition for fieldseeker.pooldetail -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; CREATE TABLE fieldseeker.pooldetail ( objectid BIGSERIAL NOT NULL, + trapdata_id UUID, pool_id UUID, species VARCHAR(50), @@ -1868,109 +824,53 @@ CREATE TABLE fieldseeker.pooldetail ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.pooldetail.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.pooldetail.trapdata_id IS 'Trap Data ID'; -COMMENT ON COLUMN fieldseeker.pooldetail.pool_id IS 'Pool ID'; -COMMENT ON COLUMN fieldseeker.pooldetail.species IS 'Species'; -COMMENT ON COLUMN fieldseeker.pooldetail.females IS 'Females'; +COMMENT ON COLUMN fieldseeker.pooldetail.trapdata_id IS 'Original attribute from ArcGIS API is TRAPDATA_ID'; +COMMENT ON COLUMN fieldseeker.pooldetail.pool_id IS 'Original attribute from ArcGIS API is POOL_ID'; +COMMENT ON COLUMN fieldseeker.pooldetail.species IS 'Original attribute from ArcGIS API is SPECIES'; +COMMENT ON COLUMN fieldseeker.pooldetail.females IS 'Original attribute from ArcGIS API is FEMALES'; +COMMENT ON COLUMN fieldseeker.pooldetail.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.pooldetail.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.pooldetail.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.pooldetail.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.pooldetail.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.pooldetail.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.pooldetail.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.pooldetail.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.pooldetail.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_pooldetail_versioned(bigint, uuid, uuid, varchar, smallint, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.pooldetail - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.pooldetail - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.pooldetail ( - objectid, trapdata_id, pool_id, species, females, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.trapdata_id IS NOT DISTINCT FROM $2 AND - lv.pool_id IS NOT DISTINCT FROM $3 AND - lv.species IS NOT DISTINCT FROM $4 AND - lv.females IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.creationdate IS NOT DISTINCT FROM $11 AND - lv.creator IS NOT DISTINCT FROM $12 AND - lv.editdate IS NOT DISTINCT FROM $13 AND - lv.editor IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_pooldetail_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.ProposedTreatmentArea +-- Table definition for fieldseeker.proposedtreatmentarea -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.proposedtreatmentarea_mosquitotreatmentmethod_enum AS ENUM ( - 'Argo', - 'ATV', - 'Backpack', - 'Drone', - 'Manual', - 'Truck', - 'ULV', - 'Enhanced_Surveillance' -); - -CREATE TYPE fieldseeker.proposedtreatmentarea_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.proposedtreatmentarea_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - CREATE TABLE fieldseeker.proposedtreatmentarea ( objectid BIGSERIAL NOT NULL, - method fieldseeker.proposedtreatmentarea_mosquitotreatmentmethod_enum, + + method VARCHAR(25), comments VARCHAR(250), zone VARCHAR(25), - reviewed fieldseeker.proposedtreatmentarea_notinuit_f_enum, + reviewed SMALLINT, reviewedby VARCHAR(25), revieweddate TIMESTAMP, zone2 VARCHAR(25), completeddate TIMESTAMP, completedby VARCHAR(25), - completed fieldseeker.proposedtreatmentarea_notinuit_f_enum, - issprayroute fieldseeker.proposedtreatmentarea_notinuit_f_enum, + completed SMALLINT, + issprayroute SMALLINT, name VARCHAR(25), acres DOUBLE PRECISION, globalid UUID, - exported fieldseeker.proposedtreatmentarea_notinuit_f_enum, + exported SMALLINT, targetproduct VARCHAR(25), targetapprate DOUBLE PRECISION, hectares DOUBLE PRECISION, @@ -1979,7 +879,7 @@ CREATE TABLE fieldseeker.proposedtreatmentarea ( lasttreatproduct VARCHAR(25), lasttreatqty DOUBLE PRECISION, lasttreatqtyunit VARCHAR(10), - priority fieldseeker.proposedtreatmentarea_locationpriority_enum, + priority VARCHAR(25), duedate TIMESTAMP, creationdate TIMESTAMP, creator VARCHAR(128), @@ -1988,243 +888,59 @@ CREATE TABLE fieldseeker.proposedtreatmentarea ( targetspecies VARCHAR(250), shape__area DOUBLE PRECISION, shape__length DOUBLE PRECISION, + geometry JSONB NOT NULL, + geospatial GEOMETRY(POLYGON, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.method IS 'Method'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completeddate IS 'Completed Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completedby IS 'Completed By'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completed IS 'Completed'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.issprayroute IS 'Is Spray Route'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.acres IS 'Acres'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetproduct IS 'Target Product'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetapprate IS 'Target App Rate'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.hectares IS 'Hectares'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatactivity IS 'Last Treatment Activity'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatdate IS 'Last Treatment Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatproduct IS 'Last Treatment Product'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatqty IS 'Last Treatment Quantity'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatqtyunit IS 'Last Treatment Quantity Unit'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.duedate IS 'Due Date'; -COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetspecies IS 'Target Species'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.method IS 'Original attribute from ArcGIS API is METHOD'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.reviewed IS 'Original attribute from ArcGIS API is REVIEWED'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.reviewedby IS 'Original attribute from ArcGIS API is REVIEWEDBY'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.revieweddate IS 'Original attribute from ArcGIS API is REVIEWEDDATE'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completeddate IS 'Original attribute from ArcGIS API is COMPLETEDDATE'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completedby IS 'Original attribute from ArcGIS API is COMPLETEDBY'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.completed IS 'Original attribute from ArcGIS API is COMPLETED'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.issprayroute IS 'Original attribute from ArcGIS API is ISSPRAYROUTE'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.acres IS 'Original attribute from ArcGIS API is ACRES'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.exported IS 'Original attribute from ArcGIS API is EXPORTED'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetproduct IS 'Original attribute from ArcGIS API is TARGETPRODUCT'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetapprate IS 'Original attribute from ArcGIS API is TARGETAPPRATE'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.hectares IS 'Original attribute from ArcGIS API is HECTARES'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatactivity IS 'Original attribute from ArcGIS API is LASTTREATACTIVITY'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatdate IS 'Original attribute from ArcGIS API is LASTTREATDATE'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatproduct IS 'Original attribute from ArcGIS API is LASTTREATPRODUCT'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatqty IS 'Original attribute from ArcGIS API is LASTTREATQTY'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.lasttreatqtyunit IS 'Original attribute from ArcGIS API is LASTTREATQTYUNIT'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.duedate IS 'Original attribute from ArcGIS API is DUEDATE'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.targetspecies IS 'Original attribute from ArcGIS API is TARGETSPECIES'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.shape__area IS 'Original attribute from ArcGIS API is Shape__Area'; +COMMENT ON COLUMN fieldseeker.proposedtreatmentarea.shape__length IS 'Original attribute from ArcGIS API is Shape__Length'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_proposedtreatmentarea_versioned(bigint, fieldseeker.proposedtreatmentarea_mosquitotreatmentmethod_enum, varchar, varchar, fieldseeker.proposedtreatmentarea_notinuit_f_enum, varchar, timestamp, varchar, timestamp, varchar, fieldseeker.proposedtreatmentarea_notinuit_f_enum, fieldseeker.proposedtreatmentarea_notinuit_f_enum, varchar, double precision, uuid, fieldseeker.proposedtreatmentarea_notinuit_f_enum, varchar, double precision, double precision, varchar, timestamp, varchar, double precision, varchar, fieldseeker.proposedtreatmentarea_locationpriority_enum, timestamp, timestamp, varchar, timestamp, varchar, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.proposedtreatmentarea - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.proposedtreatmentarea - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.proposedtreatmentarea ( - objectid, method, comments, zone, reviewed, reviewedby, revieweddate, zone2, completeddate, completedby, completed, issprayroute, name, acres, globalid, exported, targetproduct, targetapprate, hectares, lasttreatactivity, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, priority, duedate, creationdate, creator, editdate, editor, targetspecies, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.method IS NOT DISTINCT FROM $2 AND - lv.comments IS NOT DISTINCT FROM $3 AND - lv.zone IS NOT DISTINCT FROM $4 AND - lv.reviewed IS NOT DISTINCT FROM $5 AND - lv.reviewedby IS NOT DISTINCT FROM $6 AND - lv.revieweddate IS NOT DISTINCT FROM $7 AND - lv.zone2 IS NOT DISTINCT FROM $8 AND - lv.completeddate IS NOT DISTINCT FROM $9 AND - lv.completedby IS NOT DISTINCT FROM $10 AND - lv.completed IS NOT DISTINCT FROM $11 AND - lv.issprayroute IS NOT DISTINCT FROM $12 AND - lv.name IS NOT DISTINCT FROM $13 AND - lv.acres IS NOT DISTINCT FROM $14 AND - lv.globalid IS NOT DISTINCT FROM $15 AND - lv.exported IS NOT DISTINCT FROM $16 AND - lv.targetproduct IS NOT DISTINCT FROM $17 AND - lv.targetapprate IS NOT DISTINCT FROM $18 AND - lv.hectares IS NOT DISTINCT FROM $19 AND - lv.lasttreatactivity IS NOT DISTINCT FROM $20 AND - lv.lasttreatdate IS NOT DISTINCT FROM $21 AND - lv.lasttreatproduct IS NOT DISTINCT FROM $22 AND - lv.lasttreatqty IS NOT DISTINCT FROM $23 AND - lv.lasttreatqtyunit IS NOT DISTINCT FROM $24 AND - lv.priority IS NOT DISTINCT FROM $25 AND - lv.duedate IS NOT DISTINCT FROM $26 AND - lv.creationdate IS NOT DISTINCT FROM $27 AND - lv.creator IS NOT DISTINCT FROM $28 AND - lv.editdate IS NOT DISTINCT FROM $29 AND - lv.editor IS NOT DISTINCT FROM $30 AND - lv.targetspecies IS NOT DISTINCT FROM $31 AND - lv.shape__area IS NOT DISTINCT FROM $32 AND - lv.shape__length IS NOT DISTINCT FROM $33 - ) -RETURNING *; - --- Example usage: EXECUTE insert_proposedtreatmentarea_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.QAMosquitoInspection +-- Table definition for fieldseeker.qamosquitoinspection -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.qamosquitoinspection_qalarvaereason_enum AS ENUM ( - 'Missed Area', - 'New Site', - 'Not Visited', - 'Rate Low', - 'Treated Recently', - 'Unknown', - 'Wrong Product' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qaaquaticorganisms_enum AS ENUM ( - 'fish', - 'scuds', - 'snails' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawatermovement_enum AS ENUM ( - 'Fast', - 'Medium', - 'None', - 'Slow', - 'Very Slow' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawaterduration_enum AS ENUM ( - '~month', - '~week', - '<1 week', - 'month', - '>week' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawatersource_enum AS ENUM ( - 'Irrigation', - 'Manually Controlled', - 'Percolation', - 'Rain Runoff', - 'Tidal', - 'Water Table' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_mosquitoaction_enum AS ENUM ( - 'Treatment', - 'Covered container', - 'Cleared debris', - 'Maintenance' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qabreedingpotential_enum AS ENUM ( - 'High', - 'Low', - 'Medium', - 'Rare' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qamosquitohabitat_enum AS ENUM ( - 'Depressions', - 'Detritus present', - 'Fast', - 'Few predators', - 'Fluctuating levels', - 'H20<6"', - 'Low wave potential', - 'No fish', - 'Shallow edges', - 'Still water edges', - 'Still water whole', - 'Veg. on edges' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qavegetation_enum AS ENUM ( - 'Algae', - 'Cattails', - 'Duckweed', - 'Glasswort', - 'Grass on edge', - 'Mangrove', - 'Mosquito fern', - 'Muskgrass', - 'Myriophyllum', - 'Other', - 'Rotting vegetation', - 'Saltwort', - 'Sedges' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qasourcereduction_enum AS ENUM ( - '1 tractor < day', - 'adjust flood irrigation', - 'adjust turf irrigation', - 'clear outflow', - 'cut ditch', - 'hand grading', - 'laser leveling', - 'multiple loads soil', - 'none' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qasoilcondition_enum AS ENUM ( - 'Cracked', - 'Dry', - 'Inundated', - 'Saturated', - 'Surface Moist' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qawaterconditions_enum AS ENUM ( - '"rust" material', - 'Clear', - 'Cloudy/fines', - 'Floating debris', - 'Submerged/decom. debris' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.qamosquitoinspection_qasitetype_enum AS ENUM ( - 'Detention Pond', - 'Ditch', - 'Low Area', - 'Mangrove Edge', - 'Pond', - 'Pond Edge', - 'Swale' -); - CREATE TABLE fieldseeker.qamosquitoinspection ( objectid BIGSERIAL NOT NULL, + posdips SMALLINT, - actiontaken fieldseeker.qamosquitoinspection_mosquitoaction_enum, + actiontaken VARCHAR(250), comments VARCHAR(250), avetemp DOUBLE PRECISION, windspeed DOUBLE PRECISION, @@ -2233,7 +949,7 @@ CREATE TABLE fieldseeker.qamosquitoinspection ( startdatetime TIMESTAMP, enddatetime TIMESTAMP, winddir VARCHAR(3), - reviewed fieldseeker.qamosquitoinspection_notinuit_f_enum, + reviewed SMALLINT, reviewedby VARCHAR(25), revieweddate TIMESTAMP, locationname VARCHAR(25), @@ -2244,34 +960,34 @@ CREATE TABLE fieldseeker.qamosquitoinspection ( negdips SMALLINT, totalacres DOUBLE PRECISION, acresbreeding DOUBLE PRECISION, - fish fieldseeker.qamosquitoinspection_notinuit_f_enum, - sitetype fieldseeker.qamosquitoinspection_qasitetype_enum, - breedingpotential fieldseeker.qamosquitoinspection_qabreedingpotential_enum, - movingwater fieldseeker.qamosquitoinspection_notinuit_f_enum, - nowaterever fieldseeker.qamosquitoinspection_notinuit_f_enum, - mosquitohabitat fieldseeker.qamosquitoinspection_qamosquitohabitat_enum, + fish SMALLINT, + sitetype VARCHAR(250), + breedingpotential VARCHAR(25), + movingwater SMALLINT, + nowaterever SMALLINT, + mosquitohabitat VARCHAR(250), habvalue1 SMALLINT, habvalue1percent SMALLINT, habvalue2 SMALLINT, habvalue2percent SMALLINT, potential SMALLINT, - larvaepresent fieldseeker.qamosquitoinspection_notinuit_f_enum, - larvaeinsidetreatedarea fieldseeker.qamosquitoinspection_notinuit_f_enum, - larvaeoutsidetreatedarea fieldseeker.qamosquitoinspection_notinuit_f_enum, - larvaereason fieldseeker.qamosquitoinspection_qalarvaereason_enum, - aquaticorganisms fieldseeker.qamosquitoinspection_qaaquaticorganisms_enum, - vegetation fieldseeker.qamosquitoinspection_qavegetation_enum, - sourcereduction fieldseeker.qamosquitoinspection_qasourcereduction_enum, - waterpresent fieldseeker.qamosquitoinspection_notinuit_f_enum, - watermovement1 fieldseeker.qamosquitoinspection_qawatermovement_enum, + larvaepresent SMALLINT, + larvaeinsidetreatedarea SMALLINT, + larvaeoutsidetreatedarea SMALLINT, + larvaereason VARCHAR(250), + aquaticorganisms VARCHAR(500), + vegetation VARCHAR(500), + sourcereduction VARCHAR(250), + waterpresent SMALLINT, + watermovement1 VARCHAR(25), watermovement1percent SMALLINT, - watermovement2 fieldseeker.qamosquitoinspection_qawatermovement_enum, + watermovement2 VARCHAR(25), watermovement2percent SMALLINT, - soilconditions fieldseeker.qamosquitoinspection_qasoilcondition_enum, - waterduration fieldseeker.qamosquitoinspection_qawaterduration_enum, - watersource fieldseeker.qamosquitoinspection_qawatersource_enum, - waterconditions fieldseeker.qamosquitoinspection_qawaterconditions_enum, - adultactivity fieldseeker.qamosquitoinspection_notinuit_f_enum, + soilconditions VARCHAR(250), + waterduration VARCHAR(25), + watersource VARCHAR(250), + waterconditions VARCHAR(250), + adultactivity SMALLINT, linelocid UUID, pointlocid UUID, polygonlocid UUID, @@ -2284,201 +1000,97 @@ CREATE TABLE fieldseeker.qamosquitoinspection ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.posdips IS 'Positive Dips'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.actiontaken IS 'Action'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.lr IS 'Landing Rate'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.negdips IS 'Negative Dips'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.totalacres IS 'Total Acres'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.acresbreeding IS 'Acres Breeding'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.fish IS 'Fish Present?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.sitetype IS 'Site Type'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.breedingpotential IS 'Breeding Potential'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.movingwater IS 'Moving Water'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.nowaterever IS 'No Evidence of Water Ever'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.mosquitohabitat IS 'Mosquito Habitat Indicators'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue1 IS 'Habitat Value'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue1percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue2 IS 'Habitat Value'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue2percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.potential IS 'Potential'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaepresent IS 'Larvae Present'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaeinsidetreatedarea IS 'Larvae Inside Treated Area?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaeoutsidetreatedarea IS 'Larvae Outside Treated Area?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaereason IS 'Reason Larvae Present'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.aquaticorganisms IS 'Aquatic Organisms'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.vegetation IS 'Vegetation'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.sourcereduction IS 'Source Reduction'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterpresent IS 'Water Present?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement1 IS 'Water Movement'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement1percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement2 IS 'Water Movement'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement2percent IS '%'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.soilconditions IS 'Soil Conditions'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterduration IS 'How Long Water Present?'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watersource IS 'Water Source'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterconditions IS 'Water Conditions'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.adultactivity IS 'Adult Activity'; -COMMENT ON COLUMN fieldseeker.qamosquitoinspection.fieldtech IS 'Field Tech'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.posdips IS 'Original attribute from ArcGIS API is POSDIPS'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.actiontaken IS 'Original attribute from ArcGIS API is ACTIONTAKEN'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.avetemp IS 'Original attribute from ArcGIS API is AVETEMP'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.windspeed IS 'Original attribute from ArcGIS API is WINDSPEED'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.raingauge IS 'Original attribute from ArcGIS API is RAINGAUGE'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.startdatetime IS 'Original attribute from ArcGIS API is STARTDATETIME'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.enddatetime IS 'Original attribute from ArcGIS API is ENDDATETIME'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.winddir IS 'Original attribute from ArcGIS API is WINDDIR'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.reviewed IS 'Original attribute from ArcGIS API is REVIEWED'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.reviewedby IS 'Original attribute from ArcGIS API is REVIEWEDBY'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.revieweddate IS 'Original attribute from ArcGIS API is REVIEWEDDATE'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.locationname IS 'Original attribute from ArcGIS API is LOCATIONNAME'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.recordstatus IS 'Original attribute from ArcGIS API is RECORDSTATUS'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.lr IS 'Original attribute from ArcGIS API is LR'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.negdips IS 'Original attribute from ArcGIS API is NEGDIPS'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.totalacres IS 'Original attribute from ArcGIS API is TOTALACRES'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.acresbreeding IS 'Original attribute from ArcGIS API is ACRESBREEDING'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.fish IS 'Original attribute from ArcGIS API is FISH'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.sitetype IS 'Original attribute from ArcGIS API is SITETYPE'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.breedingpotential IS 'Original attribute from ArcGIS API is BREEDINGPOTENTIAL'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.movingwater IS 'Original attribute from ArcGIS API is MOVINGWATER'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.nowaterever IS 'Original attribute from ArcGIS API is NOWATEREVER'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.mosquitohabitat IS 'Original attribute from ArcGIS API is MOSQUITOHABITAT'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue1 IS 'Original attribute from ArcGIS API is HABVALUE1'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue1percent IS 'Original attribute from ArcGIS API is HABVALUE1PERCENT'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue2 IS 'Original attribute from ArcGIS API is HABVALUE2'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.habvalue2percent IS 'Original attribute from ArcGIS API is HABVALUE2PERCENT'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.potential IS 'Original attribute from ArcGIS API is POTENTIAL'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaepresent IS 'Original attribute from ArcGIS API is LARVAEPRESENT'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaeinsidetreatedarea IS 'Original attribute from ArcGIS API is LARVAEINSIDETREATEDAREA'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaeoutsidetreatedarea IS 'Original attribute from ArcGIS API is LARVAEOUTSIDETREATEDAREA'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.larvaereason IS 'Original attribute from ArcGIS API is LARVAEREASON'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.aquaticorganisms IS 'Original attribute from ArcGIS API is AQUATICORGANISMS'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.vegetation IS 'Original attribute from ArcGIS API is VEGETATION'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.sourcereduction IS 'Original attribute from ArcGIS API is SOURCEREDUCTION'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterpresent IS 'Original attribute from ArcGIS API is WATERPRESENT'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement1 IS 'Original attribute from ArcGIS API is WATERMOVEMENT1'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement1percent IS 'Original attribute from ArcGIS API is WATERMOVEMENT1PERCENT'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement2 IS 'Original attribute from ArcGIS API is WATERMOVEMENT2'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watermovement2percent IS 'Original attribute from ArcGIS API is WATERMOVEMENT2PERCENT'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.soilconditions IS 'Original attribute from ArcGIS API is SOILCONDITIONS'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterduration IS 'Original attribute from ArcGIS API is WATERDURATION'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.watersource IS 'Original attribute from ArcGIS API is WATERSOURCE'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.waterconditions IS 'Original attribute from ArcGIS API is WATERCONDITIONS'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.adultactivity IS 'Original attribute from ArcGIS API is ADULTACTIVITY'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.linelocid IS 'Original attribute from ArcGIS API is LINELOCID'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.pointlocid IS 'Original attribute from ArcGIS API is POINTLOCID'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.polygonlocid IS 'Original attribute from ArcGIS API is POLYGONLOCID'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.fieldtech IS 'Original attribute from ArcGIS API is FIELDTECH'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.qamosquitoinspection.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_qamosquitoinspection_versioned(bigint, smallint, fieldseeker.qamosquitoinspection_mosquitoaction_enum, varchar, double precision, double precision, double precision, uuid, timestamp, timestamp, varchar, fieldseeker.qamosquitoinspection_notinuit_f_enum, varchar, timestamp, varchar, varchar, smallint, varchar, smallint, smallint, double precision, double precision, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qasitetype_enum, fieldseeker.qamosquitoinspection_qabreedingpotential_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qamosquitohabitat_enum, smallint, smallint, smallint, smallint, smallint, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qalarvaereason_enum, fieldseeker.qamosquitoinspection_qaaquaticorganisms_enum, fieldseeker.qamosquitoinspection_qavegetation_enum, fieldseeker.qamosquitoinspection_qasourcereduction_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, fieldseeker.qamosquitoinspection_qawatermovement_enum, smallint, fieldseeker.qamosquitoinspection_qawatermovement_enum, smallint, fieldseeker.qamosquitoinspection_qasoilcondition_enum, fieldseeker.qamosquitoinspection_qawaterduration_enum, fieldseeker.qamosquitoinspection_qawatersource_enum, fieldseeker.qamosquitoinspection_qawaterconditions_enum, fieldseeker.qamosquitoinspection_notinuit_f_enum, uuid, uuid, uuid, varchar, timestamp, varchar, timestamp, varchar, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.qamosquitoinspection - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.qamosquitoinspection - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.qamosquitoinspection ( - objectid, posdips, actiontaken, comments, avetemp, windspeed, raingauge, globalid, startdatetime, enddatetime, winddir, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, lr, negdips, totalacres, acresbreeding, fish, sitetype, breedingpotential, movingwater, nowaterever, mosquitohabitat, habvalue1, habvalue1percent, habvalue2, habvalue2percent, potential, larvaepresent, larvaeinsidetreatedarea, larvaeoutsidetreatedarea, larvaereason, aquaticorganisms, vegetation, sourcereduction, waterpresent, watermovement1, watermovement1percent, watermovement2, watermovement2percent, soilconditions, waterduration, watersource, waterconditions, adultactivity, linelocid, pointlocid, polygonlocid, created_user, created_date, last_edited_user, last_edited_date, fieldtech, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.posdips IS NOT DISTINCT FROM $2 AND - lv.actiontaken IS NOT DISTINCT FROM $3 AND - lv.comments IS NOT DISTINCT FROM $4 AND - lv.avetemp IS NOT DISTINCT FROM $5 AND - lv.windspeed IS NOT DISTINCT FROM $6 AND - lv.raingauge IS NOT DISTINCT FROM $7 AND - lv.globalid IS NOT DISTINCT FROM $8 AND - lv.startdatetime IS NOT DISTINCT FROM $9 AND - lv.enddatetime IS NOT DISTINCT FROM $10 AND - lv.winddir IS NOT DISTINCT FROM $11 AND - lv.reviewed IS NOT DISTINCT FROM $12 AND - lv.reviewedby IS NOT DISTINCT FROM $13 AND - lv.revieweddate IS NOT DISTINCT FROM $14 AND - lv.locationname IS NOT DISTINCT FROM $15 AND - lv.zone IS NOT DISTINCT FROM $16 AND - lv.recordstatus IS NOT DISTINCT FROM $17 AND - lv.zone2 IS NOT DISTINCT FROM $18 AND - lv.lr IS NOT DISTINCT FROM $19 AND - lv.negdips IS NOT DISTINCT FROM $20 AND - lv.totalacres IS NOT DISTINCT FROM $21 AND - lv.acresbreeding IS NOT DISTINCT FROM $22 AND - lv.fish IS NOT DISTINCT FROM $23 AND - lv.sitetype IS NOT DISTINCT FROM $24 AND - lv.breedingpotential IS NOT DISTINCT FROM $25 AND - lv.movingwater IS NOT DISTINCT FROM $26 AND - lv.nowaterever IS NOT DISTINCT FROM $27 AND - lv.mosquitohabitat IS NOT DISTINCT FROM $28 AND - lv.habvalue1 IS NOT DISTINCT FROM $29 AND - lv.habvalue1percent IS NOT DISTINCT FROM $30 AND - lv.habvalue2 IS NOT DISTINCT FROM $31 AND - lv.habvalue2percent IS NOT DISTINCT FROM $32 AND - lv.potential IS NOT DISTINCT FROM $33 AND - lv.larvaepresent IS NOT DISTINCT FROM $34 AND - lv.larvaeinsidetreatedarea IS NOT DISTINCT FROM $35 AND - lv.larvaeoutsidetreatedarea IS NOT DISTINCT FROM $36 AND - lv.larvaereason IS NOT DISTINCT FROM $37 AND - lv.aquaticorganisms IS NOT DISTINCT FROM $38 AND - lv.vegetation IS NOT DISTINCT FROM $39 AND - lv.sourcereduction IS NOT DISTINCT FROM $40 AND - lv.waterpresent IS NOT DISTINCT FROM $41 AND - lv.watermovement1 IS NOT DISTINCT FROM $42 AND - lv.watermovement1percent IS NOT DISTINCT FROM $43 AND - lv.watermovement2 IS NOT DISTINCT FROM $44 AND - lv.watermovement2percent IS NOT DISTINCT FROM $45 AND - lv.soilconditions IS NOT DISTINCT FROM $46 AND - lv.waterduration IS NOT DISTINCT FROM $47 AND - lv.watersource IS NOT DISTINCT FROM $48 AND - lv.waterconditions IS NOT DISTINCT FROM $49 AND - lv.adultactivity IS NOT DISTINCT FROM $50 AND - lv.linelocid IS NOT DISTINCT FROM $51 AND - lv.pointlocid IS NOT DISTINCT FROM $52 AND - lv.polygonlocid IS NOT DISTINCT FROM $53 AND - lv.created_user IS NOT DISTINCT FROM $54 AND - lv.created_date IS NOT DISTINCT FROM $55 AND - lv.last_edited_user IS NOT DISTINCT FROM $56 AND - lv.last_edited_date IS NOT DISTINCT FROM $57 AND - lv.fieldtech IS NOT DISTINCT FROM $58 AND - lv.creationdate IS NOT DISTINCT FROM $59 AND - lv.creator IS NOT DISTINCT FROM $60 AND - lv.editdate IS NOT DISTINCT FROM $61 AND - lv.editor IS NOT DISTINCT FROM $62 - ) -RETURNING *; - --- Example usage: EXECUTE insert_qamosquitoinspection_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.RodentLocation +-- Table definition for fieldseeker.rodentlocation -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.rodentlocation_notinuit_f_1_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.rodentlocation_rodentlocation_symbology_enum AS ENUM ( - 'ACTION', - 'INACTIVE', - 'NONE' -); - -CREATE TYPE fieldseeker.rodentlocation_rodentlocationhabitat_enum AS ENUM ( - 'Commercial', - 'Industrial', - 'Residential', - 'Wood Pile' -); - -CREATE TYPE fieldseeker.rodentlocation_locationpriority_1_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.rodentlocation_locationusetype_1_enum AS ENUM ( - 'Residential', - 'Commercial', - 'Industrial', - 'Agricultural', - 'Mixed use' -); - CREATE TABLE fieldseeker.rodentlocation ( objectid BIGSERIAL NOT NULL, + locationname VARCHAR(25), zone VARCHAR(25), zone2 VARCHAR(25), - habitat fieldseeker.rodentlocation_rodentlocationhabitat_enum, - priority fieldseeker.rodentlocation_locationpriority_1_enum, - usetype fieldseeker.rodentlocation_locationusetype_1_enum, - active fieldseeker.rodentlocation_notinuit_f_1_enum, + habitat VARCHAR(25), + priority VARCHAR(25), + usetype VARCHAR(25), + active SMALLINT, description VARCHAR(250), accessdesc VARCHAR(250), comments VARCHAR(250), - symbology fieldseeker.rodentlocation_rodentlocation_symbology_enum, + symbology VARCHAR(10), externalid VARCHAR(50), nextactiondatescheduled TIMESTAMP, locationnumber INTEGER, @@ -2497,217 +1109,78 @@ CREATE TABLE fieldseeker.rodentlocation ( editdate TIMESTAMP, editor VARCHAR(128), jurisdiction VARCHAR(25), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.rodentlocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.rodentlocation.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.rodentlocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectdate IS 'Last Inspection Date'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectspecies IS 'Last Inspection Species'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectaction IS 'Last Inspection Action'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectconditions IS 'Last Inspection Conditions'; -COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectrodentevidence IS 'Last Inspection Rodent Evidence'; -COMMENT ON COLUMN fieldseeker.rodentlocation.jurisdiction IS 'Jurisdiction'; +COMMENT ON COLUMN fieldseeker.rodentlocation.locationname IS 'Original attribute from ArcGIS API is LOCATIONNAME'; +COMMENT ON COLUMN fieldseeker.rodentlocation.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.rodentlocation.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.rodentlocation.habitat IS 'Original attribute from ArcGIS API is HABITAT'; +COMMENT ON COLUMN fieldseeker.rodentlocation.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.rodentlocation.usetype IS 'Original attribute from ArcGIS API is USETYPE'; +COMMENT ON COLUMN fieldseeker.rodentlocation.active IS 'Original attribute from ArcGIS API is ACTIVE'; +COMMENT ON COLUMN fieldseeker.rodentlocation.description IS 'Original attribute from ArcGIS API is DESCRIPTION'; +COMMENT ON COLUMN fieldseeker.rodentlocation.accessdesc IS 'Original attribute from ArcGIS API is ACCESSDESC'; +COMMENT ON COLUMN fieldseeker.rodentlocation.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.rodentlocation.symbology IS 'Original attribute from ArcGIS API is SYMBOLOGY'; +COMMENT ON COLUMN fieldseeker.rodentlocation.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.rodentlocation.nextactiondatescheduled IS 'Original attribute from ArcGIS API is NEXTACTIONDATESCHEDULED'; +COMMENT ON COLUMN fieldseeker.rodentlocation.locationnumber IS 'Original attribute from ArcGIS API is LOCATIONNUMBER'; +COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectdate IS 'Original attribute from ArcGIS API is LASTINSPECTDATE'; +COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectspecies IS 'Original attribute from ArcGIS API is LASTINSPECTSPECIES'; +COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectaction IS 'Original attribute from ArcGIS API is LASTINSPECTACTION'; +COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectconditions IS 'Original attribute from ArcGIS API is LASTINSPECTCONDITIONS'; +COMMENT ON COLUMN fieldseeker.rodentlocation.lastinspectrodentevidence IS 'Original attribute from ArcGIS API is LASTINSPECTRODENTEVIDENCE'; +COMMENT ON COLUMN fieldseeker.rodentlocation.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.rodentlocation.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.rodentlocation.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.rodentlocation.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.rodentlocation.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.rodentlocation.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.rodentlocation.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.rodentlocation.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.rodentlocation.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.rodentlocation.jurisdiction IS 'Original attribute from ArcGIS API is JURISDICTION'; --- Field symbology has default value: 'NONE' - --- Field active has default value: 1 - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_rodentlocation_versioned(bigint, varchar, varchar, varchar, fieldseeker.rodentlocation_rodentlocationhabitat_enum, fieldseeker.rodentlocation_locationpriority_1_enum, fieldseeker.rodentlocation_locationusetype_1_enum, fieldseeker.rodentlocation_notinuit_f_1_enum, varchar, varchar, varchar, fieldseeker.rodentlocation_rodentlocation_symbology_enum, varchar, timestamp, integer, timestamp, varchar, varchar, varchar, varchar, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.rodentlocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.rodentlocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.rodentlocation ( - objectid, locationname, zone, zone2, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, nextactiondatescheduled, locationnumber, lastinspectdate, lastinspectspecies, lastinspectaction, lastinspectconditions, lastinspectrodentevidence, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, jurisdiction, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.locationname IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.zone2 IS NOT DISTINCT FROM $4 AND - lv.habitat IS NOT DISTINCT FROM $5 AND - lv.priority IS NOT DISTINCT FROM $6 AND - lv.usetype IS NOT DISTINCT FROM $7 AND - lv.active IS NOT DISTINCT FROM $8 AND - lv.description IS NOT DISTINCT FROM $9 AND - lv.accessdesc IS NOT DISTINCT FROM $10 AND - lv.comments IS NOT DISTINCT FROM $11 AND - lv.symbology IS NOT DISTINCT FROM $12 AND - lv.externalid IS NOT DISTINCT FROM $13 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $14 AND - lv.locationnumber IS NOT DISTINCT FROM $15 AND - lv.lastinspectdate IS NOT DISTINCT FROM $16 AND - lv.lastinspectspecies IS NOT DISTINCT FROM $17 AND - lv.lastinspectaction IS NOT DISTINCT FROM $18 AND - lv.lastinspectconditions IS NOT DISTINCT FROM $19 AND - lv.lastinspectrodentevidence IS NOT DISTINCT FROM $20 AND - lv.globalid IS NOT DISTINCT FROM $21 AND - lv.created_user IS NOT DISTINCT FROM $22 AND - lv.created_date IS NOT DISTINCT FROM $23 AND - lv.last_edited_user IS NOT DISTINCT FROM $24 AND - lv.last_edited_date IS NOT DISTINCT FROM $25 AND - lv.creationdate IS NOT DISTINCT FROM $26 AND - lv.creator IS NOT DISTINCT FROM $27 AND - lv.editdate IS NOT DISTINCT FROM $28 AND - lv.editor IS NOT DISTINCT FROM $29 AND - lv.jurisdiction IS NOT DISTINCT FROM $30 - ) -RETURNING *; - --- Example usage: EXECUTE insert_rodentlocation_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.SampleCollection +-- Table definition for fieldseeker.samplecollection -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.samplecollection_mosquitolabname_enum AS ENUM ( - 'Internal Lab', - 'State Lab' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitosampletype_enum AS ENUM ( - 'Blood', - 'Tissue', - 'Specimen', - 'Carcass' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitosamplecondition_enum AS ENUM ( - 'Usable', - 'Unusable' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitosamplespecies_enum AS ENUM ( - 'Chicken', - 'Wild bird', - 'Horse', - 'Human' -); - -CREATE TYPE fieldseeker.samplecollection_notinuisex_enum AS ENUM ( - 'M', - 'F', - 'U' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitoactivity_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitodisease_enum AS ENUM ( - 'EEE', - 'WNV', - 'Dengue', - 'Zika' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitositecondition_enum AS ENUM ( - 'Dry', - 'Clean', - 'Full', - 'Low' -); - -CREATE TYPE fieldseeker.samplecollection_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.samplecollection_notinuiwinddirection_enum AS ENUM ( - 'N', - 'NE', - 'E', - 'SE', - 'S', - 'SW', - 'W', - 'NW' -); - -CREATE TYPE fieldseeker.samplecollection_mosquitotestmethod_enum AS ENUM ( - 'RAMP', - 'VecTest', - 'ELISA', - 'RT-PCR' -); - CREATE TABLE fieldseeker.samplecollection ( objectid BIGSERIAL NOT NULL, + loc_id UUID, startdatetime TIMESTAMP, enddatetime TIMESTAMP, - sitecond fieldseeker.samplecollection_mosquitositecondition_enum, + sitecond VARCHAR(25), sampleid VARCHAR(25), survtech VARCHAR(25), datesent TIMESTAMP, datetested TIMESTAMP, testtech VARCHAR(25), comments VARCHAR(250), - processed fieldseeker.samplecollection_notinuit_f_enum, - sampletype fieldseeker.samplecollection_mosquitosampletype_enum, - samplecond fieldseeker.samplecollection_mosquitosamplecondition_enum, - species fieldseeker.samplecollection_mosquitosamplespecies_enum, - sex fieldseeker.samplecollection_notinuisex_enum, + processed SMALLINT, + sampletype VARCHAR(25), + samplecond VARCHAR(25), + species VARCHAR(25), + sex VARCHAR(1), avetemp DOUBLE PRECISION, windspeed DOUBLE PRECISION, - winddir fieldseeker.samplecollection_notinuiwinddirection_enum, + winddir VARCHAR(3), raingauge DOUBLE PRECISION, - activity fieldseeker.samplecollection_mosquitoactivity_enum, - testmethod fieldseeker.samplecollection_mosquitotestmethod_enum, - diseasetested fieldseeker.samplecollection_mosquitodisease_enum, - diseasepos fieldseeker.samplecollection_mosquitodisease_enum, - reviewed fieldseeker.samplecollection_notinuit_f_enum, + activity VARCHAR(25), + testmethod VARCHAR(100), + diseasetested VARCHAR(100), + diseasepos VARCHAR(100), + reviewed SMALLINT, reviewedby VARCHAR(25), revieweddate TIMESTAMP, locationname VARCHAR(25), @@ -2719,7 +1192,7 @@ CREATE TABLE fieldseeker.samplecollection ( created_date TIMESTAMP, last_edited_user VARCHAR(255), last_edited_date TIMESTAMP, - lab fieldseeker.samplecollection_mosquitolabname_enum, + lab VARCHAR(25), fieldtech VARCHAR(25), flockid UUID, samplecount SMALLINT, @@ -2729,174 +1202,76 @@ CREATE TABLE fieldseeker.samplecollection ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.samplecollection.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.samplecollection.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.samplecollection.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.samplecollection.sitecond IS 'Conditions'; -COMMENT ON COLUMN fieldseeker.samplecollection.sampleid IS 'Sample ID'; -COMMENT ON COLUMN fieldseeker.samplecollection.survtech IS 'Surveillance Technician'; -COMMENT ON COLUMN fieldseeker.samplecollection.datesent IS 'Sent'; -COMMENT ON COLUMN fieldseeker.samplecollection.datetested IS 'Tested'; -COMMENT ON COLUMN fieldseeker.samplecollection.testtech IS 'Test Technician'; -COMMENT ON COLUMN fieldseeker.samplecollection.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.samplecollection.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.samplecollection.sampletype IS 'Sample Type'; -COMMENT ON COLUMN fieldseeker.samplecollection.samplecond IS 'Sample Condition'; -COMMENT ON COLUMN fieldseeker.samplecollection.species IS 'Species'; -COMMENT ON COLUMN fieldseeker.samplecollection.sex IS 'Sex'; -COMMENT ON COLUMN fieldseeker.samplecollection.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.samplecollection.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.samplecollection.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.samplecollection.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.samplecollection.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.samplecollection.testmethod IS 'Test Method'; -COMMENT ON COLUMN fieldseeker.samplecollection.diseasetested IS 'Disease Tested'; -COMMENT ON COLUMN fieldseeker.samplecollection.diseasepos IS 'Disease Positive'; -COMMENT ON COLUMN fieldseeker.samplecollection.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.samplecollection.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.samplecollection.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.samplecollection.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.samplecollection.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.samplecollection.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.samplecollection.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.samplecollection.lab IS 'Lab'; -COMMENT ON COLUMN fieldseeker.samplecollection.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.samplecollection.samplecount IS 'Sample Count'; -COMMENT ON COLUMN fieldseeker.samplecollection.chickenid IS 'ChickenID'; -COMMENT ON COLUMN fieldseeker.samplecollection.gatewaysync IS 'Gateway Sync'; +COMMENT ON COLUMN fieldseeker.samplecollection.loc_id IS 'Original attribute from ArcGIS API is LOC_ID'; +COMMENT ON COLUMN fieldseeker.samplecollection.startdatetime IS 'Original attribute from ArcGIS API is STARTDATETIME'; +COMMENT ON COLUMN fieldseeker.samplecollection.enddatetime IS 'Original attribute from ArcGIS API is ENDDATETIME'; +COMMENT ON COLUMN fieldseeker.samplecollection.sitecond IS 'Original attribute from ArcGIS API is SITECOND'; +COMMENT ON COLUMN fieldseeker.samplecollection.sampleid IS 'Original attribute from ArcGIS API is SAMPLEID'; +COMMENT ON COLUMN fieldseeker.samplecollection.survtech IS 'Original attribute from ArcGIS API is SURVTECH'; +COMMENT ON COLUMN fieldseeker.samplecollection.datesent IS 'Original attribute from ArcGIS API is DATESENT'; +COMMENT ON COLUMN fieldseeker.samplecollection.datetested IS 'Original attribute from ArcGIS API is DATETESTED'; +COMMENT ON COLUMN fieldseeker.samplecollection.testtech IS 'Original attribute from ArcGIS API is TESTTECH'; +COMMENT ON COLUMN fieldseeker.samplecollection.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.samplecollection.processed IS 'Original attribute from ArcGIS API is PROCESSED'; +COMMENT ON COLUMN fieldseeker.samplecollection.sampletype IS 'Original attribute from ArcGIS API is SAMPLETYPE'; +COMMENT ON COLUMN fieldseeker.samplecollection.samplecond IS 'Original attribute from ArcGIS API is SAMPLECOND'; +COMMENT ON COLUMN fieldseeker.samplecollection.species IS 'Original attribute from ArcGIS API is SPECIES'; +COMMENT ON COLUMN fieldseeker.samplecollection.sex IS 'Original attribute from ArcGIS API is SEX'; +COMMENT ON COLUMN fieldseeker.samplecollection.avetemp IS 'Original attribute from ArcGIS API is AVETEMP'; +COMMENT ON COLUMN fieldseeker.samplecollection.windspeed IS 'Original attribute from ArcGIS API is WINDSPEED'; +COMMENT ON COLUMN fieldseeker.samplecollection.winddir IS 'Original attribute from ArcGIS API is WINDDIR'; +COMMENT ON COLUMN fieldseeker.samplecollection.raingauge IS 'Original attribute from ArcGIS API is RAINGAUGE'; +COMMENT ON COLUMN fieldseeker.samplecollection.activity IS 'Original attribute from ArcGIS API is ACTIVITY'; +COMMENT ON COLUMN fieldseeker.samplecollection.testmethod IS 'Original attribute from ArcGIS API is TESTMETHOD'; +COMMENT ON COLUMN fieldseeker.samplecollection.diseasetested IS 'Original attribute from ArcGIS API is DISEASETESTED'; +COMMENT ON COLUMN fieldseeker.samplecollection.diseasepos IS 'Original attribute from ArcGIS API is DISEASEPOS'; +COMMENT ON COLUMN fieldseeker.samplecollection.reviewed IS 'Original attribute from ArcGIS API is REVIEWED'; +COMMENT ON COLUMN fieldseeker.samplecollection.reviewedby IS 'Original attribute from ArcGIS API is REVIEWEDBY'; +COMMENT ON COLUMN fieldseeker.samplecollection.revieweddate IS 'Original attribute from ArcGIS API is REVIEWEDDATE'; +COMMENT ON COLUMN fieldseeker.samplecollection.locationname IS 'Original attribute from ArcGIS API is LOCATIONNAME'; +COMMENT ON COLUMN fieldseeker.samplecollection.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.samplecollection.recordstatus IS 'Original attribute from ArcGIS API is RECORDSTATUS'; +COMMENT ON COLUMN fieldseeker.samplecollection.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.samplecollection.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.samplecollection.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.samplecollection.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.samplecollection.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.samplecollection.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.samplecollection.lab IS 'Original attribute from ArcGIS API is LAB'; +COMMENT ON COLUMN fieldseeker.samplecollection.fieldtech IS 'Original attribute from ArcGIS API is FIELDTECH'; +COMMENT ON COLUMN fieldseeker.samplecollection.flockid IS 'Original attribute from ArcGIS API is FLOCKID'; +COMMENT ON COLUMN fieldseeker.samplecollection.samplecount IS 'Original attribute from ArcGIS API is SAMPLECOUNT'; +COMMENT ON COLUMN fieldseeker.samplecollection.chickenid IS 'Original attribute from ArcGIS API is CHICKENID'; +COMMENT ON COLUMN fieldseeker.samplecollection.gatewaysync IS 'Original attribute from ArcGIS API is GATEWAYSYNC'; +COMMENT ON COLUMN fieldseeker.samplecollection.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.samplecollection.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.samplecollection.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.samplecollection.editor IS 'Original attribute from ArcGIS API is Editor'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_samplecollection_versioned(bigint, uuid, timestamp, timestamp, fieldseeker.samplecollection_mosquitositecondition_enum, varchar, varchar, timestamp, timestamp, varchar, varchar, fieldseeker.samplecollection_notinuit_f_enum, fieldseeker.samplecollection_mosquitosampletype_enum, fieldseeker.samplecollection_mosquitosamplecondition_enum, fieldseeker.samplecollection_mosquitosamplespecies_enum, fieldseeker.samplecollection_notinuisex_enum, double precision, double precision, fieldseeker.samplecollection_notinuiwinddirection_enum, double precision, fieldseeker.samplecollection_mosquitoactivity_enum, fieldseeker.samplecollection_mosquitotestmethod_enum, fieldseeker.samplecollection_mosquitodisease_enum, fieldseeker.samplecollection_mosquitodisease_enum, fieldseeker.samplecollection_notinuit_f_enum, varchar, timestamp, varchar, varchar, smallint, varchar, uuid, varchar, timestamp, varchar, timestamp, fieldseeker.samplecollection_mosquitolabname_enum, varchar, uuid, smallint, uuid, smallint, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.samplecollection - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.samplecollection - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.samplecollection ( - objectid, loc_id, startdatetime, enddatetime, sitecond, sampleid, survtech, datesent, datetested, testtech, comments, processed, sampletype, samplecond, species, sex, avetemp, windspeed, winddir, raingauge, activity, testmethod, diseasetested, diseasepos, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, lab, fieldtech, flockid, samplecount, chickenid, gatewaysync, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.loc_id IS NOT DISTINCT FROM $2 AND - lv.startdatetime IS NOT DISTINCT FROM $3 AND - lv.enddatetime IS NOT DISTINCT FROM $4 AND - lv.sitecond IS NOT DISTINCT FROM $5 AND - lv.sampleid IS NOT DISTINCT FROM $6 AND - lv.survtech IS NOT DISTINCT FROM $7 AND - lv.datesent IS NOT DISTINCT FROM $8 AND - lv.datetested IS NOT DISTINCT FROM $9 AND - lv.testtech IS NOT DISTINCT FROM $10 AND - lv.comments IS NOT DISTINCT FROM $11 AND - lv.processed IS NOT DISTINCT FROM $12 AND - lv.sampletype IS NOT DISTINCT FROM $13 AND - lv.samplecond IS NOT DISTINCT FROM $14 AND - lv.species IS NOT DISTINCT FROM $15 AND - lv.sex IS NOT DISTINCT FROM $16 AND - lv.avetemp IS NOT DISTINCT FROM $17 AND - lv.windspeed IS NOT DISTINCT FROM $18 AND - lv.winddir IS NOT DISTINCT FROM $19 AND - lv.raingauge IS NOT DISTINCT FROM $20 AND - lv.activity IS NOT DISTINCT FROM $21 AND - lv.testmethod IS NOT DISTINCT FROM $22 AND - lv.diseasetested IS NOT DISTINCT FROM $23 AND - lv.diseasepos IS NOT DISTINCT FROM $24 AND - lv.reviewed IS NOT DISTINCT FROM $25 AND - lv.reviewedby IS NOT DISTINCT FROM $26 AND - lv.revieweddate IS NOT DISTINCT FROM $27 AND - lv.locationname IS NOT DISTINCT FROM $28 AND - lv.zone IS NOT DISTINCT FROM $29 AND - lv.recordstatus IS NOT DISTINCT FROM $30 AND - lv.zone2 IS NOT DISTINCT FROM $31 AND - lv.globalid IS NOT DISTINCT FROM $32 AND - lv.created_user IS NOT DISTINCT FROM $33 AND - lv.created_date IS NOT DISTINCT FROM $34 AND - lv.last_edited_user IS NOT DISTINCT FROM $35 AND - lv.last_edited_date IS NOT DISTINCT FROM $36 AND - lv.lab IS NOT DISTINCT FROM $37 AND - lv.fieldtech IS NOT DISTINCT FROM $38 AND - lv.flockid IS NOT DISTINCT FROM $39 AND - lv.samplecount IS NOT DISTINCT FROM $40 AND - lv.chickenid IS NOT DISTINCT FROM $41 AND - lv.gatewaysync IS NOT DISTINCT FROM $42 AND - lv.creationdate IS NOT DISTINCT FROM $43 AND - lv.creator IS NOT DISTINCT FROM $44 AND - lv.editdate IS NOT DISTINCT FROM $45 AND - lv.editor IS NOT DISTINCT FROM $46 - ) -RETURNING *; - --- Example usage: EXECUTE insert_samplecollection_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.SampleLocation +-- Table definition for fieldseeker.samplelocation -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.samplelocation_locationhabitattype_enum AS ENUM ( - 'Catch basin', - 'Creek', - 'Ditch', - 'Field/Pasture', - 'Pond', - 'Pond fish', - 'Pond marshy', - 'Pond ornamental', - 'Pond retention', - 'Pond sewage', - 'Pond woodland', - 'Tree hole', - 'Swimming pool', - 'Park', - 'Unknown' -); - -CREATE TYPE fieldseeker.samplelocation_locationpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None' -); - -CREATE TYPE fieldseeker.samplelocation_samplelocationusetype_enum AS ENUM ( - 'Flock Site', - 'Dead Bird' -); - -CREATE TYPE fieldseeker.samplelocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - CREATE TABLE fieldseeker.samplelocation ( objectid BIGSERIAL NOT NULL, + name VARCHAR(25), zone VARCHAR(25), - habitat fieldseeker.samplelocation_locationhabitattype_enum, - priority fieldseeker.samplelocation_locationpriority_enum, - usetype fieldseeker.samplelocation_samplelocationusetype_enum, - active fieldseeker.samplelocation_notinuit_f_enum, + habitat VARCHAR(25), + priority VARCHAR(25), + usetype VARCHAR(25), + active SMALLINT, description VARCHAR(250), accessdesc VARCHAR(250), comments VARCHAR(250), @@ -2914,240 +1289,56 @@ CREATE TABLE fieldseeker.samplelocation ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.samplelocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.samplelocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.samplelocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.samplelocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.samplelocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.samplelocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.samplelocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.samplelocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.samplelocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.samplelocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.samplelocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.samplelocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.samplelocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.samplelocation.gatewaysync IS 'Gateway Sync'; +COMMENT ON COLUMN fieldseeker.samplelocation.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.samplelocation.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.samplelocation.habitat IS 'Original attribute from ArcGIS API is HABITAT'; +COMMENT ON COLUMN fieldseeker.samplelocation.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.samplelocation.usetype IS 'Original attribute from ArcGIS API is USETYPE'; +COMMENT ON COLUMN fieldseeker.samplelocation.active IS 'Original attribute from ArcGIS API is ACTIVE'; +COMMENT ON COLUMN fieldseeker.samplelocation.description IS 'Original attribute from ArcGIS API is DESCRIPTION'; +COMMENT ON COLUMN fieldseeker.samplelocation.accessdesc IS 'Original attribute from ArcGIS API is ACCESSDESC'; +COMMENT ON COLUMN fieldseeker.samplelocation.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.samplelocation.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.samplelocation.nextactiondatescheduled IS 'Original attribute from ArcGIS API is NEXTACTIONDATESCHEDULED'; +COMMENT ON COLUMN fieldseeker.samplelocation.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.samplelocation.locationnumber IS 'Original attribute from ArcGIS API is LOCATIONNUMBER'; +COMMENT ON COLUMN fieldseeker.samplelocation.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.samplelocation.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.samplelocation.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.samplelocation.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.samplelocation.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.samplelocation.gatewaysync IS 'Original attribute from ArcGIS API is GATEWAYSYNC'; +COMMENT ON COLUMN fieldseeker.samplelocation.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.samplelocation.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.samplelocation.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.samplelocation.editor IS 'Original attribute from ArcGIS API is Editor'; --- Field active has default value: 1 - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_samplelocation_versioned(bigint, varchar, varchar, fieldseeker.samplelocation_locationhabitattype_enum, fieldseeker.samplelocation_locationpriority_enum, fieldseeker.samplelocation_samplelocationusetype_enum, fieldseeker.samplelocation_notinuit_f_enum, varchar, varchar, varchar, varchar, timestamp, varchar, integer, uuid, varchar, timestamp, varchar, timestamp, smallint, timestamp, varchar, timestamp, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.samplelocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.samplelocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.samplelocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, externalid, nextactiondatescheduled, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, gatewaysync, creationdate, creator, editdate, editor, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.externalid IS NOT DISTINCT FROM $11 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $12 AND - lv.zone2 IS NOT DISTINCT FROM $13 AND - lv.locationnumber IS NOT DISTINCT FROM $14 AND - lv.globalid IS NOT DISTINCT FROM $15 AND - lv.created_user IS NOT DISTINCT FROM $16 AND - lv.created_date IS NOT DISTINCT FROM $17 AND - lv.last_edited_user IS NOT DISTINCT FROM $18 AND - lv.last_edited_date IS NOT DISTINCT FROM $19 AND - lv.gatewaysync IS NOT DISTINCT FROM $20 AND - lv.creationdate IS NOT DISTINCT FROM $21 AND - lv.creator IS NOT DISTINCT FROM $22 AND - lv.editdate IS NOT DISTINCT FROM $23 AND - lv.editor IS NOT DISTINCT FROM $24 - ) -RETURNING *; - --- Example usage: EXECUTE insert_samplelocation_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.ServiceRequest +-- Table definition for fieldseeker.servicerequest -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.servicerequest_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestcontactpreferences_enum AS ENUM ( - 'None', - 'Call', - 'Email', - 'Text' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestrejectedreason_enum AS ENUM ( - 'Distance', - 'Workload' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_spanish_aaa3dc66_9f9a_4527_8ecd_c9f76db33879_enum AS ENUM ( - '0', - '1' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestissues_enum AS ENUM ( - 'Beehive Related', - 'Unsanitary Accumulations', - 'Rooster or Noise', - 'Rats Attracted', - 'Odor', - 'Number of Animals Over Limit', - 'Location', - 'Violation', - 'Inadequate Enclosure', - 'Escaped Animal', - 'Illegal Animal' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestsource_enum AS ENUM ( - 'Phone', - 'Email', - 'Website', - 'Drop-in', - '2025_pools' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestregion_enum AS ENUM ( - 'FL', - 'ID' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_schedule_period_3f40c046_afd1_4abd_8bf4_389650d29a49_enum AS ENUM ( - 'AM', - 'PM' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestpriority_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'Follow up Visit', - 'HTC Response', - 'Disease Activity Response' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_supervisor_eba07b90_c885_4fe6_8080_7aa775403b9a_enum AS ENUM ( - 'Rick Alverez', - 'Bryan Ferguson', - 'Bryan Ruiz', - 'Andrea Troupin', - 'Conlin Reis' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequesttarget_enum AS ENUM ( - 'mosquitofish', - 'neglected pool or spa', - 'standing water', - 'mosquito presence', - 'biting mosquitoes', - 'event', - 'fish', - 'mosquito', - 'source', - 'bird' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_dog_2b95ec97_1286_4fcd_88f4_f0e31113f696_enum AS ENUM ( - '0', - '1', - '2', - '3' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequest_assignedtech_71d0d685_868f_4b7a_87e2_3661a3ee67c5_enum AS ENUM ( - 'Alysia Davis', - 'Alejandra Gill', - 'Andrea Troupin', - 'Brenda Rodriguez', - 'Bryan Ferguson', - 'Bryan Ruiz', - 'Conlin Reis', - 'Carlos Rodriguez', - 'Erick Arriga', - 'Landon McGill', - 'Marco Martinez', - 'Mark Nakata', - 'Mario Sanchez', - 'Juan Pablo Ortega', - 'Ryan Spratt', - 'Ted McGill', - 'Benjamin Sperry', - 'Zachery Barragan', - 'Arturo Garcia-Trejo', - 'Jesus Jolano', - 'Yajaira Godinez', - 'Jake Maldonado', - 'Rafael Ramirez', - 'Lisa Salgado', - 'Kory Wilson', - 'Carlos Palacios', - 'Fatima Hidalgo', - 'Aaron Fredrick', - 'Josh Malone', - 'Jorge Perez', - 'Laura Romos' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequeststatus_enum AS ENUM ( - 'Assigned', - 'Closed', - 'FieldRectified', - 'Open', - 'Rejected', - 'Unverified', - 'Accepted' -); - -CREATE TYPE fieldseeker.servicerequest_servicerequestnextaction_enum AS ENUM ( - 'Night spray', - 'Site visit' -); - CREATE TABLE fieldseeker.servicerequest ( objectid BIGSERIAL NOT NULL, + recdatetime TIMESTAMP, - source fieldseeker.servicerequest_servicerequestsource_enum, + source VARCHAR(25), entrytech VARCHAR(25), - priority fieldseeker.servicerequest_servicerequestpriority_enum, - supervisor fieldseeker.servicerequest_servicerequest_supervisor_eba07b90_c885_4fe6_8080_7aa775403b9a_enum, - assignedtech fieldseeker.servicerequest_servicerequest_assignedtech_71d0d685_868f_4b7a_87e2_3661a3ee67c5_enum, - status fieldseeker.servicerequest_servicerequeststatus_enum, - clranon fieldseeker.servicerequest_notinuit_f_enum, + priority VARCHAR(25), + supervisor VARCHAR(25), + assignedtech VARCHAR(25), + status VARCHAR(25), + clranon SMALLINT, clrfname VARCHAR(25), clrphone1 VARCHAR(25), clrphone2 VARCHAR(25), @@ -3156,21 +1347,21 @@ CREATE TABLE fieldseeker.servicerequest ( clraddr1 VARCHAR(50), clraddr2 VARCHAR(50), clrcity VARCHAR(25), - clrstate fieldseeker.servicerequest_servicerequestregion_enum, + clrstate VARCHAR(25), clrzip VARCHAR(25), clrother VARCHAR(25), - clrcontpref fieldseeker.servicerequest_servicerequestcontactpreferences_enum, + clrcontpref VARCHAR(25), reqcompany VARCHAR(25), reqaddr1 VARCHAR(50), reqaddr2 VARCHAR(50), reqcity VARCHAR(25), - reqstate fieldseeker.servicerequest_servicerequestregion_enum, + reqstate VARCHAR(25), reqzip VARCHAR(25), reqcrossst VARCHAR(25), reqsubdiv VARCHAR(25), reqmapgrid VARCHAR(25), - reqpermission fieldseeker.servicerequest_notinuit_f_enum, - reqtarget fieldseeker.servicerequest_servicerequesttarget_enum, + reqpermission SMALLINT, + reqtarget VARCHAR(25), reqdescr VARCHAR(1000), reqnotesfortech VARCHAR(250), reqnotesforcust VARCHAR(250), @@ -3179,19 +1370,19 @@ CREATE TABLE fieldseeker.servicerequest ( datetimeclosed TIMESTAMP, techclosed VARCHAR(25), sr_number INTEGER, - reviewed fieldseeker.servicerequest_notinuit_f_enum, + reviewed SMALLINT, reviewedby VARCHAR(25), revieweddate TIMESTAMP, - accepted fieldseeker.servicerequest_notinuit_f_enum, + accepted SMALLINT, accepteddate TIMESTAMP, rejectedby VARCHAR(25), rejecteddate TIMESTAMP, - rejectedreason fieldseeker.servicerequest_servicerequestrejectedreason_enum, + rejectedreason VARCHAR(25), duedate TIMESTAMP, acceptedby VARCHAR(25), comments VARCHAR(2500), estcompletedate TIMESTAMP, - nextaction fieldseeker.servicerequest_servicerequestnextaction_enum, + nextaction VARCHAR(25), recordstatus SMALLINT, globalid UUID, created_user VARCHAR(255), @@ -3212,236 +1403,123 @@ CREATE TABLE fieldseeker.servicerequest ( notifieddate TIMESTAMP, scheduled SMALLINT, scheduleddate TIMESTAMP, - dog fieldseeker.servicerequest_servicerequest_dog_2b95ec97_1286_4fcd_88f4_f0e31113f696_enum, - schedule_period fieldseeker.servicerequest_servicerequest_schedule_period_3f40c046_afd1_4abd_8bf4_389650d29a49_enum, + dog INTEGER, + schedule_period VARCHAR(20), schedule_notes VARCHAR(256), - spanish fieldseeker.servicerequest_servicerequest_spanish_aaa3dc66_9f9a_4527_8ecd_c9f76db33879_enum, + spanish INTEGER, creationdate TIMESTAMP, creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), - issuesreported fieldseeker.servicerequest_servicerequestissues_enum, + issuesreported VARCHAR(250), jurisdiction VARCHAR(25), notificationtimestamp VARCHAR(250), zone VARCHAR(50), zone2 VARCHAR(50), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.servicerequest.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.servicerequest.recdatetime IS 'Received'; -COMMENT ON COLUMN fieldseeker.servicerequest.source IS 'Source'; -COMMENT ON COLUMN fieldseeker.servicerequest.entrytech IS 'Entered By'; -COMMENT ON COLUMN fieldseeker.servicerequest.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.servicerequest.supervisor IS 'Supervisor'; -COMMENT ON COLUMN fieldseeker.servicerequest.assignedtech IS 'Assigned To'; -COMMENT ON COLUMN fieldseeker.servicerequest.status IS 'Status'; -COMMENT ON COLUMN fieldseeker.servicerequest.clranon IS 'Anonymous Caller'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrfname IS 'Caller Name'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrphone1 IS 'Caller Phone'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrphone2 IS 'Caller Alternate Phone'; -COMMENT ON COLUMN fieldseeker.servicerequest.clremail IS 'Caller Email'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrcompany IS 'Caller Company'; -COMMENT ON COLUMN fieldseeker.servicerequest.clraddr1 IS 'Caller Address'; -COMMENT ON COLUMN fieldseeker.servicerequest.clraddr2 IS 'Caller Address 2'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrcity IS 'Caller City'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrstate IS 'Caller State'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrzip IS 'Caller ZIP'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrother IS 'Caller Other'; -COMMENT ON COLUMN fieldseeker.servicerequest.clrcontpref IS 'Caller Contact Preference'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqcompany IS 'Request Company'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqaddr1 IS 'Request Address'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqaddr2 IS 'Request Address 2'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqcity IS 'Request City'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqstate IS 'Request State'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqzip IS 'Request ZIP'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqcrossst IS 'Request Cross Street'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqsubdiv IS 'Request Subdivision'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqmapgrid IS 'Request Map Grid'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqpermission IS 'Permission to Enter'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqtarget IS 'Request Target'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqdescr IS 'Request Description'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqnotesfortech IS 'Notes for Field Technician'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqnotesforcust IS 'Notes for Customer'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqfldnotes IS 'Request Field Notes'; -COMMENT ON COLUMN fieldseeker.servicerequest.reqprogramactions IS 'Request Program Actions'; -COMMENT ON COLUMN fieldseeker.servicerequest.datetimeclosed IS 'Closed'; -COMMENT ON COLUMN fieldseeker.servicerequest.techclosed IS 'Closed By'; -COMMENT ON COLUMN fieldseeker.servicerequest.sr_number IS 'SR#'; -COMMENT ON COLUMN fieldseeker.servicerequest.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.servicerequest.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.servicerequest.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.accepted IS 'Accepted'; -COMMENT ON COLUMN fieldseeker.servicerequest.accepteddate IS 'Accepted Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.rejectedby IS 'Rejected By'; -COMMENT ON COLUMN fieldseeker.servicerequest.rejecteddate IS 'Rejected Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.rejectedreason IS 'Rejected Reason'; -COMMENT ON COLUMN fieldseeker.servicerequest.duedate IS 'Due Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.acceptedby IS 'Accepted By'; -COMMENT ON COLUMN fieldseeker.servicerequest.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.servicerequest.estcompletedate IS 'Estimated Completion Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.nextaction IS 'Next Action'; -COMMENT ON COLUMN fieldseeker.servicerequest.recordstatus IS 'Record Status'; -COMMENT ON COLUMN fieldseeker.servicerequest.firstresponsedate IS 'First Response Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.responsedaycount IS 'Response Day Count'; -COMMENT ON COLUMN fieldseeker.servicerequest.allowed IS 'Verify Correct Location'; -COMMENT ON COLUMN fieldseeker.servicerequest.xvalue IS 'Xvalue'; -COMMENT ON COLUMN fieldseeker.servicerequest.yvalue IS 'Yvalue'; -COMMENT ON COLUMN fieldseeker.servicerequest.validx IS 'ValidX'; -COMMENT ON COLUMN fieldseeker.servicerequest.validy IS 'ValidY'; -COMMENT ON COLUMN fieldseeker.servicerequest.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.servicerequest.externalerror IS 'External Error'; -COMMENT ON COLUMN fieldseeker.servicerequest.notified IS 'Notified'; -COMMENT ON COLUMN fieldseeker.servicerequest.notifieddate IS 'Notified Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.scheduled IS 'Scheduled'; -COMMENT ON COLUMN fieldseeker.servicerequest.scheduleddate IS 'Scheduled Date'; -COMMENT ON COLUMN fieldseeker.servicerequest.dog IS 'Dog'; -COMMENT ON COLUMN fieldseeker.servicerequest.schedule_period IS 'Schedule Period'; -COMMENT ON COLUMN fieldseeker.servicerequest.schedule_notes IS 'Schedule Notes'; -COMMENT ON COLUMN fieldseeker.servicerequest.spanish IS 'Prefer speaking Spanish'; -COMMENT ON COLUMN fieldseeker.servicerequest.issuesreported IS 'Issues Reported'; -COMMENT ON COLUMN fieldseeker.servicerequest.jurisdiction IS 'Jurisdiction'; -COMMENT ON COLUMN fieldseeker.servicerequest.notificationtimestamp IS 'Notification Timestamp'; -COMMENT ON COLUMN fieldseeker.servicerequest.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.servicerequest.zone2 IS 'Zone2'; +COMMENT ON COLUMN fieldseeker.servicerequest.recdatetime IS 'Original attribute from ArcGIS API is RECDATETIME'; +COMMENT ON COLUMN fieldseeker.servicerequest.source IS 'Original attribute from ArcGIS API is SOURCE'; +COMMENT ON COLUMN fieldseeker.servicerequest.entrytech IS 'Original attribute from ArcGIS API is ENTRYTECH'; +COMMENT ON COLUMN fieldseeker.servicerequest.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.servicerequest.supervisor IS 'Original attribute from ArcGIS API is SUPERVISOR'; +COMMENT ON COLUMN fieldseeker.servicerequest.assignedtech IS 'Original attribute from ArcGIS API is ASSIGNEDTECH'; +COMMENT ON COLUMN fieldseeker.servicerequest.status IS 'Original attribute from ArcGIS API is STATUS'; +COMMENT ON COLUMN fieldseeker.servicerequest.clranon IS 'Original attribute from ArcGIS API is CLRANON'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrfname IS 'Original attribute from ArcGIS API is CLRFNAME'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrphone1 IS 'Original attribute from ArcGIS API is CLRPHONE1'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrphone2 IS 'Original attribute from ArcGIS API is CLRPHONE2'; +COMMENT ON COLUMN fieldseeker.servicerequest.clremail IS 'Original attribute from ArcGIS API is CLREMAIL'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrcompany IS 'Original attribute from ArcGIS API is CLRCOMPANY'; +COMMENT ON COLUMN fieldseeker.servicerequest.clraddr1 IS 'Original attribute from ArcGIS API is CLRADDR1'; +COMMENT ON COLUMN fieldseeker.servicerequest.clraddr2 IS 'Original attribute from ArcGIS API is CLRADDR2'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrcity IS 'Original attribute from ArcGIS API is CLRCITY'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrstate IS 'Original attribute from ArcGIS API is CLRSTATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrzip IS 'Original attribute from ArcGIS API is CLRZIP'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrother IS 'Original attribute from ArcGIS API is CLROTHER'; +COMMENT ON COLUMN fieldseeker.servicerequest.clrcontpref IS 'Original attribute from ArcGIS API is CLRCONTPREF'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqcompany IS 'Original attribute from ArcGIS API is REQCOMPANY'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqaddr1 IS 'Original attribute from ArcGIS API is REQADDR1'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqaddr2 IS 'Original attribute from ArcGIS API is REQADDR2'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqcity IS 'Original attribute from ArcGIS API is REQCITY'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqstate IS 'Original attribute from ArcGIS API is REQSTATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqzip IS 'Original attribute from ArcGIS API is REQZIP'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqcrossst IS 'Original attribute from ArcGIS API is REQCROSSST'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqsubdiv IS 'Original attribute from ArcGIS API is REQSUBDIV'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqmapgrid IS 'Original attribute from ArcGIS API is REQMAPGRID'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqpermission IS 'Original attribute from ArcGIS API is REQPERMISSION'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqtarget IS 'Original attribute from ArcGIS API is REQTARGET'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqdescr IS 'Original attribute from ArcGIS API is REQDESCR'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqnotesfortech IS 'Original attribute from ArcGIS API is REQNOTESFORTECH'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqnotesforcust IS 'Original attribute from ArcGIS API is REQNOTESFORCUST'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqfldnotes IS 'Original attribute from ArcGIS API is REQFLDNOTES'; +COMMENT ON COLUMN fieldseeker.servicerequest.reqprogramactions IS 'Original attribute from ArcGIS API is REQPROGRAMACTIONS'; +COMMENT ON COLUMN fieldseeker.servicerequest.datetimeclosed IS 'Original attribute from ArcGIS API is DATETIMECLOSED'; +COMMENT ON COLUMN fieldseeker.servicerequest.techclosed IS 'Original attribute from ArcGIS API is TECHCLOSED'; +COMMENT ON COLUMN fieldseeker.servicerequest.sr_number IS 'Original attribute from ArcGIS API is SR_NUMBER'; +COMMENT ON COLUMN fieldseeker.servicerequest.reviewed IS 'Original attribute from ArcGIS API is REVIEWED'; +COMMENT ON COLUMN fieldseeker.servicerequest.reviewedby IS 'Original attribute from ArcGIS API is REVIEWEDBY'; +COMMENT ON COLUMN fieldseeker.servicerequest.revieweddate IS 'Original attribute from ArcGIS API is REVIEWEDDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.accepted IS 'Original attribute from ArcGIS API is ACCEPTED'; +COMMENT ON COLUMN fieldseeker.servicerequest.accepteddate IS 'Original attribute from ArcGIS API is ACCEPTEDDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.rejectedby IS 'Original attribute from ArcGIS API is REJECTEDBY'; +COMMENT ON COLUMN fieldseeker.servicerequest.rejecteddate IS 'Original attribute from ArcGIS API is REJECTEDDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.rejectedreason IS 'Original attribute from ArcGIS API is REJECTEDREASON'; +COMMENT ON COLUMN fieldseeker.servicerequest.duedate IS 'Original attribute from ArcGIS API is DUEDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.acceptedby IS 'Original attribute from ArcGIS API is ACCEPTEDBY'; +COMMENT ON COLUMN fieldseeker.servicerequest.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.servicerequest.estcompletedate IS 'Original attribute from ArcGIS API is ESTCOMPLETEDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.nextaction IS 'Original attribute from ArcGIS API is NEXTACTION'; +COMMENT ON COLUMN fieldseeker.servicerequest.recordstatus IS 'Original attribute from ArcGIS API is RECORDSTATUS'; +COMMENT ON COLUMN fieldseeker.servicerequest.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.servicerequest.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.servicerequest.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.servicerequest.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.servicerequest.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.servicerequest.firstresponsedate IS 'Original attribute from ArcGIS API is FIRSTRESPONSEDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.responsedaycount IS 'Original attribute from ArcGIS API is RESPONSEDAYCOUNT'; +COMMENT ON COLUMN fieldseeker.servicerequest.allowed IS 'Original attribute from ArcGIS API is ALLOWED'; +COMMENT ON COLUMN fieldseeker.servicerequest.xvalue IS 'Original attribute from ArcGIS API is XVALUE'; +COMMENT ON COLUMN fieldseeker.servicerequest.yvalue IS 'Original attribute from ArcGIS API is YVALUE'; +COMMENT ON COLUMN fieldseeker.servicerequest.validx IS 'Original attribute from ArcGIS API is VALIDX'; +COMMENT ON COLUMN fieldseeker.servicerequest.validy IS 'Original attribute from ArcGIS API is VALIDY'; +COMMENT ON COLUMN fieldseeker.servicerequest.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.servicerequest.externalerror IS 'Original attribute from ArcGIS API is EXTERNALERROR'; +COMMENT ON COLUMN fieldseeker.servicerequest.pointlocid IS 'Original attribute from ArcGIS API is POINTLOCID'; +COMMENT ON COLUMN fieldseeker.servicerequest.notified IS 'Original attribute from ArcGIS API is NOTIFIED'; +COMMENT ON COLUMN fieldseeker.servicerequest.notifieddate IS 'Original attribute from ArcGIS API is NOTIFIEDDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.scheduled IS 'Original attribute from ArcGIS API is SCHEDULED'; +COMMENT ON COLUMN fieldseeker.servicerequest.scheduleddate IS 'Original attribute from ArcGIS API is SCHEDULEDDATE'; +COMMENT ON COLUMN fieldseeker.servicerequest.dog IS 'Original attribute from ArcGIS API is DOG'; +COMMENT ON COLUMN fieldseeker.servicerequest.schedule_period IS 'Original attribute from ArcGIS API is schedule_period'; +COMMENT ON COLUMN fieldseeker.servicerequest.schedule_notes IS 'Original attribute from ArcGIS API is schedule_notes'; +COMMENT ON COLUMN fieldseeker.servicerequest.spanish IS 'Original attribute from ArcGIS API is Spanish'; +COMMENT ON COLUMN fieldseeker.servicerequest.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.servicerequest.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.servicerequest.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.servicerequest.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.servicerequest.issuesreported IS 'Original attribute from ArcGIS API is ISSUESREPORTED'; +COMMENT ON COLUMN fieldseeker.servicerequest.jurisdiction IS 'Original attribute from ArcGIS API is JURISDICTION'; +COMMENT ON COLUMN fieldseeker.servicerequest.notificationtimestamp IS 'Original attribute from ArcGIS API is NOTIFICATIONTIMESTAMP'; +COMMENT ON COLUMN fieldseeker.servicerequest.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.servicerequest.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; --- Field dog has default value: 0 - --- Field spanish has default value: 0 - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_servicerequest_versioned(bigint, timestamp, fieldseeker.servicerequest_servicerequestsource_enum, varchar, fieldseeker.servicerequest_servicerequestpriority_enum, fieldseeker.servicerequest_servicerequest_supervisor_eba07b90_c885_4fe6_8080_7aa775403b9a_enum, fieldseeker.servicerequest_servicerequest_assignedtech_71d0d685_868f_4b7a_87e2_3661a3ee67c5_enum, fieldseeker.servicerequest_servicerequeststatus_enum, fieldseeker.servicerequest_notinuit_f_enum, varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar, fieldseeker.servicerequest_servicerequestregion_enum, varchar, varchar, fieldseeker.servicerequest_servicerequestcontactpreferences_enum, varchar, varchar, varchar, varchar, fieldseeker.servicerequest_servicerequestregion_enum, varchar, varchar, varchar, varchar, fieldseeker.servicerequest_notinuit_f_enum, fieldseeker.servicerequest_servicerequesttarget_enum, varchar, varchar, varchar, varchar, varchar, timestamp, varchar, integer, fieldseeker.servicerequest_notinuit_f_enum, varchar, timestamp, fieldseeker.servicerequest_notinuit_f_enum, timestamp, varchar, timestamp, fieldseeker.servicerequest_servicerequestrejectedreason_enum, timestamp, varchar, varchar, timestamp, fieldseeker.servicerequest_servicerequestnextaction_enum, smallint, uuid, varchar, timestamp, varchar, timestamp, timestamp, smallint, varchar, varchar, varchar, varchar, varchar, varchar, varchar, uuid, smallint, timestamp, smallint, timestamp, fieldseeker.servicerequest_servicerequest_dog_2b95ec97_1286_4fcd_88f4_f0e31113f696_enum, fieldseeker.servicerequest_servicerequest_schedule_period_3f40c046_afd1_4abd_8bf4_389650d29a49_enum, varchar, fieldseeker.servicerequest_servicerequest_spanish_aaa3dc66_9f9a_4527_8ecd_c9f76db33879_enum, timestamp, varchar, timestamp, varchar, fieldseeker.servicerequest_servicerequestissues_enum, varchar, varchar, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.servicerequest - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.servicerequest - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.servicerequest ( - objectid, recdatetime, source, entrytech, priority, supervisor, assignedtech, status, clranon, clrfname, clrphone1, clrphone2, clremail, clrcompany, clraddr1, clraddr2, clrcity, clrstate, clrzip, clrother, clrcontpref, reqcompany, reqaddr1, reqaddr2, reqcity, reqstate, reqzip, reqcrossst, reqsubdiv, reqmapgrid, reqpermission, reqtarget, reqdescr, reqnotesfortech, reqnotesforcust, reqfldnotes, reqprogramactions, datetimeclosed, techclosed, sr_number, reviewed, reviewedby, revieweddate, accepted, accepteddate, rejectedby, rejecteddate, rejectedreason, duedate, acceptedby, comments, estcompletedate, nextaction, recordstatus, globalid, created_user, created_date, last_edited_user, last_edited_date, firstresponsedate, responsedaycount, allowed, xvalue, yvalue, validx, validy, externalid, externalerror, pointlocid, notified, notifieddate, scheduled, scheduleddate, dog, schedule_period, schedule_notes, spanish, creationdate, creator, editdate, editor, issuesreported, jurisdiction, notificationtimestamp, zone, zone2, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $80, $81, $82, $83, $84, $85, $86, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.recdatetime IS NOT DISTINCT FROM $2 AND - lv.source IS NOT DISTINCT FROM $3 AND - lv.entrytech IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.supervisor IS NOT DISTINCT FROM $6 AND - lv.assignedtech IS NOT DISTINCT FROM $7 AND - lv.status IS NOT DISTINCT FROM $8 AND - lv.clranon IS NOT DISTINCT FROM $9 AND - lv.clrfname IS NOT DISTINCT FROM $10 AND - lv.clrphone1 IS NOT DISTINCT FROM $11 AND - lv.clrphone2 IS NOT DISTINCT FROM $12 AND - lv.clremail IS NOT DISTINCT FROM $13 AND - lv.clrcompany IS NOT DISTINCT FROM $14 AND - lv.clraddr1 IS NOT DISTINCT FROM $15 AND - lv.clraddr2 IS NOT DISTINCT FROM $16 AND - lv.clrcity IS NOT DISTINCT FROM $17 AND - lv.clrstate IS NOT DISTINCT FROM $18 AND - lv.clrzip IS NOT DISTINCT FROM $19 AND - lv.clrother IS NOT DISTINCT FROM $20 AND - lv.clrcontpref IS NOT DISTINCT FROM $21 AND - lv.reqcompany IS NOT DISTINCT FROM $22 AND - lv.reqaddr1 IS NOT DISTINCT FROM $23 AND - lv.reqaddr2 IS NOT DISTINCT FROM $24 AND - lv.reqcity IS NOT DISTINCT FROM $25 AND - lv.reqstate IS NOT DISTINCT FROM $26 AND - lv.reqzip IS NOT DISTINCT FROM $27 AND - lv.reqcrossst IS NOT DISTINCT FROM $28 AND - lv.reqsubdiv IS NOT DISTINCT FROM $29 AND - lv.reqmapgrid IS NOT DISTINCT FROM $30 AND - lv.reqpermission IS NOT DISTINCT FROM $31 AND - lv.reqtarget IS NOT DISTINCT FROM $32 AND - lv.reqdescr IS NOT DISTINCT FROM $33 AND - lv.reqnotesfortech IS NOT DISTINCT FROM $34 AND - lv.reqnotesforcust IS NOT DISTINCT FROM $35 AND - lv.reqfldnotes IS NOT DISTINCT FROM $36 AND - lv.reqprogramactions IS NOT DISTINCT FROM $37 AND - lv.datetimeclosed IS NOT DISTINCT FROM $38 AND - lv.techclosed IS NOT DISTINCT FROM $39 AND - lv.sr_number IS NOT DISTINCT FROM $40 AND - lv.reviewed IS NOT DISTINCT FROM $41 AND - lv.reviewedby IS NOT DISTINCT FROM $42 AND - lv.revieweddate IS NOT DISTINCT FROM $43 AND - lv.accepted IS NOT DISTINCT FROM $44 AND - lv.accepteddate IS NOT DISTINCT FROM $45 AND - lv.rejectedby IS NOT DISTINCT FROM $46 AND - lv.rejecteddate IS NOT DISTINCT FROM $47 AND - lv.rejectedreason IS NOT DISTINCT FROM $48 AND - lv.duedate IS NOT DISTINCT FROM $49 AND - lv.acceptedby IS NOT DISTINCT FROM $50 AND - lv.comments IS NOT DISTINCT FROM $51 AND - lv.estcompletedate IS NOT DISTINCT FROM $52 AND - lv.nextaction IS NOT DISTINCT FROM $53 AND - lv.recordstatus IS NOT DISTINCT FROM $54 AND - lv.globalid IS NOT DISTINCT FROM $55 AND - lv.created_user IS NOT DISTINCT FROM $56 AND - lv.created_date IS NOT DISTINCT FROM $57 AND - lv.last_edited_user IS NOT DISTINCT FROM $58 AND - lv.last_edited_date IS NOT DISTINCT FROM $59 AND - lv.firstresponsedate IS NOT DISTINCT FROM $60 AND - lv.responsedaycount IS NOT DISTINCT FROM $61 AND - lv.allowed IS NOT DISTINCT FROM $62 AND - lv.xvalue IS NOT DISTINCT FROM $63 AND - lv.yvalue IS NOT DISTINCT FROM $64 AND - lv.validx IS NOT DISTINCT FROM $65 AND - lv.validy IS NOT DISTINCT FROM $66 AND - lv.externalid IS NOT DISTINCT FROM $67 AND - lv.externalerror IS NOT DISTINCT FROM $68 AND - lv.pointlocid IS NOT DISTINCT FROM $69 AND - lv.notified IS NOT DISTINCT FROM $70 AND - lv.notifieddate IS NOT DISTINCT FROM $71 AND - lv.scheduled IS NOT DISTINCT FROM $72 AND - lv.scheduleddate IS NOT DISTINCT FROM $73 AND - lv.dog IS NOT DISTINCT FROM $74 AND - lv.schedule_period IS NOT DISTINCT FROM $75 AND - lv.schedule_notes IS NOT DISTINCT FROM $76 AND - lv.spanish IS NOT DISTINCT FROM $77 AND - lv.creationdate IS NOT DISTINCT FROM $78 AND - lv.creator IS NOT DISTINCT FROM $79 AND - lv.editdate IS NOT DISTINCT FROM $80 AND - lv.editor IS NOT DISTINCT FROM $81 AND - lv.issuesreported IS NOT DISTINCT FROM $82 AND - lv.jurisdiction IS NOT DISTINCT FROM $83 AND - lv.notificationtimestamp IS NOT DISTINCT FROM $84 AND - lv.zone IS NOT DISTINCT FROM $85 AND - lv.zone2 IS NOT DISTINCT FROM $86 - ) -RETURNING *; - --- Example usage: EXECUTE insert_servicerequest_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.SpeciesAbundance +-- Table definition for fieldseeker.speciesabundance -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.speciesabundance_notinuit_f_enum AS ENUM ( - '1', - '0' -); - CREATE TABLE fieldseeker.speciesabundance ( objectid BIGSERIAL NOT NULL, + trapdata_id UUID, species VARCHAR(50), males SMALLINT, @@ -3450,7 +1528,7 @@ CREATE TABLE fieldseeker.speciesabundance ( gravidfem SMALLINT, larvae SMALLINT, poolstogen SMALLINT, - processed fieldseeker.speciesabundance_notinuit_f_enum, + processed SMALLINT, globalid UUID, created_user VARCHAR(255), created_date TIMESTAMP, @@ -3470,105 +1548,57 @@ CREATE TABLE fieldseeker.speciesabundance ( r8score DOUBLE PRECISION, h3r7 VARCHAR(256), h3r8 VARCHAR(256), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.speciesabundance.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.speciesabundance.trapdata_id IS 'Trap Data ID'; -COMMENT ON COLUMN fieldseeker.speciesabundance.species IS 'Species'; -COMMENT ON COLUMN fieldseeker.speciesabundance.males IS 'Males'; -COMMENT ON COLUMN fieldseeker.speciesabundance.unknown IS 'Unknown'; -COMMENT ON COLUMN fieldseeker.speciesabundance.bloodedfem IS 'Blooded Females'; -COMMENT ON COLUMN fieldseeker.speciesabundance.gravidfem IS 'Gravid Females'; -COMMENT ON COLUMN fieldseeker.speciesabundance.larvae IS 'Larvae'; -COMMENT ON COLUMN fieldseeker.speciesabundance.poolstogen IS 'Pools to Generate'; -COMMENT ON COLUMN fieldseeker.speciesabundance.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.speciesabundance.pupae IS 'Pupae'; -COMMENT ON COLUMN fieldseeker.speciesabundance.eggs IS 'Eggs'; -COMMENT ON COLUMN fieldseeker.speciesabundance.females IS 'Females'; -COMMENT ON COLUMN fieldseeker.speciesabundance.total IS 'Total Adults'; +COMMENT ON COLUMN fieldseeker.speciesabundance.trapdata_id IS 'Original attribute from ArcGIS API is TRAPDATA_ID'; +COMMENT ON COLUMN fieldseeker.speciesabundance.species IS 'Original attribute from ArcGIS API is SPECIES'; +COMMENT ON COLUMN fieldseeker.speciesabundance.males IS 'Original attribute from ArcGIS API is MALES'; +COMMENT ON COLUMN fieldseeker.speciesabundance.unknown IS 'Original attribute from ArcGIS API is UNKNOWN'; +COMMENT ON COLUMN fieldseeker.speciesabundance.bloodedfem IS 'Original attribute from ArcGIS API is BLOODEDFEM'; +COMMENT ON COLUMN fieldseeker.speciesabundance.gravidfem IS 'Original attribute from ArcGIS API is GRAVIDFEM'; +COMMENT ON COLUMN fieldseeker.speciesabundance.larvae IS 'Original attribute from ArcGIS API is LARVAE'; +COMMENT ON COLUMN fieldseeker.speciesabundance.poolstogen IS 'Original attribute from ArcGIS API is POOLSTOGEN'; +COMMENT ON COLUMN fieldseeker.speciesabundance.processed IS 'Original attribute from ArcGIS API is PROCESSED'; +COMMENT ON COLUMN fieldseeker.speciesabundance.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.speciesabundance.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.speciesabundance.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.speciesabundance.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.speciesabundance.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.speciesabundance.pupae IS 'Original attribute from ArcGIS API is PUPAE'; +COMMENT ON COLUMN fieldseeker.speciesabundance.eggs IS 'Original attribute from ArcGIS API is EGGS'; +COMMENT ON COLUMN fieldseeker.speciesabundance.females IS 'Original attribute from ArcGIS API is FEMALES'; +COMMENT ON COLUMN fieldseeker.speciesabundance.total IS 'Original attribute from ArcGIS API is TOTAL'; +COMMENT ON COLUMN fieldseeker.speciesabundance.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.speciesabundance.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.speciesabundance.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.speciesabundance.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.speciesabundance.yearweek IS 'Original attribute from ArcGIS API is yearWeek'; +COMMENT ON COLUMN fieldseeker.speciesabundance.globalzscore IS 'Original attribute from ArcGIS API is globalZScore'; +COMMENT ON COLUMN fieldseeker.speciesabundance.r7score IS 'Original attribute from ArcGIS API is r7Score'; +COMMENT ON COLUMN fieldseeker.speciesabundance.r8score IS 'Original attribute from ArcGIS API is r8Score'; +COMMENT ON COLUMN fieldseeker.speciesabundance.h3r7 IS 'Original attribute from ArcGIS API is h3r7'; +COMMENT ON COLUMN fieldseeker.speciesabundance.h3r8 IS 'Original attribute from ArcGIS API is h3r8'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_speciesabundance_versioned(bigint, uuid, varchar, smallint, smallint, smallint, smallint, smallint, smallint, fieldseeker.speciesabundance_notinuit_f_enum, uuid, varchar, timestamp, varchar, timestamp, smallint, smallint, integer, integer, timestamp, varchar, timestamp, varchar, integer, double precision, double precision, double precision, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.speciesabundance - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.speciesabundance - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.speciesabundance ( - objectid, trapdata_id, species, males, unknown, bloodedfem, gravidfem, larvae, poolstogen, processed, globalid, created_user, created_date, last_edited_user, last_edited_date, pupae, eggs, females, total, creationdate, creator, editdate, editor, yearweek, globalzscore, r7score, r8score, h3r7, h3r8, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.trapdata_id IS NOT DISTINCT FROM $2 AND - lv.species IS NOT DISTINCT FROM $3 AND - lv.males IS NOT DISTINCT FROM $4 AND - lv.unknown IS NOT DISTINCT FROM $5 AND - lv.bloodedfem IS NOT DISTINCT FROM $6 AND - lv.gravidfem IS NOT DISTINCT FROM $7 AND - lv.larvae IS NOT DISTINCT FROM $8 AND - lv.poolstogen IS NOT DISTINCT FROM $9 AND - lv.processed IS NOT DISTINCT FROM $10 AND - lv.globalid IS NOT DISTINCT FROM $11 AND - lv.created_user IS NOT DISTINCT FROM $12 AND - lv.created_date IS NOT DISTINCT FROM $13 AND - lv.last_edited_user IS NOT DISTINCT FROM $14 AND - lv.last_edited_date IS NOT DISTINCT FROM $15 AND - lv.pupae IS NOT DISTINCT FROM $16 AND - lv.eggs IS NOT DISTINCT FROM $17 AND - lv.females IS NOT DISTINCT FROM $18 AND - lv.total IS NOT DISTINCT FROM $19 AND - lv.creationdate IS NOT DISTINCT FROM $20 AND - lv.creator IS NOT DISTINCT FROM $21 AND - lv.editdate IS NOT DISTINCT FROM $22 AND - lv.editor IS NOT DISTINCT FROM $23 AND - lv.yearweek IS NOT DISTINCT FROM $24 AND - lv.globalzscore IS NOT DISTINCT FROM $25 AND - lv.r7score IS NOT DISTINCT FROM $26 AND - lv.r8score IS NOT DISTINCT FROM $27 AND - lv.h3r7 IS NOT DISTINCT FROM $28 AND - lv.h3r8 IS NOT DISTINCT FROM $29 - ) -RETURNING *; - --- Example usage: EXECUTE insert_speciesabundance_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.StormDrain +-- Table definition for fieldseeker.stormdrain -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.stormdrain_stormdrainsymbology_enum AS ENUM ( - 'Dry', - 'Needs Treatment', - 'Treated' -); - CREATE TABLE fieldseeker.stormdrain ( objectid BIGSERIAL NOT NULL, + nexttreatmentdate TIMESTAMP, lasttreatdate TIMESTAMP, lastaction VARCHAR(25), - symbology fieldseeker.stormdrain_stormdrainsymbology_enum, + symbology VARCHAR(25), globalid UUID, created_user VARCHAR(255), created_date TIMESTAMP, @@ -3583,119 +1613,49 @@ CREATE TABLE fieldseeker.stormdrain ( editor VARCHAR(128), type VARCHAR(25), jurisdiction VARCHAR(25), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.stormdrain.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.stormdrain.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.stormdrain.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.stormdrain.type IS 'Type'; -COMMENT ON COLUMN fieldseeker.stormdrain.jurisdiction IS 'Jurisdiction'; +COMMENT ON COLUMN fieldseeker.stormdrain.nexttreatmentdate IS 'Original attribute from ArcGIS API is NextTreatmentDate'; +COMMENT ON COLUMN fieldseeker.stormdrain.lasttreatdate IS 'Original attribute from ArcGIS API is LastTreatDate'; +COMMENT ON COLUMN fieldseeker.stormdrain.lastaction IS 'Original attribute from ArcGIS API is LastAction'; +COMMENT ON COLUMN fieldseeker.stormdrain.symbology IS 'Original attribute from ArcGIS API is Symbology'; +COMMENT ON COLUMN fieldseeker.stormdrain.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.stormdrain.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.stormdrain.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.stormdrain.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.stormdrain.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.stormdrain.laststatus IS 'Original attribute from ArcGIS API is LastStatus'; +COMMENT ON COLUMN fieldseeker.stormdrain.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.stormdrain.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.stormdrain.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.stormdrain.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.stormdrain.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.stormdrain.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.stormdrain.type IS 'Original attribute from ArcGIS API is TYPE'; +COMMENT ON COLUMN fieldseeker.stormdrain.jurisdiction IS 'Original attribute from ArcGIS API is JURISDICTION'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_stormdrain_versioned(bigint, timestamp, timestamp, varchar, fieldseeker.stormdrain_stormdrainsymbology_enum, uuid, varchar, timestamp, varchar, timestamp, varchar, varchar, varchar, timestamp, varchar, timestamp, varchar, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.stormdrain - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.stormdrain - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.stormdrain ( - objectid, nexttreatmentdate, lasttreatdate, lastaction, symbology, globalid, created_user, created_date, last_edited_user, last_edited_date, laststatus, zone, zone2, creationdate, creator, editdate, editor, type, jurisdiction, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.nexttreatmentdate IS NOT DISTINCT FROM $2 AND - lv.lasttreatdate IS NOT DISTINCT FROM $3 AND - lv.lastaction IS NOT DISTINCT FROM $4 AND - lv.symbology IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.laststatus IS NOT DISTINCT FROM $11 AND - lv.zone IS NOT DISTINCT FROM $12 AND - lv.zone2 IS NOT DISTINCT FROM $13 AND - lv.creationdate IS NOT DISTINCT FROM $14 AND - lv.creator IS NOT DISTINCT FROM $15 AND - lv.editdate IS NOT DISTINCT FROM $16 AND - lv.editor IS NOT DISTINCT FROM $17 AND - lv.type IS NOT DISTINCT FROM $18 AND - lv.jurisdiction IS NOT DISTINCT FROM $19 - ) -RETURNING *; - --- Example usage: EXECUTE insert_stormdrain_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.TimeCard +-- Table definition for fieldseeker.timecard -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.timecard_timecard_activity_451e67260c084304a35457170dc13366_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TYPE fieldseeker.timecard_timecardequipmenttype_enum AS ENUM ( - 'Spreader', - 'ATV', - 'Truck' -); - CREATE TABLE fieldseeker.timecard ( objectid BIGSERIAL NOT NULL, - activity fieldseeker.timecard_timecard_activity_451e67260c084304a35457170dc13366_enum, + + activity VARCHAR(25), startdatetime TIMESTAMP, enddatetime TIMESTAMP, comments VARCHAR(250), externalid VARCHAR(25), - equiptype fieldseeker.timecard_timecardequipmenttype_enum, + equiptype VARCHAR(25), locationname VARCHAR(25), zone VARCHAR(25), zone2 VARCHAR(25), @@ -3717,153 +1677,67 @@ CREATE TABLE fieldseeker.timecard ( editdate TIMESTAMP, editor VARCHAR(128), rodentlocid UUID, + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.timecard.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.timecard.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.timecard.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.timecard.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.timecard.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.timecard.equiptype IS 'Equipment Type'; -COMMENT ON COLUMN fieldseeker.timecard.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.timecard.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.timecard.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.timecard.fieldtech IS 'Field Tech'; +COMMENT ON COLUMN fieldseeker.timecard.activity IS 'Original attribute from ArcGIS API is ACTIVITY'; +COMMENT ON COLUMN fieldseeker.timecard.startdatetime IS 'Original attribute from ArcGIS API is STARTDATETIME'; +COMMENT ON COLUMN fieldseeker.timecard.enddatetime IS 'Original attribute from ArcGIS API is ENDDATETIME'; +COMMENT ON COLUMN fieldseeker.timecard.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.timecard.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.timecard.equiptype IS 'Original attribute from ArcGIS API is EQUIPTYPE'; +COMMENT ON COLUMN fieldseeker.timecard.locationname IS 'Original attribute from ArcGIS API is LOCATIONNAME'; +COMMENT ON COLUMN fieldseeker.timecard.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.timecard.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.timecard.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.timecard.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.timecard.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.timecard.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.timecard.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.timecard.linelocid IS 'Original attribute from ArcGIS API is LINELOCID'; +COMMENT ON COLUMN fieldseeker.timecard.pointlocid IS 'Original attribute from ArcGIS API is POINTLOCID'; +COMMENT ON COLUMN fieldseeker.timecard.polygonlocid IS 'Original attribute from ArcGIS API is POLYGONLOCID'; +COMMENT ON COLUMN fieldseeker.timecard.lclocid IS 'Original attribute from ArcGIS API is LCLOCID'; +COMMENT ON COLUMN fieldseeker.timecard.samplelocid IS 'Original attribute from ArcGIS API is SAMPLELOCID'; +COMMENT ON COLUMN fieldseeker.timecard.srid IS 'Original attribute from ArcGIS API is SRID'; +COMMENT ON COLUMN fieldseeker.timecard.traplocid IS 'Original attribute from ArcGIS API is TRAPLOCID'; +COMMENT ON COLUMN fieldseeker.timecard.fieldtech IS 'Original attribute from ArcGIS API is FIELDTECH'; +COMMENT ON COLUMN fieldseeker.timecard.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.timecard.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.timecard.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.timecard.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.timecard.rodentlocid IS 'Original attribute from ArcGIS API is RODENTLOCID'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_timecard_versioned(bigint, fieldseeker.timecard_timecard_activity_451e67260c084304a35457170dc13366_enum, timestamp, timestamp, varchar, varchar, fieldseeker.timecard_timecardequipmenttype_enum, varchar, varchar, varchar, uuid, varchar, timestamp, varchar, timestamp, uuid, uuid, uuid, uuid, uuid, uuid, uuid, varchar, timestamp, varchar, timestamp, varchar, uuid) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.timecard - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.timecard - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.timecard ( - objectid, activity, startdatetime, enddatetime, comments, externalid, equiptype, locationname, zone, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, linelocid, pointlocid, polygonlocid, lclocid, samplelocid, srid, traplocid, fieldtech, creationdate, creator, editdate, editor, rodentlocid, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.activity IS NOT DISTINCT FROM $2 AND - lv.startdatetime IS NOT DISTINCT FROM $3 AND - lv.enddatetime IS NOT DISTINCT FROM $4 AND - lv.comments IS NOT DISTINCT FROM $5 AND - lv.externalid IS NOT DISTINCT FROM $6 AND - lv.equiptype IS NOT DISTINCT FROM $7 AND - lv.locationname IS NOT DISTINCT FROM $8 AND - lv.zone IS NOT DISTINCT FROM $9 AND - lv.zone2 IS NOT DISTINCT FROM $10 AND - lv.globalid IS NOT DISTINCT FROM $11 AND - lv.created_user IS NOT DISTINCT FROM $12 AND - lv.created_date IS NOT DISTINCT FROM $13 AND - lv.last_edited_user IS NOT DISTINCT FROM $14 AND - lv.last_edited_date IS NOT DISTINCT FROM $15 AND - lv.linelocid IS NOT DISTINCT FROM $16 AND - lv.pointlocid IS NOT DISTINCT FROM $17 AND - lv.polygonlocid IS NOT DISTINCT FROM $18 AND - lv.lclocid IS NOT DISTINCT FROM $19 AND - lv.samplelocid IS NOT DISTINCT FROM $20 AND - lv.srid IS NOT DISTINCT FROM $21 AND - lv.traplocid IS NOT DISTINCT FROM $22 AND - lv.fieldtech IS NOT DISTINCT FROM $23 AND - lv.creationdate IS NOT DISTINCT FROM $24 AND - lv.creator IS NOT DISTINCT FROM $25 AND - lv.editdate IS NOT DISTINCT FROM $26 AND - lv.editor IS NOT DISTINCT FROM $27 AND - lv.rodentlocid IS NOT DISTINCT FROM $28 - ) -RETURNING *; - --- Example usage: EXECUTE insert_timecard_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.TrapData +-- Table definition for fieldseeker.trapdata -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.trapdata_mosquitotraptype_enum AS ENUM ( - 'GRVD', - 'BGSENT', - 'CO2' -); - -CREATE TYPE fieldseeker.trapdata_notinuitrapactivitytype_enum AS ENUM ( - 'S', - 'R' -); - -CREATE TYPE fieldseeker.trapdata_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.trapdata_mosquitositecondition_enum AS ENUM ( - 'Dry', - 'Clean', - 'Full', - 'Low' -); - -CREATE TYPE fieldseeker.trapdata_mosquitotrapcondition_enum AS ENUM ( - 'Damaged', - 'Missing', - 'Fan Off', - 'Fan Slow' -); - -CREATE TYPE fieldseeker.trapdata_trapdata_winddir_c1a31e05_d0b9_4b22_8800_be127bb3f166_enum AS ENUM ( - 'E', - 'N', - 'NE', - 'NW', - 'S', - 'SE', - 'SW', - 'W' -); - -CREATE TYPE fieldseeker.trapdata_trapdata_lure_25fe542f_077f_4254_8681_76e8f436354b_enum AS ENUM ( - 'CO2 (Dry Ice)', - 'CO2 (Sugar Yeast)', - 'BG-Lure', - 'Gravid Water' -); - CREATE TABLE fieldseeker.trapdata ( objectid BIGSERIAL NOT NULL, - traptype fieldseeker.trapdata_mosquitotraptype_enum, - trapactivitytype fieldseeker.trapdata_notinuitrapactivitytype_enum, + + traptype VARCHAR(25), + trapactivitytype VARCHAR(1), startdatetime TIMESTAMP, enddatetime TIMESTAMP, comments VARCHAR(250), idbytech VARCHAR(25), sortbytech VARCHAR(25), - processed fieldseeker.trapdata_notinuit_f_enum, - sitecond fieldseeker.trapdata_mosquitositecondition_enum, + processed SMALLINT, + sitecond VARCHAR(25), locationname VARCHAR(25), recordstatus SMALLINT, - reviewed fieldseeker.trapdata_notinuit_f_enum, + reviewed SMALLINT, reviewedby VARCHAR(25), revieweddate TIMESTAMP, - trapcondition fieldseeker.trapdata_mosquitotrapcondition_enum, + trapcondition VARCHAR(25), trapnights SMALLINT, zone VARCHAR(25), zone2 VARCHAR(25), @@ -3877,7 +1751,7 @@ CREATE TABLE fieldseeker.trapdata ( gatewaysync SMALLINT, loc_id UUID, voltage DOUBLE PRECISION, - winddir fieldseeker.trapdata_trapdata_winddir_c1a31e05_d0b9_4b22_8800_be127bb3f166_enum, + winddir VARCHAR(3), windspeed DOUBLE PRECISION, avetemp DOUBLE PRECISION, raingauge DOUBLE PRECISION, @@ -3889,157 +1763,75 @@ CREATE TABLE fieldseeker.trapdata ( creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), - lure fieldseeker.trapdata_trapdata_lure_25fe542f_077f_4254_8681_76e8f436354b_enum, + lure VARCHAR(256), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.trapdata.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.trapdata.traptype IS 'Trap Type'; -COMMENT ON COLUMN fieldseeker.trapdata.trapactivitytype IS 'Trap Activity Type'; -COMMENT ON COLUMN fieldseeker.trapdata.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.trapdata.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.trapdata.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.trapdata.idbytech IS 'Tech Identifying Species in Lab'; -COMMENT ON COLUMN fieldseeker.trapdata.sortbytech IS 'Tech Sorting Trap Results in Lab'; -COMMENT ON COLUMN fieldseeker.trapdata.processed IS 'Processed'; -COMMENT ON COLUMN fieldseeker.trapdata.sitecond IS 'Site Conditions'; -COMMENT ON COLUMN fieldseeker.trapdata.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.trapdata.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.trapdata.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.trapdata.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.trapdata.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.trapdata.trapcondition IS 'Trap Condition'; -COMMENT ON COLUMN fieldseeker.trapdata.trapnights IS 'Trap Nights'; -COMMENT ON COLUMN fieldseeker.trapdata.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.trapdata.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.trapdata.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.trapdata.gatewaysync IS 'Gateway Sync'; -COMMENT ON COLUMN fieldseeker.trapdata.voltage IS 'Voltage'; -COMMENT ON COLUMN fieldseeker.trapdata.lr IS 'Landing Rate'; +COMMENT ON COLUMN fieldseeker.trapdata.traptype IS 'Original attribute from ArcGIS API is TRAPTYPE'; +COMMENT ON COLUMN fieldseeker.trapdata.trapactivitytype IS 'Original attribute from ArcGIS API is TRAPACTIVITYTYPE'; +COMMENT ON COLUMN fieldseeker.trapdata.startdatetime IS 'Original attribute from ArcGIS API is STARTDATETIME'; +COMMENT ON COLUMN fieldseeker.trapdata.enddatetime IS 'Original attribute from ArcGIS API is ENDDATETIME'; +COMMENT ON COLUMN fieldseeker.trapdata.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.trapdata.idbytech IS 'Original attribute from ArcGIS API is IDBYTECH'; +COMMENT ON COLUMN fieldseeker.trapdata.sortbytech IS 'Original attribute from ArcGIS API is SORTBYTECH'; +COMMENT ON COLUMN fieldseeker.trapdata.processed IS 'Original attribute from ArcGIS API is PROCESSED'; +COMMENT ON COLUMN fieldseeker.trapdata.sitecond IS 'Original attribute from ArcGIS API is SITECOND'; +COMMENT ON COLUMN fieldseeker.trapdata.locationname IS 'Original attribute from ArcGIS API is LOCATIONNAME'; +COMMENT ON COLUMN fieldseeker.trapdata.recordstatus IS 'Original attribute from ArcGIS API is RECORDSTATUS'; +COMMENT ON COLUMN fieldseeker.trapdata.reviewed IS 'Original attribute from ArcGIS API is REVIEWED'; +COMMENT ON COLUMN fieldseeker.trapdata.reviewedby IS 'Original attribute from ArcGIS API is REVIEWEDBY'; +COMMENT ON COLUMN fieldseeker.trapdata.revieweddate IS 'Original attribute from ArcGIS API is REVIEWEDDATE'; +COMMENT ON COLUMN fieldseeker.trapdata.trapcondition IS 'Original attribute from ArcGIS API is TRAPCONDITION'; +COMMENT ON COLUMN fieldseeker.trapdata.trapnights IS 'Original attribute from ArcGIS API is TRAPNIGHTS'; +COMMENT ON COLUMN fieldseeker.trapdata.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.trapdata.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.trapdata.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.trapdata.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.trapdata.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.trapdata.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.trapdata.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.trapdata.srid IS 'Original attribute from ArcGIS API is SRID'; +COMMENT ON COLUMN fieldseeker.trapdata.fieldtech IS 'Original attribute from ArcGIS API is FIELDTECH'; +COMMENT ON COLUMN fieldseeker.trapdata.gatewaysync IS 'Original attribute from ArcGIS API is GATEWAYSYNC'; +COMMENT ON COLUMN fieldseeker.trapdata.loc_id IS 'Original attribute from ArcGIS API is LOC_ID'; +COMMENT ON COLUMN fieldseeker.trapdata.voltage IS 'Original attribute from ArcGIS API is VOLTAGE'; +COMMENT ON COLUMN fieldseeker.trapdata.winddir IS 'Original attribute from ArcGIS API is WINDDIR'; +COMMENT ON COLUMN fieldseeker.trapdata.windspeed IS 'Original attribute from ArcGIS API is WINDSPEED'; +COMMENT ON COLUMN fieldseeker.trapdata.avetemp IS 'Original attribute from ArcGIS API is AVETEMP'; +COMMENT ON COLUMN fieldseeker.trapdata.raingauge IS 'Original attribute from ArcGIS API is RAINGAUGE'; +COMMENT ON COLUMN fieldseeker.trapdata.lr IS 'Original attribute from ArcGIS API is LR'; +COMMENT ON COLUMN fieldseeker.trapdata.field IS 'Original attribute from ArcGIS API is Field'; +COMMENT ON COLUMN fieldseeker.trapdata.vectorsurvtrapdataid IS 'Original attribute from ArcGIS API is VECTORSURVTRAPDATAID'; +COMMENT ON COLUMN fieldseeker.trapdata.vectorsurvtraplocationid IS 'Original attribute from ArcGIS API is VECTORSURVTRAPLOCATIONID'; +COMMENT ON COLUMN fieldseeker.trapdata.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.trapdata.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.trapdata.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.trapdata.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.trapdata.lure IS 'Original attribute from ArcGIS API is Lure'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_trapdata_versioned(bigint, fieldseeker.trapdata_mosquitotraptype_enum, fieldseeker.trapdata_notinuitrapactivitytype_enum, timestamp, timestamp, varchar, varchar, varchar, fieldseeker.trapdata_notinuit_f_enum, fieldseeker.trapdata_mosquitositecondition_enum, varchar, smallint, fieldseeker.trapdata_notinuit_f_enum, varchar, timestamp, fieldseeker.trapdata_mosquitotrapcondition_enum, smallint, varchar, varchar, uuid, varchar, timestamp, varchar, timestamp, uuid, varchar, smallint, uuid, double precision, fieldseeker.trapdata_trapdata_winddir_c1a31e05_d0b9_4b22_8800_be127bb3f166_enum, double precision, double precision, double precision, smallint, integer, varchar, varchar, timestamp, varchar, timestamp, varchar, fieldseeker.trapdata_trapdata_lure_25fe542f_077f_4254_8681_76e8f436354b_enum) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.trapdata - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.trapdata - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.trapdata ( - objectid, traptype, trapactivitytype, startdatetime, enddatetime, comments, idbytech, sortbytech, processed, sitecond, locationname, recordstatus, reviewed, reviewedby, revieweddate, trapcondition, trapnights, zone, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, srid, fieldtech, gatewaysync, loc_id, voltage, winddir, windspeed, avetemp, raingauge, lr, field, vectorsurvtrapdataid, vectorsurvtraplocationid, creationdate, creator, editdate, editor, lure, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.traptype IS NOT DISTINCT FROM $2 AND - lv.trapactivitytype IS NOT DISTINCT FROM $3 AND - lv.startdatetime IS NOT DISTINCT FROM $4 AND - lv.enddatetime IS NOT DISTINCT FROM $5 AND - lv.comments IS NOT DISTINCT FROM $6 AND - lv.idbytech IS NOT DISTINCT FROM $7 AND - lv.sortbytech IS NOT DISTINCT FROM $8 AND - lv.processed IS NOT DISTINCT FROM $9 AND - lv.sitecond IS NOT DISTINCT FROM $10 AND - lv.locationname IS NOT DISTINCT FROM $11 AND - lv.recordstatus IS NOT DISTINCT FROM $12 AND - lv.reviewed IS NOT DISTINCT FROM $13 AND - lv.reviewedby IS NOT DISTINCT FROM $14 AND - lv.revieweddate IS NOT DISTINCT FROM $15 AND - lv.trapcondition IS NOT DISTINCT FROM $16 AND - lv.trapnights IS NOT DISTINCT FROM $17 AND - lv.zone IS NOT DISTINCT FROM $18 AND - lv.zone2 IS NOT DISTINCT FROM $19 AND - lv.globalid IS NOT DISTINCT FROM $20 AND - lv.created_user IS NOT DISTINCT FROM $21 AND - lv.created_date IS NOT DISTINCT FROM $22 AND - lv.last_edited_user IS NOT DISTINCT FROM $23 AND - lv.last_edited_date IS NOT DISTINCT FROM $24 AND - lv.srid IS NOT DISTINCT FROM $25 AND - lv.fieldtech IS NOT DISTINCT FROM $26 AND - lv.gatewaysync IS NOT DISTINCT FROM $27 AND - lv.loc_id IS NOT DISTINCT FROM $28 AND - lv.voltage IS NOT DISTINCT FROM $29 AND - lv.winddir IS NOT DISTINCT FROM $30 AND - lv.windspeed IS NOT DISTINCT FROM $31 AND - lv.avetemp IS NOT DISTINCT FROM $32 AND - lv.raingauge IS NOT DISTINCT FROM $33 AND - lv.lr IS NOT DISTINCT FROM $34 AND - lv.field IS NOT DISTINCT FROM $35 AND - lv.vectorsurvtrapdataid IS NOT DISTINCT FROM $36 AND - lv.vectorsurvtraplocationid IS NOT DISTINCT FROM $37 AND - lv.creationdate IS NOT DISTINCT FROM $38 AND - lv.creator IS NOT DISTINCT FROM $39 AND - lv.editdate IS NOT DISTINCT FROM $40 AND - lv.editor IS NOT DISTINCT FROM $41 AND - lv.lure IS NOT DISTINCT FROM $42 - ) -RETURNING *; - --- Example usage: EXECUTE insert_trapdata_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.TrapLocation +-- Table definition for fieldseeker.traplocation -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.traplocation_traplocation_priority_680fb011063b41d59f39271c959b857f_enum AS ENUM ( - 'Low', - 'Medium', - 'High', - 'None', - 'Project', - 'Fixed', - 'Response ' -); - -CREATE TYPE fieldseeker.traplocation_traplocation_usetype_5e0eff9231fb404c98cc53c1d49a2193_enum AS ENUM ( - 'Fixed Trapping', - 'Response Trapping', - 'Service Request', - 'Project Trap' -); - -CREATE TYPE fieldseeker.traplocation_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.traplocation_traplocation_accessdesc_154cbd10_4524_4e3a_8ca0_f099ec86556a_enum AS ENUM ( - 'homeowner preference', - 'no longer needed' -); - -CREATE TYPE fieldseeker.traplocation_traplocation_habitat_5c349680f5ff40b1aeca88c17993e8f3_enum AS ENUM ( - 'Trap' -); - CREATE TABLE fieldseeker.traplocation ( objectid BIGSERIAL NOT NULL, + name VARCHAR(25), zone VARCHAR(25), - habitat fieldseeker.traplocation_traplocation_habitat_5c349680f5ff40b1aeca88c17993e8f3_enum, - priority fieldseeker.traplocation_traplocation_priority_680fb011063b41d59f39271c959b857f_enum, - usetype fieldseeker.traplocation_traplocation_usetype_5e0eff9231fb404c98cc53c1d49a2193_enum, - active fieldseeker.traplocation_notinuit_f_enum, + habitat VARCHAR(25), + priority VARCHAR(25), + usetype VARCHAR(25), + active SMALLINT, description VARCHAR(250), - accessdesc fieldseeker.traplocation_traplocation_accessdesc_154cbd10_4524_4e3a_8ca0_f099ec86556a_enum, + accessdesc VARCHAR(250), comments VARCHAR(250), externalid VARCHAR(50), nextactiondatescheduled TIMESTAMP, @@ -4061,271 +1853,76 @@ CREATE TABLE fieldseeker.traplocation ( editor VARCHAR(128), h3r7 VARCHAR(255), h3r8 VARCHAR(255), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.traplocation.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.traplocation.name IS 'Name'; -COMMENT ON COLUMN fieldseeker.traplocation.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.traplocation.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.traplocation.priority IS 'Priority'; -COMMENT ON COLUMN fieldseeker.traplocation.usetype IS 'Use Type'; -COMMENT ON COLUMN fieldseeker.traplocation.active IS 'Active'; -COMMENT ON COLUMN fieldseeker.traplocation.description IS 'Description'; -COMMENT ON COLUMN fieldseeker.traplocation.accessdesc IS 'Access Description'; -COMMENT ON COLUMN fieldseeker.traplocation.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.traplocation.externalid IS 'External ID'; -COMMENT ON COLUMN fieldseeker.traplocation.nextactiondatescheduled IS 'Next Scheduled Action'; -COMMENT ON COLUMN fieldseeker.traplocation.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.traplocation.gatewaysync IS 'Gateway Sync'; -COMMENT ON COLUMN fieldseeker.traplocation.route IS 'Route'; -COMMENT ON COLUMN fieldseeker.traplocation.set_dow IS 'Set Day of Week'; -COMMENT ON COLUMN fieldseeker.traplocation.route_order IS 'Route order'; +COMMENT ON COLUMN fieldseeker.traplocation.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.traplocation.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.traplocation.habitat IS 'Original attribute from ArcGIS API is HABITAT'; +COMMENT ON COLUMN fieldseeker.traplocation.priority IS 'Original attribute from ArcGIS API is PRIORITY'; +COMMENT ON COLUMN fieldseeker.traplocation.usetype IS 'Original attribute from ArcGIS API is USETYPE'; +COMMENT ON COLUMN fieldseeker.traplocation.active IS 'Original attribute from ArcGIS API is ACTIVE'; +COMMENT ON COLUMN fieldseeker.traplocation.description IS 'Original attribute from ArcGIS API is DESCRIPTION'; +COMMENT ON COLUMN fieldseeker.traplocation.accessdesc IS 'Original attribute from ArcGIS API is ACCESSDESC'; +COMMENT ON COLUMN fieldseeker.traplocation.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.traplocation.externalid IS 'Original attribute from ArcGIS API is EXTERNALID'; +COMMENT ON COLUMN fieldseeker.traplocation.nextactiondatescheduled IS 'Original attribute from ArcGIS API is NEXTACTIONDATESCHEDULED'; +COMMENT ON COLUMN fieldseeker.traplocation.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.traplocation.locationnumber IS 'Original attribute from ArcGIS API is LOCATIONNUMBER'; +COMMENT ON COLUMN fieldseeker.traplocation.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.traplocation.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.traplocation.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.traplocation.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.traplocation.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.traplocation.gatewaysync IS 'Original attribute from ArcGIS API is GATEWAYSYNC'; +COMMENT ON COLUMN fieldseeker.traplocation.route IS 'Original attribute from ArcGIS API is route'; +COMMENT ON COLUMN fieldseeker.traplocation.set_dow IS 'Original attribute from ArcGIS API is set_dow'; +COMMENT ON COLUMN fieldseeker.traplocation.route_order IS 'Original attribute from ArcGIS API is route_order'; +COMMENT ON COLUMN fieldseeker.traplocation.vectorsurvsiteid IS 'Original attribute from ArcGIS API is VECTORSURVSITEID'; +COMMENT ON COLUMN fieldseeker.traplocation.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.traplocation.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.traplocation.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.traplocation.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.traplocation.h3r7 IS 'Original attribute from ArcGIS API is h3r7'; +COMMENT ON COLUMN fieldseeker.traplocation.h3r8 IS 'Original attribute from ArcGIS API is h3r8'; --- Field active has default value: 1 - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_traplocation_versioned(bigint, varchar, varchar, fieldseeker.traplocation_traplocation_habitat_5c349680f5ff40b1aeca88c17993e8f3_enum, fieldseeker.traplocation_traplocation_priority_680fb011063b41d59f39271c959b857f_enum, fieldseeker.traplocation_traplocation_usetype_5e0eff9231fb404c98cc53c1d49a2193_enum, fieldseeker.traplocation_notinuit_f_enum, varchar, fieldseeker.traplocation_traplocation_accessdesc_154cbd10_4524_4e3a_8ca0_f099ec86556a_enum, varchar, varchar, timestamp, varchar, integer, uuid, varchar, timestamp, varchar, timestamp, smallint, integer, integer, integer, varchar, timestamp, varchar, timestamp, varchar, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.traplocation - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.traplocation - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.traplocation ( - objectid, name, zone, habitat, priority, usetype, active, description, accessdesc, comments, externalid, nextactiondatescheduled, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, gatewaysync, route, set_dow, route_order, vectorsurvsiteid, creationdate, creator, editdate, editor, h3r7, h3r8, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.zone IS NOT DISTINCT FROM $3 AND - lv.habitat IS NOT DISTINCT FROM $4 AND - lv.priority IS NOT DISTINCT FROM $5 AND - lv.usetype IS NOT DISTINCT FROM $6 AND - lv.active IS NOT DISTINCT FROM $7 AND - lv.description IS NOT DISTINCT FROM $8 AND - lv.accessdesc IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.externalid IS NOT DISTINCT FROM $11 AND - lv.nextactiondatescheduled IS NOT DISTINCT FROM $12 AND - lv.zone2 IS NOT DISTINCT FROM $13 AND - lv.locationnumber IS NOT DISTINCT FROM $14 AND - lv.globalid IS NOT DISTINCT FROM $15 AND - lv.created_user IS NOT DISTINCT FROM $16 AND - lv.created_date IS NOT DISTINCT FROM $17 AND - lv.last_edited_user IS NOT DISTINCT FROM $18 AND - lv.last_edited_date IS NOT DISTINCT FROM $19 AND - lv.gatewaysync IS NOT DISTINCT FROM $20 AND - lv.route IS NOT DISTINCT FROM $21 AND - lv.set_dow IS NOT DISTINCT FROM $22 AND - lv.route_order IS NOT DISTINCT FROM $23 AND - lv.vectorsurvsiteid IS NOT DISTINCT FROM $24 AND - lv.creationdate IS NOT DISTINCT FROM $25 AND - lv.creator IS NOT DISTINCT FROM $26 AND - lv.editdate IS NOT DISTINCT FROM $27 AND - lv.editor IS NOT DISTINCT FROM $28 AND - lv.h3r7 IS NOT DISTINCT FROM $29 AND - lv.h3r8 IS NOT DISTINCT FROM $30 - ) -RETURNING *; - --- Example usage: EXECUTE insert_traplocation_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.Treatment +-- Table definition for fieldseeker.treatment -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; -CREATE TYPE fieldseeker.treatment_treatment_sitecond_5a15bf36fa124280b961f31cd1a9b571_enum AS ENUM ( - 'Dry', - 'Flowing', - 'Maintained', - 'Unmaintained', - 'High Organic', - 'Fish Present', - 'Stagnant' -); - -CREATE TYPE fieldseeker.treatment_mosquitoactivity_enum AS ENUM ( - 'Routine inspection', - 'Pre-treatment', - 'Maintenance', - 'ULV', - 'BARRIER', - 'LOGIN', - 'TREATSD', - 'SD', - 'SITEVISIT', - 'ONLINE', - 'SYNC', - 'CREATESR', - 'LC', - 'ACCEPTSR', - 'POINT', - 'DOWNLOAD', - 'COMPLETESR', - 'POLYGON', - 'TRAP', - 'SAMPLE', - 'QA', - 'PTA', - 'FIELDSCOUTING', - 'OFFLINE', - 'LINE', - 'TRAPLOCATION', - 'SAMPLELOCATION', - 'LCLOCATION' -); - -CREATE TYPE fieldseeker.treatment_mosquitoproductmeasureunit_enum AS ENUM ( - 'briquet', - 'dry oz', - 'each', - 'fl oz', - 'gal', - 'lb', - 'packet', - 'pouch' -); - -CREATE TYPE fieldseeker.treatment_treatment_method_d558ca3ccf43440c8160758253967621_enum AS ENUM ( - 'Argo', - 'ATV', - 'Backpack', - 'Drone', - 'Manual', - 'Truck', - 'ULV', - 'WALS', - 'Administrative Action' -); - -CREATE TYPE fieldseeker.treatment_treatment_equiptype_45694d79_ff21_42cc_be4f_a0d1def4fba0_enum AS ENUM ( - 'Backpack #1', - 'A1 Mist Sprayer (T-3) ', - 'Spreader #2', - 'Guardian #73 ', - 'ULV #74 (Grizzly)', - 'Clark ULV Sprayer #71', - 'Clark ULV Sprayer #72', - 'Spray bottle' -); - -CREATE TYPE fieldseeker.treatment_notinuiwinddirection_enum AS ENUM ( - 'N', - 'NE', - 'E', - 'SE', - 'S', - 'SW', - 'W', - 'NW' -); - -CREATE TYPE fieldseeker.treatment_treatment_sitecond_f812e1f64dcb4dc9a75da9d00abe6169_enum AS ENUM ( - 'Dry', - 'Flowing', - 'Maintained', - 'Unmaintained', - 'High Organic', - 'Fish Present' -); - -CREATE TYPE fieldseeker.treatment_mosquitoproductareaunit_enum AS ENUM ( - 'acre', - 'sq ft' -); - -CREATE TYPE fieldseeker.treatment_notinuit_f_enum AS ENUM ( - '1', - '0' -); - -CREATE TYPE fieldseeker.treatment_treatment_habitat_0afee7eb_f9ea_4707_8483_cccfe60f0d16_enum AS ENUM ( - 'orchard', - 'row_crops', - 'vine_crops', - 'ag_grass_or_grain', - 'pasture', - 'irrigation_standpipe', - 'ditch', - 'pond', - 'sump', - 'drain', - 'dairy_lagoon', - 'wastewater_treatment', - 'trough', - 'depression', - 'gutter', - 'rain_gutter', - 'culvert', - 'Utility', - 'catch_basin', - 'stream_or_creek', - 'slough', - 'river', - 'marsh_or_wetlands', - 'containers', - 'watering_bowl', - 'plant_saucer', - 'yard_drain', - 'plant_axil', - 'treehole', - 'foutain_or_water_feature', - 'bird_bath', - 'misc_water_accumulation', - 'tarp_or_cover', - 'swimming_pool', - 'aboveground_pool', - 'kid_pool', - 'hot_tub', - 'applicance', - 'flooded_structure', - 'low_point' -); - CREATE TABLE fieldseeker.treatment ( objectid BIGSERIAL NOT NULL, - activity fieldseeker.treatment_mosquitoactivity_enum, + + activity VARCHAR(25), treatarea DOUBLE PRECISION, - areaunit fieldseeker.treatment_mosquitoproductareaunit_enum, + areaunit VARCHAR(10), product VARCHAR(25), qty DOUBLE PRECISION, - qtyunit fieldseeker.treatment_mosquitoproductmeasureunit_enum, - method fieldseeker.treatment_treatment_method_d558ca3ccf43440c8160758253967621_enum, - equiptype fieldseeker.treatment_treatment_equiptype_45694d79_ff21_42cc_be4f_a0d1def4fba0_enum, + qtyunit VARCHAR(10), + method VARCHAR(25), + equiptype VARCHAR(25), comments VARCHAR(250), avetemp DOUBLE PRECISION, windspeed DOUBLE PRECISION, - winddir fieldseeker.treatment_notinuiwinddirection_enum, + winddir VARCHAR(3), raingauge DOUBLE PRECISION, startdatetime TIMESTAMP, enddatetime TIMESTAMP, insp_id UUID, - reviewed fieldseeker.treatment_notinuit_f_enum, + reviewed SMALLINT, reviewedby VARCHAR(25), revieweddate TIMESTAMP, locationname VARCHAR(25), zone VARCHAR(25), - warningoverride fieldseeker.treatment_notinuit_f_enum, + warningoverride SMALLINT, recordstatus SMALLINT, zone2 VARCHAR(25), treatacres DOUBLE PRECISION, @@ -4346,156 +1943,89 @@ CREATE TABLE fieldseeker.treatment ( fieldtech VARCHAR(25), ptaid UUID, flowrate DOUBLE PRECISION, - habitat fieldseeker.treatment_treatment_habitat_0afee7eb_f9ea_4707_8483_cccfe60f0d16_enum, + habitat VARCHAR(250), treathectares DOUBLE PRECISION, invloc VARCHAR(25), - temp_sitecond fieldseeker.treatment_treatment_sitecond_f812e1f64dcb4dc9a75da9d00abe6169_enum, - sitecond fieldseeker.treatment_treatment_sitecond_5a15bf36fa124280b961f31cd1a9b571_enum, + temp_sitecond VARCHAR(250), + sitecond VARCHAR(250), totalcostprodcut DOUBLE PRECISION, creationdate TIMESTAMP, creator VARCHAR(128), editdate TIMESTAMP, editor VARCHAR(128), targetspecies VARCHAR(250), + geometry JSONB NOT NULL, + geospatial GEOMETRY(POINT, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.treatment.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.treatment.activity IS 'Activity'; -COMMENT ON COLUMN fieldseeker.treatment.treatarea IS 'Area Treated'; -COMMENT ON COLUMN fieldseeker.treatment.areaunit IS 'Area Unit'; -COMMENT ON COLUMN fieldseeker.treatment.product IS 'Product'; -COMMENT ON COLUMN fieldseeker.treatment.qty IS 'Quantity'; -COMMENT ON COLUMN fieldseeker.treatment.qtyunit IS 'Quantity Unit'; -COMMENT ON COLUMN fieldseeker.treatment.method IS 'Method'; -COMMENT ON COLUMN fieldseeker.treatment.equiptype IS 'Equipment Type'; -COMMENT ON COLUMN fieldseeker.treatment.comments IS 'Comments'; -COMMENT ON COLUMN fieldseeker.treatment.avetemp IS 'Average Temperature'; -COMMENT ON COLUMN fieldseeker.treatment.windspeed IS 'Wind Speed'; -COMMENT ON COLUMN fieldseeker.treatment.winddir IS 'Wind Direction'; -COMMENT ON COLUMN fieldseeker.treatment.raingauge IS 'Rain Gauge'; -COMMENT ON COLUMN fieldseeker.treatment.startdatetime IS 'Start'; -COMMENT ON COLUMN fieldseeker.treatment.enddatetime IS 'Finish'; -COMMENT ON COLUMN fieldseeker.treatment.reviewed IS 'Reviewed'; -COMMENT ON COLUMN fieldseeker.treatment.reviewedby IS 'Reviewed By'; -COMMENT ON COLUMN fieldseeker.treatment.revieweddate IS 'Reviewed Date'; -COMMENT ON COLUMN fieldseeker.treatment.locationname IS 'Location Name'; -COMMENT ON COLUMN fieldseeker.treatment.zone IS 'Zone'; -COMMENT ON COLUMN fieldseeker.treatment.warningoverride IS 'Warning Override'; -COMMENT ON COLUMN fieldseeker.treatment.recordstatus IS 'RecordStatus'; -COMMENT ON COLUMN fieldseeker.treatment.zone2 IS 'Zone2'; -COMMENT ON COLUMN fieldseeker.treatment.treatacres IS 'Treated Acres'; -COMMENT ON COLUMN fieldseeker.treatment.tirecount IS 'Tire Count'; -COMMENT ON COLUMN fieldseeker.treatment.cbcount IS 'Catch Basin Count'; -COMMENT ON COLUMN fieldseeker.treatment.containercount IS 'Container Count'; -COMMENT ON COLUMN fieldseeker.treatment.treatmentlength IS 'Treatment Length'; -COMMENT ON COLUMN fieldseeker.treatment.treatmenthours IS 'Treatment Hours'; -COMMENT ON COLUMN fieldseeker.treatment.treatmentlengthunits IS 'Treatment Length Units'; -COMMENT ON COLUMN fieldseeker.treatment.fieldtech IS 'Field Tech'; -COMMENT ON COLUMN fieldseeker.treatment.habitat IS 'Habitat'; -COMMENT ON COLUMN fieldseeker.treatment.treathectares IS 'Treat Hectares'; -COMMENT ON COLUMN fieldseeker.treatment.invloc IS 'Inventory Location'; -COMMENT ON COLUMN fieldseeker.treatment.temp_sitecond IS 'temp_Conditions'; -COMMENT ON COLUMN fieldseeker.treatment.sitecond IS 'Conditions'; -COMMENT ON COLUMN fieldseeker.treatment.totalcostprodcut IS 'TotalCostProduct'; -COMMENT ON COLUMN fieldseeker.treatment.targetspecies IS 'Target Species'; +COMMENT ON COLUMN fieldseeker.treatment.activity IS 'Original attribute from ArcGIS API is ACTIVITY'; +COMMENT ON COLUMN fieldseeker.treatment.treatarea IS 'Original attribute from ArcGIS API is TREATAREA'; +COMMENT ON COLUMN fieldseeker.treatment.areaunit IS 'Original attribute from ArcGIS API is AREAUNIT'; +COMMENT ON COLUMN fieldseeker.treatment.product IS 'Original attribute from ArcGIS API is PRODUCT'; +COMMENT ON COLUMN fieldseeker.treatment.qty IS 'Original attribute from ArcGIS API is QTY'; +COMMENT ON COLUMN fieldseeker.treatment.qtyunit IS 'Original attribute from ArcGIS API is QTYUNIT'; +COMMENT ON COLUMN fieldseeker.treatment.method IS 'Original attribute from ArcGIS API is METHOD'; +COMMENT ON COLUMN fieldseeker.treatment.equiptype IS 'Original attribute from ArcGIS API is EQUIPTYPE'; +COMMENT ON COLUMN fieldseeker.treatment.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.treatment.avetemp IS 'Original attribute from ArcGIS API is AVETEMP'; +COMMENT ON COLUMN fieldseeker.treatment.windspeed IS 'Original attribute from ArcGIS API is WINDSPEED'; +COMMENT ON COLUMN fieldseeker.treatment.winddir IS 'Original attribute from ArcGIS API is WINDDIR'; +COMMENT ON COLUMN fieldseeker.treatment.raingauge IS 'Original attribute from ArcGIS API is RAINGAUGE'; +COMMENT ON COLUMN fieldseeker.treatment.startdatetime IS 'Original attribute from ArcGIS API is STARTDATETIME'; +COMMENT ON COLUMN fieldseeker.treatment.enddatetime IS 'Original attribute from ArcGIS API is ENDDATETIME'; +COMMENT ON COLUMN fieldseeker.treatment.insp_id IS 'Original attribute from ArcGIS API is INSP_ID'; +COMMENT ON COLUMN fieldseeker.treatment.reviewed IS 'Original attribute from ArcGIS API is REVIEWED'; +COMMENT ON COLUMN fieldseeker.treatment.reviewedby IS 'Original attribute from ArcGIS API is REVIEWEDBY'; +COMMENT ON COLUMN fieldseeker.treatment.revieweddate IS 'Original attribute from ArcGIS API is REVIEWEDDATE'; +COMMENT ON COLUMN fieldseeker.treatment.locationname IS 'Original attribute from ArcGIS API is LOCATIONNAME'; +COMMENT ON COLUMN fieldseeker.treatment.zone IS 'Original attribute from ArcGIS API is ZONE'; +COMMENT ON COLUMN fieldseeker.treatment.warningoverride IS 'Original attribute from ArcGIS API is WARNINGOVERRIDE'; +COMMENT ON COLUMN fieldseeker.treatment.recordstatus IS 'Original attribute from ArcGIS API is RECORDSTATUS'; +COMMENT ON COLUMN fieldseeker.treatment.zone2 IS 'Original attribute from ArcGIS API is ZONE2'; +COMMENT ON COLUMN fieldseeker.treatment.treatacres IS 'Original attribute from ArcGIS API is TREATACRES'; +COMMENT ON COLUMN fieldseeker.treatment.tirecount IS 'Original attribute from ArcGIS API is TIRECOUNT'; +COMMENT ON COLUMN fieldseeker.treatment.cbcount IS 'Original attribute from ArcGIS API is CBCOUNT'; +COMMENT ON COLUMN fieldseeker.treatment.containercount IS 'Original attribute from ArcGIS API is CONTAINERCOUNT'; +COMMENT ON COLUMN fieldseeker.treatment.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.treatment.treatmentlength IS 'Original attribute from ArcGIS API is TREATMENTLENGTH'; +COMMENT ON COLUMN fieldseeker.treatment.treatmenthours IS 'Original attribute from ArcGIS API is TREATMENTHOURS'; +COMMENT ON COLUMN fieldseeker.treatment.treatmentlengthunits IS 'Original attribute from ArcGIS API is TREATMENTLENGTHUNITS'; +COMMENT ON COLUMN fieldseeker.treatment.linelocid IS 'Original attribute from ArcGIS API is LINELOCID'; +COMMENT ON COLUMN fieldseeker.treatment.pointlocid IS 'Original attribute from ArcGIS API is POINTLOCID'; +COMMENT ON COLUMN fieldseeker.treatment.polygonlocid IS 'Original attribute from ArcGIS API is POLYGONLOCID'; +COMMENT ON COLUMN fieldseeker.treatment.srid IS 'Original attribute from ArcGIS API is SRID'; +COMMENT ON COLUMN fieldseeker.treatment.sdid IS 'Original attribute from ArcGIS API is SDID'; +COMMENT ON COLUMN fieldseeker.treatment.barrierrouteid IS 'Original attribute from ArcGIS API is BARRIERROUTEID'; +COMMENT ON COLUMN fieldseeker.treatment.ulvrouteid IS 'Original attribute from ArcGIS API is ULVROUTEID'; +COMMENT ON COLUMN fieldseeker.treatment.fieldtech IS 'Original attribute from ArcGIS API is FIELDTECH'; +COMMENT ON COLUMN fieldseeker.treatment.ptaid IS 'Original attribute from ArcGIS API is PTAID'; +COMMENT ON COLUMN fieldseeker.treatment.flowrate IS 'Original attribute from ArcGIS API is FLOWRATE'; +COMMENT ON COLUMN fieldseeker.treatment.habitat IS 'Original attribute from ArcGIS API is HABITAT'; +COMMENT ON COLUMN fieldseeker.treatment.treathectares IS 'Original attribute from ArcGIS API is TREATHECTARES'; +COMMENT ON COLUMN fieldseeker.treatment.invloc IS 'Original attribute from ArcGIS API is INVLOC'; +COMMENT ON COLUMN fieldseeker.treatment.temp_sitecond IS 'Original attribute from ArcGIS API is temp_SITECOND'; +COMMENT ON COLUMN fieldseeker.treatment.sitecond IS 'Original attribute from ArcGIS API is SITECOND'; +COMMENT ON COLUMN fieldseeker.treatment.totalcostprodcut IS 'Original attribute from ArcGIS API is TotalCostProdcut'; +COMMENT ON COLUMN fieldseeker.treatment.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.treatment.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.treatment.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.treatment.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.treatment.targetspecies IS 'Original attribute from ArcGIS API is TARGETSPECIES'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_treatment_versioned(bigint, fieldseeker.treatment_mosquitoactivity_enum, double precision, fieldseeker.treatment_mosquitoproductareaunit_enum, varchar, double precision, fieldseeker.treatment_mosquitoproductmeasureunit_enum, fieldseeker.treatment_treatment_method_d558ca3ccf43440c8160758253967621_enum, fieldseeker.treatment_treatment_equiptype_45694d79_ff21_42cc_be4f_a0d1def4fba0_enum, varchar, double precision, double precision, fieldseeker.treatment_notinuiwinddirection_enum, double precision, timestamp, timestamp, uuid, fieldseeker.treatment_notinuit_f_enum, varchar, timestamp, varchar, varchar, fieldseeker.treatment_notinuit_f_enum, smallint, varchar, double precision, smallint, smallint, smallint, uuid, double precision, double precision, varchar, uuid, uuid, uuid, uuid, uuid, uuid, uuid, varchar, uuid, double precision, fieldseeker.treatment_treatment_habitat_0afee7eb_f9ea_4707_8483_cccfe60f0d16_enum, double precision, varchar, fieldseeker.treatment_treatment_sitecond_f812e1f64dcb4dc9a75da9d00abe6169_enum, fieldseeker.treatment_treatment_sitecond_5a15bf36fa124280b961f31cd1a9b571_enum, double precision, timestamp, varchar, timestamp, varchar, varchar) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.treatment - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.treatment - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.treatment ( - objectid, activity, treatarea, areaunit, product, qty, qtyunit, method, equiptype, comments, avetemp, windspeed, winddir, raingauge, startdatetime, enddatetime, insp_id, reviewed, reviewedby, revieweddate, locationname, zone, warningoverride, recordstatus, zone2, treatacres, tirecount, cbcount, containercount, globalid, treatmentlength, treatmenthours, treatmentlengthunits, linelocid, pointlocid, polygonlocid, srid, sdid, barrierrouteid, ulvrouteid, fieldtech, ptaid, flowrate, habitat, treathectares, invloc, temp_sitecond, sitecond, totalcostprodcut, creationdate, creator, editdate, editor, targetspecies, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.activity IS NOT DISTINCT FROM $2 AND - lv.treatarea IS NOT DISTINCT FROM $3 AND - lv.areaunit IS NOT DISTINCT FROM $4 AND - lv.product IS NOT DISTINCT FROM $5 AND - lv.qty IS NOT DISTINCT FROM $6 AND - lv.qtyunit IS NOT DISTINCT FROM $7 AND - lv.method IS NOT DISTINCT FROM $8 AND - lv.equiptype IS NOT DISTINCT FROM $9 AND - lv.comments IS NOT DISTINCT FROM $10 AND - lv.avetemp IS NOT DISTINCT FROM $11 AND - lv.windspeed IS NOT DISTINCT FROM $12 AND - lv.winddir IS NOT DISTINCT FROM $13 AND - lv.raingauge IS NOT DISTINCT FROM $14 AND - lv.startdatetime IS NOT DISTINCT FROM $15 AND - lv.enddatetime IS NOT DISTINCT FROM $16 AND - lv.insp_id IS NOT DISTINCT FROM $17 AND - lv.reviewed IS NOT DISTINCT FROM $18 AND - lv.reviewedby IS NOT DISTINCT FROM $19 AND - lv.revieweddate IS NOT DISTINCT FROM $20 AND - lv.locationname IS NOT DISTINCT FROM $21 AND - lv.zone IS NOT DISTINCT FROM $22 AND - lv.warningoverride IS NOT DISTINCT FROM $23 AND - lv.recordstatus IS NOT DISTINCT FROM $24 AND - lv.zone2 IS NOT DISTINCT FROM $25 AND - lv.treatacres IS NOT DISTINCT FROM $26 AND - lv.tirecount IS NOT DISTINCT FROM $27 AND - lv.cbcount IS NOT DISTINCT FROM $28 AND - lv.containercount IS NOT DISTINCT FROM $29 AND - lv.globalid IS NOT DISTINCT FROM $30 AND - lv.treatmentlength IS NOT DISTINCT FROM $31 AND - lv.treatmenthours IS NOT DISTINCT FROM $32 AND - lv.treatmentlengthunits IS NOT DISTINCT FROM $33 AND - lv.linelocid IS NOT DISTINCT FROM $34 AND - lv.pointlocid IS NOT DISTINCT FROM $35 AND - lv.polygonlocid IS NOT DISTINCT FROM $36 AND - lv.srid IS NOT DISTINCT FROM $37 AND - lv.sdid IS NOT DISTINCT FROM $38 AND - lv.barrierrouteid IS NOT DISTINCT FROM $39 AND - lv.ulvrouteid IS NOT DISTINCT FROM $40 AND - lv.fieldtech IS NOT DISTINCT FROM $41 AND - lv.ptaid IS NOT DISTINCT FROM $42 AND - lv.flowrate IS NOT DISTINCT FROM $43 AND - lv.habitat IS NOT DISTINCT FROM $44 AND - lv.treathectares IS NOT DISTINCT FROM $45 AND - lv.invloc IS NOT DISTINCT FROM $46 AND - lv.temp_sitecond IS NOT DISTINCT FROM $47 AND - lv.sitecond IS NOT DISTINCT FROM $48 AND - lv.totalcostprodcut IS NOT DISTINCT FROM $49 AND - lv.creationdate IS NOT DISTINCT FROM $50 AND - lv.creator IS NOT DISTINCT FROM $51 AND - lv.editdate IS NOT DISTINCT FROM $52 AND - lv.editor IS NOT DISTINCT FROM $53 AND - lv.targetspecies IS NOT DISTINCT FROM $54 - ) -RETURNING *; - --- Example usage: EXECUTE insert_treatment_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.TreatmentArea +-- Table definition for fieldseeker.treatmentarea -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; CREATE TABLE fieldseeker.treatmentarea ( objectid BIGSERIAL NOT NULL, + treat_id UUID, session_id UUID, treatdate TIMESTAMP, @@ -4513,72 +2043,42 @@ CREATE TABLE fieldseeker.treatmentarea ( editor VARCHAR(128), shape__area DOUBLE PRECISION, shape__length DOUBLE PRECISION, + geometry JSONB NOT NULL, + geospatial GEOMETRY(POLYGON, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.treatmentarea.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.treatmentarea.treatdate IS 'Treatment Date'; +COMMENT ON COLUMN fieldseeker.treatmentarea.treat_id IS 'Original attribute from ArcGIS API is TREAT_ID'; +COMMENT ON COLUMN fieldseeker.treatmentarea.session_id IS 'Original attribute from ArcGIS API is SESSION_ID'; +COMMENT ON COLUMN fieldseeker.treatmentarea.treatdate IS 'Original attribute from ArcGIS API is TREATDATE'; +COMMENT ON COLUMN fieldseeker.treatmentarea.comments IS 'Original attribute from ArcGIS API is COMMENTS'; +COMMENT ON COLUMN fieldseeker.treatmentarea.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.treatmentarea.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.treatmentarea.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.treatmentarea.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.treatmentarea.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.treatmentarea.notified IS 'Original attribute from ArcGIS API is Notified'; +COMMENT ON COLUMN fieldseeker.treatmentarea.type IS 'Original attribute from ArcGIS API is Type'; +COMMENT ON COLUMN fieldseeker.treatmentarea.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.treatmentarea.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.treatmentarea.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.treatmentarea.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.treatmentarea.shape__area IS 'Original attribute from ArcGIS API is Shape__Area'; +COMMENT ON COLUMN fieldseeker.treatmentarea.shape__length IS 'Original attribute from ArcGIS API is Shape__Length'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_treatmentarea_versioned(bigint, uuid, uuid, timestamp, varchar, uuid, varchar, timestamp, varchar, timestamp, smallint, varchar, timestamp, varchar, timestamp, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.treatmentarea - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.treatmentarea - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.treatmentarea ( - objectid, treat_id, session_id, treatdate, comments, globalid, created_user, created_date, last_edited_user, last_edited_date, notified, type, creationdate, creator, editdate, editor, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.treat_id IS NOT DISTINCT FROM $2 AND - lv.session_id IS NOT DISTINCT FROM $3 AND - lv.treatdate IS NOT DISTINCT FROM $4 AND - lv.comments IS NOT DISTINCT FROM $5 AND - lv.globalid IS NOT DISTINCT FROM $6 AND - lv.created_user IS NOT DISTINCT FROM $7 AND - lv.created_date IS NOT DISTINCT FROM $8 AND - lv.last_edited_user IS NOT DISTINCT FROM $9 AND - lv.last_edited_date IS NOT DISTINCT FROM $10 AND - lv.notified IS NOT DISTINCT FROM $11 AND - lv.type IS NOT DISTINCT FROM $12 AND - lv.creationdate IS NOT DISTINCT FROM $13 AND - lv.creator IS NOT DISTINCT FROM $14 AND - lv.editdate IS NOT DISTINCT FROM $15 AND - lv.editor IS NOT DISTINCT FROM $16 AND - lv.shape__area IS NOT DISTINCT FROM $17 AND - lv.shape__length IS NOT DISTINCT FROM $18 - ) -RETURNING *; - --- Example usage: EXECUTE insert_treatmentarea_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.Zones +-- Table definition for fieldseeker.zones -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; CREATE TABLE fieldseeker.zones ( objectid BIGSERIAL NOT NULL, + name VARCHAR(50), globalid UUID, created_user VARCHAR(255), @@ -4592,68 +2092,38 @@ CREATE TABLE fieldseeker.zones ( editor VARCHAR(128), shape__area DOUBLE PRECISION, shape__length DOUBLE PRECISION, + geometry JSONB NOT NULL, + geospatial GEOMETRY(POLYGON, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.zones.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.zones.name IS 'Name'; +COMMENT ON COLUMN fieldseeker.zones.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.zones.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.zones.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.zones.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.zones.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.zones.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.zones.active IS 'Original attribute from ArcGIS API is ACTIVE'; +COMMENT ON COLUMN fieldseeker.zones.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.zones.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.zones.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.zones.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.zones.shape__area IS 'Original attribute from ArcGIS API is Shape__Area'; +COMMENT ON COLUMN fieldseeker.zones.shape__length IS 'Original attribute from ArcGIS API is Shape__Length'; --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_zones_versioned(bigint, varchar, uuid, varchar, timestamp, varchar, timestamp, integer, timestamp, varchar, timestamp, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.zones - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.zones - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.zones ( - objectid, name, globalid, created_user, created_date, last_edited_user, last_edited_date, active, creationdate, creator, editdate, editor, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.active IS NOT DISTINCT FROM $8 AND - lv.creationdate IS NOT DISTINCT FROM $9 AND - lv.creator IS NOT DISTINCT FROM $10 AND - lv.editdate IS NOT DISTINCT FROM $11 AND - lv.editor IS NOT DISTINCT FROM $12 AND - lv.shape__area IS NOT DISTINCT FROM $13 AND - lv.shape__length IS NOT DISTINCT FROM $14 - ) -RETURNING *; - --- Example usage: EXECUTE insert_zones_versioned(id, value1, value2, ...); --- Table definition for fieldseeker.Zones2 +-- Table definition for fieldseeker.zones2 -- Includes versioning for tracking changes +-- When inserting a new row, VERSION defaults to 1 +-- When updating a row, insert a new row with the same ID but incremented VERSION +-- The most recent version of a row has the highest VERSION value CREATE SCHEMA IF NOT EXISTS fieldseeker; CREATE TABLE fieldseeker.zones2 ( objectid BIGSERIAL NOT NULL, + name VARCHAR(50), globalid UUID, created_user VARCHAR(255), @@ -4666,59 +2136,26 @@ CREATE TABLE fieldseeker.zones2 ( editor VARCHAR(128), shape__area DOUBLE PRECISION, shape__length DOUBLE PRECISION, + geometry JSONB NOT NULL, + geospatial GEOMETRY(POLYGON, 3857), VERSION INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (objectid, VERSION) ); -COMMENT ON COLUMN fieldseeker.zones2.VERSION IS 'Tracks version changes to the row. Increases when data is modified.'; -COMMENT ON COLUMN fieldseeker.zones2.name IS 'Name'; - --- Prepared statement for conditional insert with versioning --- Only inserts a new version if data has changed -PREPARE insert_zones2_versioned(bigint, varchar, uuid, varchar, timestamp, varchar, timestamp, timestamp, varchar, timestamp, varchar, double precision, double precision) AS -WITH --- Get the current latest version of this record -latest_version AS ( - SELECT * FROM fieldseeker.zones2 - WHERE objectid = $1 - ORDER BY VERSION DESC - LIMIT 1 -), --- Calculate the next version number -next_version AS ( - SELECT COALESCE(MAX(VERSION) + 1, 1) as version_num - FROM fieldseeker.zones2 - WHERE objectid = $1 -) --- Perform conditional insert -INSERT INTO fieldseeker.zones2 ( - objectid, name, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, shape__area, shape__length, - VERSION -) -SELECT - $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, - v.version_num -FROM next_version v -WHERE - -- Only insert if no record exists yet OR data has changed - NOT EXISTS (SELECT 1 FROM latest_version lv WHERE - lv.objectid IS NOT DISTINCT FROM $1 AND - lv.name IS NOT DISTINCT FROM $2 AND - lv.globalid IS NOT DISTINCT FROM $3 AND - lv.created_user IS NOT DISTINCT FROM $4 AND - lv.created_date IS NOT DISTINCT FROM $5 AND - lv.last_edited_user IS NOT DISTINCT FROM $6 AND - lv.last_edited_date IS NOT DISTINCT FROM $7 AND - lv.creationdate IS NOT DISTINCT FROM $8 AND - lv.creator IS NOT DISTINCT FROM $9 AND - lv.editdate IS NOT DISTINCT FROM $10 AND - lv.editor IS NOT DISTINCT FROM $11 AND - lv.shape__area IS NOT DISTINCT FROM $12 AND - lv.shape__length IS NOT DISTINCT FROM $13 - ) -RETURNING *; - --- Example usage: EXECUTE insert_zones2_versioned(id, value1, value2, ...); +COMMENT ON COLUMN fieldseeker.zones2.name IS 'Original attribute from ArcGIS API is NAME'; +COMMENT ON COLUMN fieldseeker.zones2.globalid IS 'Original attribute from ArcGIS API is GlobalID'; +COMMENT ON COLUMN fieldseeker.zones2.created_user IS 'Original attribute from ArcGIS API is created_user'; +COMMENT ON COLUMN fieldseeker.zones2.created_date IS 'Original attribute from ArcGIS API is created_date'; +COMMENT ON COLUMN fieldseeker.zones2.last_edited_user IS 'Original attribute from ArcGIS API is last_edited_user'; +COMMENT ON COLUMN fieldseeker.zones2.last_edited_date IS 'Original attribute from ArcGIS API is last_edited_date'; +COMMENT ON COLUMN fieldseeker.zones2.creationdate IS 'Original attribute from ArcGIS API is CreationDate'; +COMMENT ON COLUMN fieldseeker.zones2.creator IS 'Original attribute from ArcGIS API is Creator'; +COMMENT ON COLUMN fieldseeker.zones2.editdate IS 'Original attribute from ArcGIS API is EditDate'; +COMMENT ON COLUMN fieldseeker.zones2.editor IS 'Original attribute from ArcGIS API is Editor'; +COMMENT ON COLUMN fieldseeker.zones2.shape__area IS 'Original attribute from ArcGIS API is Shape__Area'; +COMMENT ON COLUMN fieldseeker.zones2.shape__length IS 'Original attribute from ArcGIS API is Shape__Length'; -- +goose Down DROP SCHEMA fieldseeker CASCADE; + + diff --git a/db/migrations/00017_fieldseeker_inserts.sql b/db/migrations/00017_fieldseeker_inserts.sql index 587ccd0b..ee52f349 100644 --- a/db/migrations/00017_fieldseeker_inserts.sql +++ b/db/migrations/00017_fieldseeker_inserts.sql @@ -2,7 +2,22 @@ -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_containerrelate( p_objectid bigint, - p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_inspsampleid uuid,p_mosquitoinspid uuid,p_treatmentid uuid,p_containertype varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_inspsampleid uuid, + p_mosquitoinspid uuid, + p_treatmentid uuid, + p_containertype varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -12,7 +27,22 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.containerrelate lv WHERE lv.objectid = p_objectid - AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.inspsampleid IS NOT DISTINCT FROM p_inspsampleid AND lv.mosquitoinspid IS NOT DISTINCT FROM p_mosquitoinspid AND lv.treatmentid IS NOT DISTINCT FROM p_treatmentid AND lv.containertype IS NOT DISTINCT FROM p_containertype AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.inspsampleid IS NOT DISTINCT FROM p_inspsampleid + AND lv.mosquitoinspid IS NOT DISTINCT FROM p_mosquitoinspid + AND lv.treatmentid IS NOT DISTINCT FROM p_treatmentid + AND lv.containertype IS NOT DISTINCT FROM p_containertype + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -34,11 +64,41 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.containerrelate ( objectid, - globalid, created_user, created_date, last_edited_user, last_edited_date, inspsampleid, mosquitoinspid, treatmentid, containertype, creationdate, creator, editdate, editor, + + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + inspsampleid, + mosquitoinspid, + treatmentid, + containertype, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_inspsampleid, p_mosquitoinspid, p_treatmentid, p_containertype, p_creationdate, p_creator, p_editdate, p_editor, + + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_inspsampleid, + p_mosquitoinspid, + p_treatmentid, + p_containertype, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -46,12 +106,24 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_fieldscoutinglog( p_objectid bigint, - p_status smallint,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_status smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -61,7 +133,19 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.fieldscoutinglog lv WHERE lv.objectid = p_objectid - AND lv.status IS NOT DISTINCT FROM p_status AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.status IS NOT DISTINCT FROM p_status + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -83,11 +167,35 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.fieldscoutinglog ( objectid, - status, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, + + status, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_status, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_creationdate, p_creator, p_editdate, p_editor, + + p_status, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -95,12 +203,25 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_habitatrelate( p_objectid bigint, - p_foreign_id uuid,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_habitattype varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_foreign_id uuid, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_habitattype varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -110,7 +231,20 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.habitatrelate lv WHERE lv.objectid = p_objectid - AND lv.foreign_id IS NOT DISTINCT FROM p_foreign_id AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.habitattype IS NOT DISTINCT FROM p_habitattype AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.foreign_id IS NOT DISTINCT FROM p_foreign_id + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.habitattype IS NOT DISTINCT FROM p_habitattype + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -132,11 +266,37 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.habitatrelate ( objectid, - foreign_id, globalid, created_user, created_date, last_edited_user, last_edited_date, habitattype, creationdate, creator, editdate, editor, + + foreign_id, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + habitattype, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_foreign_id, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_habitattype, p_creationdate, p_creator, p_editdate, p_editor, + + p_foreign_id, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_habitattype, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -144,61 +304,38 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd --- +goose StatementBegin -CREATE OR REPLACE FUNCTION fieldseeker.insert_inspectionsample( - p_objectid bigint, - p_insp_id uuid,p_sampleid varchar,p_processed smallint,p_idbytech varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar -) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ -DECLARE - v_next_version integer; - v_changes_exist boolean; -BEGIN - -- Check if changes exist - SELECT NOT EXISTS ( - SELECT 1 FROM fieldseeker.inspectionsample lv - WHERE lv.objectid = p_objectid - AND lv.insp_id IS NOT DISTINCT FROM p_insp_id AND lv.sampleid IS NOT DISTINCT FROM p_sampleid AND lv.processed IS NOT DISTINCT FROM p_processed AND lv.idbytech IS NOT DISTINCT FROM p_idbytech AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor - ORDER BY VERSION DESC LIMIT 1 - ) INTO v_changes_exist; - - -- If no changes, return false with current version - IF NOT v_changes_exist THEN - RETURN QUERY - SELECT - FALSE AS row_inserted, - (SELECT VERSION FROM fieldseeker.inspectionsample - WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; - RETURN; - END IF; - - -- Calculate next version - SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version - FROM fieldseeker.inspectionsample - WHERE objectid = p_objectid; - - -- Insert new version - INSERT INTO fieldseeker.inspectionsample ( - objectid, - insp_id, sampleid, processed, idbytech, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, - VERSION - ) VALUES ( - p_objectid, - p_insp_id, p_sampleid, p_processed, p_idbytech, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_creationdate, p_creator, p_editdate, p_editor, - v_next_version - ); - - -- Return success with new version - RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; -END; -$$ LANGUAGE plpgsql; --- +goose StatementEnd -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_inspectionsampledetail( p_objectid bigint, - p_inspsample_id uuid,p_fieldspecies varchar,p_flarvcount smallint,p_fpupcount smallint,p_feggcount smallint,p_flstages varchar,p_fdomstage varchar,p_fadultact varchar,p_labspecies varchar,p_llarvcount smallint,p_lpupcount smallint,p_leggcount smallint,p_ldomstage varchar,p_comments varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_processed smallint,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_inspsample_id uuid, + p_fieldspecies varchar, + p_flarvcount smallint, + p_fpupcount smallint, + p_feggcount smallint, + p_flstages varchar, + p_fdomstage varchar, + p_fadultact varchar, + p_labspecies varchar, + p_llarvcount smallint, + p_lpupcount smallint, + p_leggcount smallint, + p_ldomstage varchar, + p_comments varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_processed smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -208,7 +345,33 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.inspectionsampledetail lv WHERE lv.objectid = p_objectid - AND lv.inspsample_id IS NOT DISTINCT FROM p_inspsample_id AND lv.fieldspecies IS NOT DISTINCT FROM p_fieldspecies AND lv.flarvcount IS NOT DISTINCT FROM p_flarvcount AND lv.fpupcount IS NOT DISTINCT FROM p_fpupcount AND lv.feggcount IS NOT DISTINCT FROM p_feggcount AND lv.flstages IS NOT DISTINCT FROM p_flstages AND lv.fdomstage IS NOT DISTINCT FROM p_fdomstage AND lv.fadultact IS NOT DISTINCT FROM p_fadultact AND lv.labspecies IS NOT DISTINCT FROM p_labspecies AND lv.llarvcount IS NOT DISTINCT FROM p_llarvcount AND lv.lpupcount IS NOT DISTINCT FROM p_lpupcount AND lv.leggcount IS NOT DISTINCT FROM p_leggcount AND lv.ldomstage IS NOT DISTINCT FROM p_ldomstage AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.processed IS NOT DISTINCT FROM p_processed AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.inspsample_id IS NOT DISTINCT FROM p_inspsample_id + AND lv.fieldspecies IS NOT DISTINCT FROM p_fieldspecies + AND lv.flarvcount IS NOT DISTINCT FROM p_flarvcount + AND lv.fpupcount IS NOT DISTINCT FROM p_fpupcount + AND lv.feggcount IS NOT DISTINCT FROM p_feggcount + AND lv.flstages IS NOT DISTINCT FROM p_flstages + AND lv.fdomstage IS NOT DISTINCT FROM p_fdomstage + AND lv.fadultact IS NOT DISTINCT FROM p_fadultact + AND lv.labspecies IS NOT DISTINCT FROM p_labspecies + AND lv.llarvcount IS NOT DISTINCT FROM p_llarvcount + AND lv.lpupcount IS NOT DISTINCT FROM p_lpupcount + AND lv.leggcount IS NOT DISTINCT FROM p_leggcount + AND lv.ldomstage IS NOT DISTINCT FROM p_ldomstage + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -230,11 +393,63 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.inspectionsampledetail ( objectid, - inspsample_id, fieldspecies, flarvcount, fpupcount, feggcount, flstages, fdomstage, fadultact, labspecies, llarvcount, lpupcount, leggcount, ldomstage, comments, globalid, created_user, created_date, last_edited_user, last_edited_date, processed, creationdate, creator, editdate, editor, + + inspsample_id, + fieldspecies, + flarvcount, + fpupcount, + feggcount, + flstages, + fdomstage, + fadultact, + labspecies, + llarvcount, + lpupcount, + leggcount, + ldomstage, + comments, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + processed, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_inspsample_id, p_fieldspecies, p_flarvcount, p_fpupcount, p_feggcount, p_flstages, p_fdomstage, p_fadultact, p_labspecies, p_llarvcount, p_lpupcount, p_leggcount, p_ldomstage, p_comments, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_processed, p_creationdate, p_creator, p_editdate, p_editor, + + p_inspsample_id, + p_fieldspecies, + p_flarvcount, + p_fpupcount, + p_feggcount, + p_flstages, + p_fdomstage, + p_fadultact, + p_labspecies, + p_llarvcount, + p_lpupcount, + p_leggcount, + p_ldomstage, + p_comments, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_processed, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -242,12 +457,170 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_inspectionsample( + p_objectid bigint, + + p_insp_id uuid, + p_sampleid varchar, + p_processed smallint, + p_idbytech varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.inspectionsample lv + WHERE lv.objectid = p_objectid + + AND lv.insp_id IS NOT DISTINCT FROM p_insp_id + AND lv.sampleid IS NOT DISTINCT FROM p_sampleid + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.idbytech IS NOT DISTINCT FROM p_idbytech + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.inspectionsample + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.inspectionsample + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.inspectionsample ( + objectid, + + insp_id, + sampleid, + processed, + idbytech, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_insp_id, + p_sampleid, + p_processed, + p_idbytech, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_linelocation( p_objectid bigint, - p_name varchar,p_zone varchar,p_habitat varchar,p_priority varchar,p_usetype varchar,p_active smallint,p_description varchar,p_accessdesc varchar,p_comments varchar,p_symbology varchar,p_externalid varchar,p_acres double precision,p_nextactiondatescheduled timestamp,p_larvinspectinterval smallint,p_length_ft double precision,p_width_ft double precision,p_zone2 varchar,p_locationnumber integer,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_lastinspectdate timestamp,p_lastinspectbreeding varchar,p_lastinspectavglarvae double precision,p_lastinspectavgpupae double precision,p_lastinspectlstages varchar,p_lastinspectactiontaken varchar,p_lastinspectfieldspecies varchar,p_lasttreatdate timestamp,p_lasttreatproduct varchar,p_lasttreatqty double precision,p_lasttreatqtyunit varchar,p_hectares double precision,p_lastinspectactivity varchar,p_lasttreatactivity varchar,p_length_meters double precision,p_width_meters double precision,p_lastinspectconditions varchar,p_waterorigin varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_jurisdiction varchar,p_shape__length double precision + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_symbology varchar, + p_externalid varchar, + p_acres double precision, + p_nextactiondatescheduled timestamp, + p_larvinspectinterval smallint, + p_length_ft double precision, + p_width_ft double precision, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_lastinspectdate timestamp, + p_lastinspectbreeding varchar, + p_lastinspectavglarvae double precision, + p_lastinspectavgpupae double precision, + p_lastinspectlstages varchar, + p_lastinspectactiontaken varchar, + p_lastinspectfieldspecies varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_hectares double precision, + p_lastinspectactivity varchar, + p_lasttreatactivity varchar, + p_length_meters double precision, + p_width_meters double precision, + p_lastinspectconditions varchar, + p_waterorigin varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -257,7 +630,56 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.linelocation lv WHERE lv.objectid = p_objectid - AND lv.name IS NOT DISTINCT FROM p_name AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.habitat IS NOT DISTINCT FROM p_habitat AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.usetype IS NOT DISTINCT FROM p_usetype AND lv.active IS NOT DISTINCT FROM p_active AND lv.description IS NOT DISTINCT FROM p_description AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.symbology IS NOT DISTINCT FROM p_symbology AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.acres IS NOT DISTINCT FROM p_acres AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval AND lv.length_ft IS NOT DISTINCT FROM p_length_ft AND lv.width_ft IS NOT DISTINCT FROM p_width_ft AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit AND lv.hectares IS NOT DISTINCT FROM p_hectares AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity AND lv.length_meters IS NOT DISTINCT FROM p_length_meters AND lv.width_meters IS NOT DISTINCT FROM p_width_meters AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.acres IS NOT DISTINCT FROM p_acres + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval + AND lv.length_ft IS NOT DISTINCT FROM p_length_ft + AND lv.width_ft IS NOT DISTINCT FROM p_width_ft + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding + AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae + AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae + AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages + AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken + AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.hectares IS NOT DISTINCT FROM p_hectares + AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.length_meters IS NOT DISTINCT FROM p_length_meters + AND lv.width_meters IS NOT DISTINCT FROM p_width_meters + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -279,11 +701,109 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.linelocation ( objectid, - name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, acres, nextactiondatescheduled, larvinspectinterval, length_ft, width_ft, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, hectares, lastinspectactivity, lasttreatactivity, length_meters, width_meters, lastinspectconditions, waterorigin, creationdate, creator, editdate, editor, jurisdiction, shape__length, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + acres, + nextactiondatescheduled, + larvinspectinterval, + length_ft, + width_ft, + zone2, + locationnumber, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + lastinspectdate, + lastinspectbreeding, + lastinspectavglarvae, + lastinspectavgpupae, + lastinspectlstages, + lastinspectactiontaken, + lastinspectfieldspecies, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + hectares, + lastinspectactivity, + lasttreatactivity, + length_meters, + width_meters, + lastinspectconditions, + waterorigin, + creationdate, + creator, + editdate, + editor, + jurisdiction, + shape__length, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_name, p_zone, p_habitat, p_priority, p_usetype, p_active, p_description, p_accessdesc, p_comments, p_symbology, p_externalid, p_acres, p_nextactiondatescheduled, p_larvinspectinterval, p_length_ft, p_width_ft, p_zone2, p_locationnumber, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_lastinspectdate, p_lastinspectbreeding, p_lastinspectavglarvae, p_lastinspectavgpupae, p_lastinspectlstages, p_lastinspectactiontaken, p_lastinspectfieldspecies, p_lasttreatdate, p_lasttreatproduct, p_lasttreatqty, p_lasttreatqtyunit, p_hectares, p_lastinspectactivity, p_lasttreatactivity, p_length_meters, p_width_meters, p_lastinspectconditions, p_waterorigin, p_creationdate, p_creator, p_editdate, p_editor, p_jurisdiction, p_shape__length, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_acres, + p_nextactiondatescheduled, + p_larvinspectinterval, + p_length_ft, + p_width_ft, + p_zone2, + p_locationnumber, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_lastinspectdate, + p_lastinspectbreeding, + p_lastinspectavglarvae, + p_lastinspectavgpupae, + p_lastinspectlstages, + p_lastinspectactiontaken, + p_lastinspectfieldspecies, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_hectares, + p_lastinspectactivity, + p_lasttreatactivity, + p_length_meters, + p_width_meters, + p_lastinspectconditions, + p_waterorigin, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_shape__length, + p_geometry, + p_geospatial, v_next_version ); @@ -291,12 +811,25 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_locationtracking( p_objectid bigint, - p_accuracy double precision,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_globalid uuid,p_fieldtech varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_accuracy double precision, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_globalid uuid, + p_fieldtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -306,7 +839,20 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.locationtracking lv WHERE lv.objectid = p_objectid - AND lv.accuracy IS NOT DISTINCT FROM p_accuracy AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.accuracy IS NOT DISTINCT FROM p_accuracy + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -328,11 +874,37 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.locationtracking ( objectid, - accuracy, created_user, created_date, last_edited_user, last_edited_date, globalid, fieldtech, creationdate, creator, editdate, editor, + + accuracy, + created_user, + created_date, + last_edited_user, + last_edited_date, + globalid, + fieldtech, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_accuracy, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_globalid, p_fieldtech, p_creationdate, p_creator, p_editdate, p_editor, + + p_accuracy, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_globalid, + p_fieldtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -340,12 +912,70 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_mosquitoinspection( p_objectid bigint, - p_numdips smallint,p_activity varchar,p_breeding varchar,p_totlarvae smallint,p_totpupae smallint,p_eggs smallint,p_posdips smallint,p_adultact varchar,p_lstages varchar,p_domstage varchar,p_actiontaken varchar,p_comments varchar,p_avetemp double precision,p_windspeed double precision,p_raingauge double precision,p_startdatetime timestamp,p_enddatetime timestamp,p_winddir varchar,p_avglarvae double precision,p_avgpupae double precision,p_reviewed smallint,p_reviewedby varchar,p_revieweddate timestamp,p_locationname varchar,p_zone varchar,p_recordstatus smallint,p_zone2 varchar,p_personalcontact smallint,p_tirecount smallint,p_cbcount smallint,p_containercount smallint,p_fieldspecies varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_linelocid uuid,p_pointlocid uuid,p_polygonlocid uuid,p_srid uuid,p_fieldtech varchar,p_larvaepresent smallint,p_pupaepresent smallint,p_sdid uuid,p_sitecond varchar,p_positivecontainercount smallint,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_jurisdiction varchar,p_visualmonitoring smallint,p_vmcomments varchar,p_adminaction varchar,p_ptaid uuid + + p_numdips smallint, + p_activity varchar, + p_breeding varchar, + p_totlarvae smallint, + p_totpupae smallint, + p_eggs smallint, + p_posdips smallint, + p_adultact varchar, + p_lstages varchar, + p_domstage varchar, + p_actiontaken varchar, + p_comments varchar, + p_avetemp double precision, + p_windspeed double precision, + p_raingauge double precision, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_winddir varchar, + p_avglarvae double precision, + p_avgpupae double precision, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_recordstatus smallint, + p_zone2 varchar, + p_personalcontact smallint, + p_tirecount smallint, + p_cbcount smallint, + p_containercount smallint, + p_fieldspecies varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_srid uuid, + p_fieldtech varchar, + p_larvaepresent smallint, + p_pupaepresent smallint, + p_sdid uuid, + p_sitecond varchar, + p_positivecontainercount smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_visualmonitoring smallint, + p_vmcomments varchar, + p_adminaction varchar, + p_ptaid uuid, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -355,7 +985,65 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.mosquitoinspection lv WHERE lv.objectid = p_objectid - AND lv.numdips IS NOT DISTINCT FROM p_numdips AND lv.activity IS NOT DISTINCT FROM p_activity AND lv.breeding IS NOT DISTINCT FROM p_breeding AND lv.totlarvae IS NOT DISTINCT FROM p_totlarvae AND lv.totpupae IS NOT DISTINCT FROM p_totpupae AND lv.eggs IS NOT DISTINCT FROM p_eggs AND lv.posdips IS NOT DISTINCT FROM p_posdips AND lv.adultact IS NOT DISTINCT FROM p_adultact AND lv.lstages IS NOT DISTINCT FROM p_lstages AND lv.domstage IS NOT DISTINCT FROM p_domstage AND lv.actiontaken IS NOT DISTINCT FROM p_actiontaken AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.avetemp IS NOT DISTINCT FROM p_avetemp AND lv.windspeed IS NOT DISTINCT FROM p_windspeed AND lv.raingauge IS NOT DISTINCT FROM p_raingauge AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime AND lv.winddir IS NOT DISTINCT FROM p_winddir AND lv.avglarvae IS NOT DISTINCT FROM p_avglarvae AND lv.avgpupae IS NOT DISTINCT FROM p_avgpupae AND lv.reviewed IS NOT DISTINCT FROM p_reviewed AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate AND lv.locationname IS NOT DISTINCT FROM p_locationname AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.personalcontact IS NOT DISTINCT FROM p_personalcontact AND lv.tirecount IS NOT DISTINCT FROM p_tirecount AND lv.cbcount IS NOT DISTINCT FROM p_cbcount AND lv.containercount IS NOT DISTINCT FROM p_containercount AND lv.fieldspecies IS NOT DISTINCT FROM p_fieldspecies AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.linelocid IS NOT DISTINCT FROM p_linelocid AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid AND lv.srid IS NOT DISTINCT FROM p_srid AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech AND lv.larvaepresent IS NOT DISTINCT FROM p_larvaepresent AND lv.pupaepresent IS NOT DISTINCT FROM p_pupaepresent AND lv.sdid IS NOT DISTINCT FROM p_sdid AND lv.sitecond IS NOT DISTINCT FROM p_sitecond AND lv.positivecontainercount IS NOT DISTINCT FROM p_positivecontainercount AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction AND lv.visualmonitoring IS NOT DISTINCT FROM p_visualmonitoring AND lv.vmcomments IS NOT DISTINCT FROM p_vmcomments AND lv.adminaction IS NOT DISTINCT FROM p_adminaction AND lv.ptaid IS NOT DISTINCT FROM p_ptaid + + AND lv.numdips IS NOT DISTINCT FROM p_numdips + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.breeding IS NOT DISTINCT FROM p_breeding + AND lv.totlarvae IS NOT DISTINCT FROM p_totlarvae + AND lv.totpupae IS NOT DISTINCT FROM p_totpupae + AND lv.eggs IS NOT DISTINCT FROM p_eggs + AND lv.posdips IS NOT DISTINCT FROM p_posdips + AND lv.adultact IS NOT DISTINCT FROM p_adultact + AND lv.lstages IS NOT DISTINCT FROM p_lstages + AND lv.domstage IS NOT DISTINCT FROM p_domstage + AND lv.actiontaken IS NOT DISTINCT FROM p_actiontaken + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.avglarvae IS NOT DISTINCT FROM p_avglarvae + AND lv.avgpupae IS NOT DISTINCT FROM p_avgpupae + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.personalcontact IS NOT DISTINCT FROM p_personalcontact + AND lv.tirecount IS NOT DISTINCT FROM p_tirecount + AND lv.cbcount IS NOT DISTINCT FROM p_cbcount + AND lv.containercount IS NOT DISTINCT FROM p_containercount + AND lv.fieldspecies IS NOT DISTINCT FROM p_fieldspecies + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.larvaepresent IS NOT DISTINCT FROM p_larvaepresent + AND lv.pupaepresent IS NOT DISTINCT FROM p_pupaepresent + AND lv.sdid IS NOT DISTINCT FROM p_sdid + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.positivecontainercount IS NOT DISTINCT FROM p_positivecontainercount + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.visualmonitoring IS NOT DISTINCT FROM p_visualmonitoring + AND lv.vmcomments IS NOT DISTINCT FROM p_vmcomments + AND lv.adminaction IS NOT DISTINCT FROM p_adminaction + AND lv.ptaid IS NOT DISTINCT FROM p_ptaid + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -377,11 +1065,127 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.mosquitoinspection ( objectid, - numdips, activity, breeding, totlarvae, totpupae, eggs, posdips, adultact, lstages, domstage, actiontaken, comments, avetemp, windspeed, raingauge, startdatetime, enddatetime, winddir, avglarvae, avgpupae, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, personalcontact, tirecount, cbcount, containercount, fieldspecies, globalid, created_user, created_date, last_edited_user, last_edited_date, linelocid, pointlocid, polygonlocid, srid, fieldtech, larvaepresent, pupaepresent, sdid, sitecond, positivecontainercount, creationdate, creator, editdate, editor, jurisdiction, visualmonitoring, vmcomments, adminaction, ptaid, + + numdips, + activity, + breeding, + totlarvae, + totpupae, + eggs, + posdips, + adultact, + lstages, + domstage, + actiontaken, + comments, + avetemp, + windspeed, + raingauge, + startdatetime, + enddatetime, + winddir, + avglarvae, + avgpupae, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + recordstatus, + zone2, + personalcontact, + tirecount, + cbcount, + containercount, + fieldspecies, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + linelocid, + pointlocid, + polygonlocid, + srid, + fieldtech, + larvaepresent, + pupaepresent, + sdid, + sitecond, + positivecontainercount, + creationdate, + creator, + editdate, + editor, + jurisdiction, + visualmonitoring, + vmcomments, + adminaction, + ptaid, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_numdips, p_activity, p_breeding, p_totlarvae, p_totpupae, p_eggs, p_posdips, p_adultact, p_lstages, p_domstage, p_actiontaken, p_comments, p_avetemp, p_windspeed, p_raingauge, p_startdatetime, p_enddatetime, p_winddir, p_avglarvae, p_avgpupae, p_reviewed, p_reviewedby, p_revieweddate, p_locationname, p_zone, p_recordstatus, p_zone2, p_personalcontact, p_tirecount, p_cbcount, p_containercount, p_fieldspecies, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_linelocid, p_pointlocid, p_polygonlocid, p_srid, p_fieldtech, p_larvaepresent, p_pupaepresent, p_sdid, p_sitecond, p_positivecontainercount, p_creationdate, p_creator, p_editdate, p_editor, p_jurisdiction, p_visualmonitoring, p_vmcomments, p_adminaction, p_ptaid, + + p_numdips, + p_activity, + p_breeding, + p_totlarvae, + p_totpupae, + p_eggs, + p_posdips, + p_adultact, + p_lstages, + p_domstage, + p_actiontaken, + p_comments, + p_avetemp, + p_windspeed, + p_raingauge, + p_startdatetime, + p_enddatetime, + p_winddir, + p_avglarvae, + p_avgpupae, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_recordstatus, + p_zone2, + p_personalcontact, + p_tirecount, + p_cbcount, + p_containercount, + p_fieldspecies, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_srid, + p_fieldtech, + p_larvaepresent, + p_pupaepresent, + p_sdid, + p_sitecond, + p_positivecontainercount, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_visualmonitoring, + p_vmcomments, + p_adminaction, + p_ptaid, + p_geometry, + p_geospatial, v_next_version ); @@ -389,12 +1193,57 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_pointlocation( p_objectid bigint, - p_name varchar,p_zone varchar,p_habitat varchar,p_priority varchar,p_usetype varchar,p_active smallint,p_description varchar,p_accessdesc varchar,p_comments varchar,p_symbology varchar,p_externalid varchar,p_nextactiondatescheduled timestamp,p_larvinspectinterval smallint,p_zone2 varchar,p_locationnumber integer,p_globalid uuid,p_stype varchar,p_lastinspectdate timestamp,p_lastinspectbreeding varchar,p_lastinspectavglarvae double precision,p_lastinspectavgpupae double precision,p_lastinspectlstages varchar,p_lastinspectactiontaken varchar,p_lastinspectfieldspecies varchar,p_lasttreatdate timestamp,p_lasttreatproduct varchar,p_lasttreatqty double precision,p_lasttreatqtyunit varchar,p_lastinspectactivity varchar,p_lasttreatactivity varchar,p_lastinspectconditions varchar,p_waterorigin varchar,p_x double precision,p_y double precision,p_assignedtech varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_jurisdiction varchar,p_deactivate_reason varchar,p_scalarpriority integer,p_sourcestatus varchar + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_symbology varchar, + p_externalid varchar, + p_nextactiondatescheduled timestamp, + p_larvinspectinterval smallint, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_stype varchar, + p_lastinspectdate timestamp, + p_lastinspectbreeding varchar, + p_lastinspectavglarvae double precision, + p_lastinspectavgpupae double precision, + p_lastinspectlstages varchar, + p_lastinspectactiontaken varchar, + p_lastinspectfieldspecies varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_lastinspectactivity varchar, + p_lasttreatactivity varchar, + p_lastinspectconditions varchar, + p_waterorigin varchar, + p_x double precision, + p_y double precision, + p_assignedtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_deactivate_reason varchar, + p_scalarpriority integer, + p_sourcestatus varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -404,7 +1253,52 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.pointlocation lv WHERE lv.objectid = p_objectid - AND lv.name IS NOT DISTINCT FROM p_name AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.habitat IS NOT DISTINCT FROM p_habitat AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.usetype IS NOT DISTINCT FROM p_usetype AND lv.active IS NOT DISTINCT FROM p_active AND lv.description IS NOT DISTINCT FROM p_description AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.symbology IS NOT DISTINCT FROM p_symbology AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.stype IS NOT DISTINCT FROM p_stype AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin AND lv.x IS NOT DISTINCT FROM p_x AND lv.y IS NOT DISTINCT FROM p_y AND lv.assignedtech IS NOT DISTINCT FROM p_assignedtech AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction AND lv.deactivate_reason IS NOT DISTINCT FROM p_deactivate_reason AND lv.scalarpriority IS NOT DISTINCT FROM p_scalarpriority AND lv.sourcestatus IS NOT DISTINCT FROM p_sourcestatus + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.stype IS NOT DISTINCT FROM p_stype + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding + AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae + AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae + AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages + AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken + AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin + AND lv.x IS NOT DISTINCT FROM p_x + AND lv.y IS NOT DISTINCT FROM p_y + AND lv.assignedtech IS NOT DISTINCT FROM p_assignedtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.deactivate_reason IS NOT DISTINCT FROM p_deactivate_reason + AND lv.scalarpriority IS NOT DISTINCT FROM p_scalarpriority + AND lv.sourcestatus IS NOT DISTINCT FROM p_sourcestatus + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -426,11 +1320,101 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.pointlocation ( objectid, - name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, nextactiondatescheduled, larvinspectinterval, zone2, locationnumber, globalid, stype, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, lastinspectactivity, lasttreatactivity, lastinspectconditions, waterorigin, x, y, assignedtech, creationdate, creator, editdate, editor, jurisdiction, deactivate_reason, scalarpriority, sourcestatus, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + nextactiondatescheduled, + larvinspectinterval, + zone2, + locationnumber, + globalid, + stype, + lastinspectdate, + lastinspectbreeding, + lastinspectavglarvae, + lastinspectavgpupae, + lastinspectlstages, + lastinspectactiontaken, + lastinspectfieldspecies, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + lastinspectactivity, + lasttreatactivity, + lastinspectconditions, + waterorigin, + x, + y, + assignedtech, + creationdate, + creator, + editdate, + editor, + jurisdiction, + deactivate_reason, + scalarpriority, + sourcestatus, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_name, p_zone, p_habitat, p_priority, p_usetype, p_active, p_description, p_accessdesc, p_comments, p_symbology, p_externalid, p_nextactiondatescheduled, p_larvinspectinterval, p_zone2, p_locationnumber, p_globalid, p_stype, p_lastinspectdate, p_lastinspectbreeding, p_lastinspectavglarvae, p_lastinspectavgpupae, p_lastinspectlstages, p_lastinspectactiontaken, p_lastinspectfieldspecies, p_lasttreatdate, p_lasttreatproduct, p_lasttreatqty, p_lasttreatqtyunit, p_lastinspectactivity, p_lasttreatactivity, p_lastinspectconditions, p_waterorigin, p_x, p_y, p_assignedtech, p_creationdate, p_creator, p_editdate, p_editor, p_jurisdiction, p_deactivate_reason, p_scalarpriority, p_sourcestatus, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_nextactiondatescheduled, + p_larvinspectinterval, + p_zone2, + p_locationnumber, + p_globalid, + p_stype, + p_lastinspectdate, + p_lastinspectbreeding, + p_lastinspectavglarvae, + p_lastinspectavgpupae, + p_lastinspectlstages, + p_lastinspectactiontaken, + p_lastinspectfieldspecies, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_lastinspectactivity, + p_lasttreatactivity, + p_lastinspectconditions, + p_waterorigin, + p_x, + p_y, + p_assignedtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_deactivate_reason, + p_scalarpriority, + p_sourcestatus, + p_geometry, + p_geospatial, v_next_version ); @@ -438,12 +1422,55 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_polygonlocation( p_objectid bigint, - p_name varchar,p_zone varchar,p_habitat varchar,p_priority varchar,p_usetype varchar,p_active smallint,p_description varchar,p_accessdesc varchar,p_comments varchar,p_symbology varchar,p_externalid varchar,p_acres double precision,p_nextactiondatescheduled timestamp,p_larvinspectinterval smallint,p_zone2 varchar,p_locationnumber integer,p_globalid uuid,p_lastinspectdate timestamp,p_lastinspectbreeding varchar,p_lastinspectavglarvae double precision,p_lastinspectavgpupae double precision,p_lastinspectlstages varchar,p_lastinspectactiontaken varchar,p_lastinspectfieldspecies varchar,p_lasttreatdate timestamp,p_lasttreatproduct varchar,p_lasttreatqty double precision,p_lasttreatqtyunit varchar,p_hectares double precision,p_lastinspectactivity varchar,p_lasttreatactivity varchar,p_lastinspectconditions varchar,p_waterorigin varchar,p_filter varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_jurisdiction varchar,p_shape__area double precision,p_shape__length double precision + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_symbology varchar, + p_externalid varchar, + p_acres double precision, + p_nextactiondatescheduled timestamp, + p_larvinspectinterval smallint, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_lastinspectdate timestamp, + p_lastinspectbreeding varchar, + p_lastinspectavglarvae double precision, + p_lastinspectavgpupae double precision, + p_lastinspectlstages varchar, + p_lastinspectactiontaken varchar, + p_lastinspectfieldspecies varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_hectares double precision, + p_lastinspectactivity varchar, + p_lasttreatactivity varchar, + p_lastinspectconditions varchar, + p_waterorigin varchar, + p_filter varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_jurisdiction varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -453,7 +1480,50 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.polygonlocation lv WHERE lv.objectid = p_objectid - AND lv.name IS NOT DISTINCT FROM p_name AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.habitat IS NOT DISTINCT FROM p_habitat AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.usetype IS NOT DISTINCT FROM p_usetype AND lv.active IS NOT DISTINCT FROM p_active AND lv.description IS NOT DISTINCT FROM p_description AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.symbology IS NOT DISTINCT FROM p_symbology AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.acres IS NOT DISTINCT FROM p_acres AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit AND lv.hectares IS NOT DISTINCT FROM p_hectares AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin AND lv.filter IS NOT DISTINCT FROM p_filter AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction AND lv.shape__area IS NOT DISTINCT FROM p_shape__area AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.acres IS NOT DISTINCT FROM p_acres + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.larvinspectinterval IS NOT DISTINCT FROM p_larvinspectinterval + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectbreeding IS NOT DISTINCT FROM p_lastinspectbreeding + AND lv.lastinspectavglarvae IS NOT DISTINCT FROM p_lastinspectavglarvae + AND lv.lastinspectavgpupae IS NOT DISTINCT FROM p_lastinspectavgpupae + AND lv.lastinspectlstages IS NOT DISTINCT FROM p_lastinspectlstages + AND lv.lastinspectactiontaken IS NOT DISTINCT FROM p_lastinspectactiontaken + AND lv.lastinspectfieldspecies IS NOT DISTINCT FROM p_lastinspectfieldspecies + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.hectares IS NOT DISTINCT FROM p_hectares + AND lv.lastinspectactivity IS NOT DISTINCT FROM p_lastinspectactivity + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.waterorigin IS NOT DISTINCT FROM p_waterorigin + AND lv.filter IS NOT DISTINCT FROM p_filter + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -475,11 +1545,97 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.polygonlocation ( objectid, - name, zone, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, acres, nextactiondatescheduled, larvinspectinterval, zone2, locationnumber, globalid, lastinspectdate, lastinspectbreeding, lastinspectavglarvae, lastinspectavgpupae, lastinspectlstages, lastinspectactiontaken, lastinspectfieldspecies, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, hectares, lastinspectactivity, lasttreatactivity, lastinspectconditions, waterorigin, filter, creationdate, creator, editdate, editor, jurisdiction, shape__area, shape__length, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + acres, + nextactiondatescheduled, + larvinspectinterval, + zone2, + locationnumber, + globalid, + lastinspectdate, + lastinspectbreeding, + lastinspectavglarvae, + lastinspectavgpupae, + lastinspectlstages, + lastinspectactiontaken, + lastinspectfieldspecies, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + hectares, + lastinspectactivity, + lasttreatactivity, + lastinspectconditions, + waterorigin, + filter, + creationdate, + creator, + editdate, + editor, + jurisdiction, + shape__area, + shape__length, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_name, p_zone, p_habitat, p_priority, p_usetype, p_active, p_description, p_accessdesc, p_comments, p_symbology, p_externalid, p_acres, p_nextactiondatescheduled, p_larvinspectinterval, p_zone2, p_locationnumber, p_globalid, p_lastinspectdate, p_lastinspectbreeding, p_lastinspectavglarvae, p_lastinspectavgpupae, p_lastinspectlstages, p_lastinspectactiontaken, p_lastinspectfieldspecies, p_lasttreatdate, p_lasttreatproduct, p_lasttreatqty, p_lasttreatqtyunit, p_hectares, p_lastinspectactivity, p_lasttreatactivity, p_lastinspectconditions, p_waterorigin, p_filter, p_creationdate, p_creator, p_editdate, p_editor, p_jurisdiction, p_shape__area, p_shape__length, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_acres, + p_nextactiondatescheduled, + p_larvinspectinterval, + p_zone2, + p_locationnumber, + p_globalid, + p_lastinspectdate, + p_lastinspectbreeding, + p_lastinspectavglarvae, + p_lastinspectavgpupae, + p_lastinspectlstages, + p_lastinspectactiontaken, + p_lastinspectfieldspecies, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_hectares, + p_lastinspectactivity, + p_lasttreatactivity, + p_lastinspectconditions, + p_waterorigin, + p_filter, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, v_next_version ); @@ -487,61 +1643,27 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd --- +goose StatementBegin -CREATE OR REPLACE FUNCTION fieldseeker.insert_pool( - p_objectid bigint, - p_trapdata_id uuid,p_datesent timestamp,p_survtech varchar,p_datetested timestamp,p_testtech varchar,p_comments varchar,p_sampleid varchar,p_processed smallint,p_lab_id uuid,p_testmethod varchar,p_diseasetested varchar,p_diseasepos varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_lab varchar,p_poolyear smallint,p_gatewaysync smallint,p_vectorsurvcollectionid varchar,p_vectorsurvpoolid varchar,p_vectorsurvtrapdataid varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar -) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ -DECLARE - v_next_version integer; - v_changes_exist boolean; -BEGIN - -- Check if changes exist - SELECT NOT EXISTS ( - SELECT 1 FROM fieldseeker.pool lv - WHERE lv.objectid = p_objectid - AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id AND lv.datesent IS NOT DISTINCT FROM p_datesent AND lv.survtech IS NOT DISTINCT FROM p_survtech AND lv.datetested IS NOT DISTINCT FROM p_datetested AND lv.testtech IS NOT DISTINCT FROM p_testtech AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.sampleid IS NOT DISTINCT FROM p_sampleid AND lv.processed IS NOT DISTINCT FROM p_processed AND lv.lab_id IS NOT DISTINCT FROM p_lab_id AND lv.testmethod IS NOT DISTINCT FROM p_testmethod AND lv.diseasetested IS NOT DISTINCT FROM p_diseasetested AND lv.diseasepos IS NOT DISTINCT FROM p_diseasepos AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.lab IS NOT DISTINCT FROM p_lab AND lv.poolyear IS NOT DISTINCT FROM p_poolyear AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync AND lv.vectorsurvcollectionid IS NOT DISTINCT FROM p_vectorsurvcollectionid AND lv.vectorsurvpoolid IS NOT DISTINCT FROM p_vectorsurvpoolid AND lv.vectorsurvtrapdataid IS NOT DISTINCT FROM p_vectorsurvtrapdataid AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor - ORDER BY VERSION DESC LIMIT 1 - ) INTO v_changes_exist; - - -- If no changes, return false with current version - IF NOT v_changes_exist THEN - RETURN QUERY - SELECT - FALSE AS row_inserted, - (SELECT VERSION FROM fieldseeker.pool - WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; - RETURN; - END IF; - - -- Calculate next version - SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version - FROM fieldseeker.pool - WHERE objectid = p_objectid; - - -- Insert new version - INSERT INTO fieldseeker.pool ( - objectid, - trapdata_id, datesent, survtech, datetested, testtech, comments, sampleid, processed, lab_id, testmethod, diseasetested, diseasepos, globalid, created_user, created_date, last_edited_user, last_edited_date, lab, poolyear, gatewaysync, vectorsurvcollectionid, vectorsurvpoolid, vectorsurvtrapdataid, creationdate, creator, editdate, editor, - VERSION - ) VALUES ( - p_objectid, - p_trapdata_id, p_datesent, p_survtech, p_datetested, p_testtech, p_comments, p_sampleid, p_processed, p_lab_id, p_testmethod, p_diseasetested, p_diseasepos, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_lab, p_poolyear, p_gatewaysync, p_vectorsurvcollectionid, p_vectorsurvpoolid, p_vectorsurvtrapdataid, p_creationdate, p_creator, p_editdate, p_editor, - v_next_version - ); - - -- Return success with new version - RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; -END; -$$ LANGUAGE plpgsql; --- +goose StatementEnd -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_pooldetail( p_objectid bigint, - p_trapdata_id uuid,p_pool_id uuid,p_species varchar,p_females smallint,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_trapdata_id uuid, + p_pool_id uuid, + p_species varchar, + p_females smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -551,7 +1673,22 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.pooldetail lv WHERE lv.objectid = p_objectid - AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id AND lv.pool_id IS NOT DISTINCT FROM p_pool_id AND lv.species IS NOT DISTINCT FROM p_species AND lv.females IS NOT DISTINCT FROM p_females AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id + AND lv.pool_id IS NOT DISTINCT FROM p_pool_id + AND lv.species IS NOT DISTINCT FROM p_species + AND lv.females IS NOT DISTINCT FROM p_females + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -573,11 +1710,41 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.pooldetail ( objectid, - trapdata_id, pool_id, species, females, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, + + trapdata_id, + pool_id, + species, + females, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_trapdata_id, p_pool_id, p_species, p_females, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_creationdate, p_creator, p_editdate, p_editor, + + p_trapdata_id, + p_pool_id, + p_species, + p_females, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -585,12 +1752,211 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_pool( + p_objectid bigint, + + p_trapdata_id uuid, + p_datesent timestamp, + p_survtech varchar, + p_datetested timestamp, + p_testtech varchar, + p_comments varchar, + p_sampleid varchar, + p_processed smallint, + p_lab_id uuid, + p_testmethod varchar, + p_diseasetested varchar, + p_diseasepos varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_lab varchar, + p_poolyear smallint, + p_gatewaysync smallint, + p_vectorsurvcollectionid varchar, + p_vectorsurvpoolid varchar, + p_vectorsurvtrapdataid varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.pool lv + WHERE lv.objectid = p_objectid + + AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id + AND lv.datesent IS NOT DISTINCT FROM p_datesent + AND lv.survtech IS NOT DISTINCT FROM p_survtech + AND lv.datetested IS NOT DISTINCT FROM p_datetested + AND lv.testtech IS NOT DISTINCT FROM p_testtech + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.sampleid IS NOT DISTINCT FROM p_sampleid + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.lab_id IS NOT DISTINCT FROM p_lab_id + AND lv.testmethod IS NOT DISTINCT FROM p_testmethod + AND lv.diseasetested IS NOT DISTINCT FROM p_diseasetested + AND lv.diseasepos IS NOT DISTINCT FROM p_diseasepos + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.lab IS NOT DISTINCT FROM p_lab + AND lv.poolyear IS NOT DISTINCT FROM p_poolyear + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.vectorsurvcollectionid IS NOT DISTINCT FROM p_vectorsurvcollectionid + AND lv.vectorsurvpoolid IS NOT DISTINCT FROM p_vectorsurvpoolid + AND lv.vectorsurvtrapdataid IS NOT DISTINCT FROM p_vectorsurvtrapdataid + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.pool + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.pool + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.pool ( + objectid, + + trapdata_id, + datesent, + survtech, + datetested, + testtech, + comments, + sampleid, + processed, + lab_id, + testmethod, + diseasetested, + diseasepos, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + lab, + poolyear, + gatewaysync, + vectorsurvcollectionid, + vectorsurvpoolid, + vectorsurvtrapdataid, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_trapdata_id, + p_datesent, + p_survtech, + p_datetested, + p_testtech, + p_comments, + p_sampleid, + p_processed, + p_lab_id, + p_testmethod, + p_diseasetested, + p_diseasepos, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_lab, + p_poolyear, + p_gatewaysync, + p_vectorsurvcollectionid, + p_vectorsurvpoolid, + p_vectorsurvtrapdataid, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_proposedtreatmentarea( p_objectid bigint, - p_method varchar,p_comments varchar,p_zone varchar,p_reviewed smallint,p_reviewedby varchar,p_revieweddate timestamp,p_zone2 varchar,p_completeddate timestamp,p_completedby varchar,p_completed smallint,p_issprayroute smallint,p_name varchar,p_acres double precision,p_globalid uuid,p_exported smallint,p_targetproduct varchar,p_targetapprate double precision,p_hectares double precision,p_lasttreatactivity varchar,p_lasttreatdate timestamp,p_lasttreatproduct varchar,p_lasttreatqty double precision,p_lasttreatqtyunit varchar,p_priority varchar,p_duedate timestamp,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_targetspecies varchar,p_shape__area double precision,p_shape__length double precision + + p_method varchar, + p_comments varchar, + p_zone varchar, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_zone2 varchar, + p_completeddate timestamp, + p_completedby varchar, + p_completed smallint, + p_issprayroute smallint, + p_name varchar, + p_acres double precision, + p_globalid uuid, + p_exported smallint, + p_targetproduct varchar, + p_targetapprate double precision, + p_hectares double precision, + p_lasttreatactivity varchar, + p_lasttreatdate timestamp, + p_lasttreatproduct varchar, + p_lasttreatqty double precision, + p_lasttreatqtyunit varchar, + p_priority varchar, + p_duedate timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_targetspecies varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -600,7 +1966,41 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.proposedtreatmentarea lv WHERE lv.objectid = p_objectid - AND lv.method IS NOT DISTINCT FROM p_method AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.reviewed IS NOT DISTINCT FROM p_reviewed AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.completeddate IS NOT DISTINCT FROM p_completeddate AND lv.completedby IS NOT DISTINCT FROM p_completedby AND lv.completed IS NOT DISTINCT FROM p_completed AND lv.issprayroute IS NOT DISTINCT FROM p_issprayroute AND lv.name IS NOT DISTINCT FROM p_name AND lv.acres IS NOT DISTINCT FROM p_acres AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.exported IS NOT DISTINCT FROM p_exported AND lv.targetproduct IS NOT DISTINCT FROM p_targetproduct AND lv.targetapprate IS NOT DISTINCT FROM p_targetapprate AND lv.hectares IS NOT DISTINCT FROM p_hectares AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.duedate IS NOT DISTINCT FROM p_duedate AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.targetspecies IS NOT DISTINCT FROM p_targetspecies AND lv.shape__area IS NOT DISTINCT FROM p_shape__area AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + + AND lv.method IS NOT DISTINCT FROM p_method + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.completeddate IS NOT DISTINCT FROM p_completeddate + AND lv.completedby IS NOT DISTINCT FROM p_completedby + AND lv.completed IS NOT DISTINCT FROM p_completed + AND lv.issprayroute IS NOT DISTINCT FROM p_issprayroute + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.acres IS NOT DISTINCT FROM p_acres + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.exported IS NOT DISTINCT FROM p_exported + AND lv.targetproduct IS NOT DISTINCT FROM p_targetproduct + AND lv.targetapprate IS NOT DISTINCT FROM p_targetapprate + AND lv.hectares IS NOT DISTINCT FROM p_hectares + AND lv.lasttreatactivity IS NOT DISTINCT FROM p_lasttreatactivity + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lasttreatproduct IS NOT DISTINCT FROM p_lasttreatproduct + AND lv.lasttreatqty IS NOT DISTINCT FROM p_lasttreatqty + AND lv.lasttreatqtyunit IS NOT DISTINCT FROM p_lasttreatqtyunit + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.duedate IS NOT DISTINCT FROM p_duedate + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.targetspecies IS NOT DISTINCT FROM p_targetspecies + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -622,11 +2022,79 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.proposedtreatmentarea ( objectid, - method, comments, zone, reviewed, reviewedby, revieweddate, zone2, completeddate, completedby, completed, issprayroute, name, acres, globalid, exported, targetproduct, targetapprate, hectares, lasttreatactivity, lasttreatdate, lasttreatproduct, lasttreatqty, lasttreatqtyunit, priority, duedate, creationdate, creator, editdate, editor, targetspecies, shape__area, shape__length, + + method, + comments, + zone, + reviewed, + reviewedby, + revieweddate, + zone2, + completeddate, + completedby, + completed, + issprayroute, + name, + acres, + globalid, + exported, + targetproduct, + targetapprate, + hectares, + lasttreatactivity, + lasttreatdate, + lasttreatproduct, + lasttreatqty, + lasttreatqtyunit, + priority, + duedate, + creationdate, + creator, + editdate, + editor, + targetspecies, + shape__area, + shape__length, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_method, p_comments, p_zone, p_reviewed, p_reviewedby, p_revieweddate, p_zone2, p_completeddate, p_completedby, p_completed, p_issprayroute, p_name, p_acres, p_globalid, p_exported, p_targetproduct, p_targetapprate, p_hectares, p_lasttreatactivity, p_lasttreatdate, p_lasttreatproduct, p_lasttreatqty, p_lasttreatqtyunit, p_priority, p_duedate, p_creationdate, p_creator, p_editdate, p_editor, p_targetspecies, p_shape__area, p_shape__length, + + p_method, + p_comments, + p_zone, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_zone2, + p_completeddate, + p_completedby, + p_completed, + p_issprayroute, + p_name, + p_acres, + p_globalid, + p_exported, + p_targetproduct, + p_targetapprate, + p_hectares, + p_lasttreatactivity, + p_lasttreatdate, + p_lasttreatproduct, + p_lasttreatqty, + p_lasttreatqtyunit, + p_priority, + p_duedate, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_targetspecies, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, v_next_version ); @@ -634,12 +2102,75 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_qamosquitoinspection( p_objectid bigint, - p_posdips smallint,p_actiontaken varchar,p_comments varchar,p_avetemp double precision,p_windspeed double precision,p_raingauge double precision,p_globalid uuid,p_startdatetime timestamp,p_enddatetime timestamp,p_winddir varchar,p_reviewed smallint,p_reviewedby varchar,p_revieweddate timestamp,p_locationname varchar,p_zone varchar,p_recordstatus smallint,p_zone2 varchar,p_lr smallint,p_negdips smallint,p_totalacres double precision,p_acresbreeding double precision,p_fish smallint,p_sitetype varchar,p_breedingpotential varchar,p_movingwater smallint,p_nowaterever smallint,p_mosquitohabitat varchar,p_habvalue1 smallint,p_habvalue1percent smallint,p_habvalue2 smallint,p_habvalue2percent smallint,p_potential smallint,p_larvaepresent smallint,p_larvaeinsidetreatedarea smallint,p_larvaeoutsidetreatedarea smallint,p_larvaereason varchar,p_aquaticorganisms varchar,p_vegetation varchar,p_sourcereduction varchar,p_waterpresent smallint,p_watermovement1 varchar,p_watermovement1percent smallint,p_watermovement2 varchar,p_watermovement2percent smallint,p_soilconditions varchar,p_waterduration varchar,p_watersource varchar,p_waterconditions varchar,p_adultactivity smallint,p_linelocid uuid,p_pointlocid uuid,p_polygonlocid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_fieldtech varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_posdips smallint, + p_actiontaken varchar, + p_comments varchar, + p_avetemp double precision, + p_windspeed double precision, + p_raingauge double precision, + p_globalid uuid, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_winddir varchar, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_recordstatus smallint, + p_zone2 varchar, + p_lr smallint, + p_negdips smallint, + p_totalacres double precision, + p_acresbreeding double precision, + p_fish smallint, + p_sitetype varchar, + p_breedingpotential varchar, + p_movingwater smallint, + p_nowaterever smallint, + p_mosquitohabitat varchar, + p_habvalue1 smallint, + p_habvalue1percent smallint, + p_habvalue2 smallint, + p_habvalue2percent smallint, + p_potential smallint, + p_larvaepresent smallint, + p_larvaeinsidetreatedarea smallint, + p_larvaeoutsidetreatedarea smallint, + p_larvaereason varchar, + p_aquaticorganisms varchar, + p_vegetation varchar, + p_sourcereduction varchar, + p_waterpresent smallint, + p_watermovement1 varchar, + p_watermovement1percent smallint, + p_watermovement2 varchar, + p_watermovement2percent smallint, + p_soilconditions varchar, + p_waterduration varchar, + p_watersource varchar, + p_waterconditions varchar, + p_adultactivity smallint, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_fieldtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -649,7 +2180,70 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.qamosquitoinspection lv WHERE lv.objectid = p_objectid - AND lv.posdips IS NOT DISTINCT FROM p_posdips AND lv.actiontaken IS NOT DISTINCT FROM p_actiontaken AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.avetemp IS NOT DISTINCT FROM p_avetemp AND lv.windspeed IS NOT DISTINCT FROM p_windspeed AND lv.raingauge IS NOT DISTINCT FROM p_raingauge AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime AND lv.winddir IS NOT DISTINCT FROM p_winddir AND lv.reviewed IS NOT DISTINCT FROM p_reviewed AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate AND lv.locationname IS NOT DISTINCT FROM p_locationname AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.lr IS NOT DISTINCT FROM p_lr AND lv.negdips IS NOT DISTINCT FROM p_negdips AND lv.totalacres IS NOT DISTINCT FROM p_totalacres AND lv.acresbreeding IS NOT DISTINCT FROM p_acresbreeding AND lv.fish IS NOT DISTINCT FROM p_fish AND lv.sitetype IS NOT DISTINCT FROM p_sitetype AND lv.breedingpotential IS NOT DISTINCT FROM p_breedingpotential AND lv.movingwater IS NOT DISTINCT FROM p_movingwater AND lv.nowaterever IS NOT DISTINCT FROM p_nowaterever AND lv.mosquitohabitat IS NOT DISTINCT FROM p_mosquitohabitat AND lv.habvalue1 IS NOT DISTINCT FROM p_habvalue1 AND lv.habvalue1percent IS NOT DISTINCT FROM p_habvalue1percent AND lv.habvalue2 IS NOT DISTINCT FROM p_habvalue2 AND lv.habvalue2percent IS NOT DISTINCT FROM p_habvalue2percent AND lv.potential IS NOT DISTINCT FROM p_potential AND lv.larvaepresent IS NOT DISTINCT FROM p_larvaepresent AND lv.larvaeinsidetreatedarea IS NOT DISTINCT FROM p_larvaeinsidetreatedarea AND lv.larvaeoutsidetreatedarea IS NOT DISTINCT FROM p_larvaeoutsidetreatedarea AND lv.larvaereason IS NOT DISTINCT FROM p_larvaereason AND lv.aquaticorganisms IS NOT DISTINCT FROM p_aquaticorganisms AND lv.vegetation IS NOT DISTINCT FROM p_vegetation AND lv.sourcereduction IS NOT DISTINCT FROM p_sourcereduction AND lv.waterpresent IS NOT DISTINCT FROM p_waterpresent AND lv.watermovement1 IS NOT DISTINCT FROM p_watermovement1 AND lv.watermovement1percent IS NOT DISTINCT FROM p_watermovement1percent AND lv.watermovement2 IS NOT DISTINCT FROM p_watermovement2 AND lv.watermovement2percent IS NOT DISTINCT FROM p_watermovement2percent AND lv.soilconditions IS NOT DISTINCT FROM p_soilconditions AND lv.waterduration IS NOT DISTINCT FROM p_waterduration AND lv.watersource IS NOT DISTINCT FROM p_watersource AND lv.waterconditions IS NOT DISTINCT FROM p_waterconditions AND lv.adultactivity IS NOT DISTINCT FROM p_adultactivity AND lv.linelocid IS NOT DISTINCT FROM p_linelocid AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.posdips IS NOT DISTINCT FROM p_posdips + AND lv.actiontaken IS NOT DISTINCT FROM p_actiontaken + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.lr IS NOT DISTINCT FROM p_lr + AND lv.negdips IS NOT DISTINCT FROM p_negdips + AND lv.totalacres IS NOT DISTINCT FROM p_totalacres + AND lv.acresbreeding IS NOT DISTINCT FROM p_acresbreeding + AND lv.fish IS NOT DISTINCT FROM p_fish + AND lv.sitetype IS NOT DISTINCT FROM p_sitetype + AND lv.breedingpotential IS NOT DISTINCT FROM p_breedingpotential + AND lv.movingwater IS NOT DISTINCT FROM p_movingwater + AND lv.nowaterever IS NOT DISTINCT FROM p_nowaterever + AND lv.mosquitohabitat IS NOT DISTINCT FROM p_mosquitohabitat + AND lv.habvalue1 IS NOT DISTINCT FROM p_habvalue1 + AND lv.habvalue1percent IS NOT DISTINCT FROM p_habvalue1percent + AND lv.habvalue2 IS NOT DISTINCT FROM p_habvalue2 + AND lv.habvalue2percent IS NOT DISTINCT FROM p_habvalue2percent + AND lv.potential IS NOT DISTINCT FROM p_potential + AND lv.larvaepresent IS NOT DISTINCT FROM p_larvaepresent + AND lv.larvaeinsidetreatedarea IS NOT DISTINCT FROM p_larvaeinsidetreatedarea + AND lv.larvaeoutsidetreatedarea IS NOT DISTINCT FROM p_larvaeoutsidetreatedarea + AND lv.larvaereason IS NOT DISTINCT FROM p_larvaereason + AND lv.aquaticorganisms IS NOT DISTINCT FROM p_aquaticorganisms + AND lv.vegetation IS NOT DISTINCT FROM p_vegetation + AND lv.sourcereduction IS NOT DISTINCT FROM p_sourcereduction + AND lv.waterpresent IS NOT DISTINCT FROM p_waterpresent + AND lv.watermovement1 IS NOT DISTINCT FROM p_watermovement1 + AND lv.watermovement1percent IS NOT DISTINCT FROM p_watermovement1percent + AND lv.watermovement2 IS NOT DISTINCT FROM p_watermovement2 + AND lv.watermovement2percent IS NOT DISTINCT FROM p_watermovement2percent + AND lv.soilconditions IS NOT DISTINCT FROM p_soilconditions + AND lv.waterduration IS NOT DISTINCT FROM p_waterduration + AND lv.watersource IS NOT DISTINCT FROM p_watersource + AND lv.waterconditions IS NOT DISTINCT FROM p_waterconditions + AND lv.adultactivity IS NOT DISTINCT FROM p_adultactivity + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -671,11 +2265,137 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.qamosquitoinspection ( objectid, - posdips, actiontaken, comments, avetemp, windspeed, raingauge, globalid, startdatetime, enddatetime, winddir, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, lr, negdips, totalacres, acresbreeding, fish, sitetype, breedingpotential, movingwater, nowaterever, mosquitohabitat, habvalue1, habvalue1percent, habvalue2, habvalue2percent, potential, larvaepresent, larvaeinsidetreatedarea, larvaeoutsidetreatedarea, larvaereason, aquaticorganisms, vegetation, sourcereduction, waterpresent, watermovement1, watermovement1percent, watermovement2, watermovement2percent, soilconditions, waterduration, watersource, waterconditions, adultactivity, linelocid, pointlocid, polygonlocid, created_user, created_date, last_edited_user, last_edited_date, fieldtech, creationdate, creator, editdate, editor, + + posdips, + actiontaken, + comments, + avetemp, + windspeed, + raingauge, + globalid, + startdatetime, + enddatetime, + winddir, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + recordstatus, + zone2, + lr, + negdips, + totalacres, + acresbreeding, + fish, + sitetype, + breedingpotential, + movingwater, + nowaterever, + mosquitohabitat, + habvalue1, + habvalue1percent, + habvalue2, + habvalue2percent, + potential, + larvaepresent, + larvaeinsidetreatedarea, + larvaeoutsidetreatedarea, + larvaereason, + aquaticorganisms, + vegetation, + sourcereduction, + waterpresent, + watermovement1, + watermovement1percent, + watermovement2, + watermovement2percent, + soilconditions, + waterduration, + watersource, + waterconditions, + adultactivity, + linelocid, + pointlocid, + polygonlocid, + created_user, + created_date, + last_edited_user, + last_edited_date, + fieldtech, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_posdips, p_actiontaken, p_comments, p_avetemp, p_windspeed, p_raingauge, p_globalid, p_startdatetime, p_enddatetime, p_winddir, p_reviewed, p_reviewedby, p_revieweddate, p_locationname, p_zone, p_recordstatus, p_zone2, p_lr, p_negdips, p_totalacres, p_acresbreeding, p_fish, p_sitetype, p_breedingpotential, p_movingwater, p_nowaterever, p_mosquitohabitat, p_habvalue1, p_habvalue1percent, p_habvalue2, p_habvalue2percent, p_potential, p_larvaepresent, p_larvaeinsidetreatedarea, p_larvaeoutsidetreatedarea, p_larvaereason, p_aquaticorganisms, p_vegetation, p_sourcereduction, p_waterpresent, p_watermovement1, p_watermovement1percent, p_watermovement2, p_watermovement2percent, p_soilconditions, p_waterduration, p_watersource, p_waterconditions, p_adultactivity, p_linelocid, p_pointlocid, p_polygonlocid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_fieldtech, p_creationdate, p_creator, p_editdate, p_editor, + + p_posdips, + p_actiontaken, + p_comments, + p_avetemp, + p_windspeed, + p_raingauge, + p_globalid, + p_startdatetime, + p_enddatetime, + p_winddir, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_recordstatus, + p_zone2, + p_lr, + p_negdips, + p_totalacres, + p_acresbreeding, + p_fish, + p_sitetype, + p_breedingpotential, + p_movingwater, + p_nowaterever, + p_mosquitohabitat, + p_habvalue1, + p_habvalue1percent, + p_habvalue2, + p_habvalue2percent, + p_potential, + p_larvaepresent, + p_larvaeinsidetreatedarea, + p_larvaeoutsidetreatedarea, + p_larvaereason, + p_aquaticorganisms, + p_vegetation, + p_sourcereduction, + p_waterpresent, + p_watermovement1, + p_watermovement1percent, + p_watermovement2, + p_watermovement2percent, + p_soilconditions, + p_waterduration, + p_watersource, + p_waterconditions, + p_adultactivity, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_fieldtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -683,11 +2403,12 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_rodentlocation( p_objectid bigint, + p_locationname varchar, p_zone varchar, p_zone2 varchar, @@ -700,23 +2421,25 @@ CREATE OR REPLACE FUNCTION fieldseeker.insert_rodentlocation( p_comments varchar, p_symbology varchar, p_externalid varchar, - p_nextactiondatescheduled timestamp without time zone , + p_nextactiondatescheduled timestamp, p_locationnumber integer, - p_lastinspectdate timestamp without time zone, + p_lastinspectdate timestamp, p_lastinspectspecies varchar, p_lastinspectaction varchar, p_lastinspectconditions varchar, p_lastinspectrodentevidence varchar, p_globalid uuid, p_created_user varchar, - p_created_date timestamp without time zone, + p_created_date timestamp, p_last_edited_user varchar, - p_last_edited_date timestamp without time zone, - p_creationdate timestamp without time zone, + p_last_edited_date timestamp, + p_creationdate timestamp, p_creator varchar, - p_editdate timestamp without time zone, + p_editdate timestamp, p_editor varchar, - p_jurisdiction varchar + p_jurisdiction varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -726,7 +2449,38 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.rodentlocation lv WHERE lv.objectid = p_objectid - AND lv.locationname IS NOT DISTINCT FROM p_locationname AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.habitat IS NOT DISTINCT FROM p_habitat AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.usetype IS NOT DISTINCT FROM p_usetype AND lv.active IS NOT DISTINCT FROM p_active AND lv.description IS NOT DISTINCT FROM p_description AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.symbology IS NOT DISTINCT FROM p_symbology AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate AND lv.lastinspectspecies IS NOT DISTINCT FROM p_lastinspectspecies AND lv.lastinspectaction IS NOT DISTINCT FROM p_lastinspectaction AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions AND lv.lastinspectrodentevidence IS NOT DISTINCT FROM p_lastinspectrodentevidence AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.lastinspectdate IS NOT DISTINCT FROM p_lastinspectdate + AND lv.lastinspectspecies IS NOT DISTINCT FROM p_lastinspectspecies + AND lv.lastinspectaction IS NOT DISTINCT FROM p_lastinspectaction + AND lv.lastinspectconditions IS NOT DISTINCT FROM p_lastinspectconditions + AND lv.lastinspectrodentevidence IS NOT DISTINCT FROM p_lastinspectrodentevidence + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -748,11 +2502,73 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.rodentlocation ( objectid, - locationname, zone, zone2, habitat, priority, usetype, active, description, accessdesc, comments, symbology, externalid, nextactiondatescheduled, locationnumber, lastinspectdate, lastinspectspecies, lastinspectaction, lastinspectconditions, lastinspectrodentevidence, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, jurisdiction, + + locationname, + zone, + zone2, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + symbology, + externalid, + nextactiondatescheduled, + locationnumber, + lastinspectdate, + lastinspectspecies, + lastinspectaction, + lastinspectconditions, + lastinspectrodentevidence, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + jurisdiction, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_locationname, p_zone, p_zone2, p_habitat, p_priority, p_usetype, p_active, p_description, p_accessdesc, p_comments, p_symbology, p_externalid, p_nextactiondatescheduled, p_locationnumber, p_lastinspectdate, p_lastinspectspecies, p_lastinspectaction, p_lastinspectconditions, p_lastinspectrodentevidence, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_creationdate, p_creator, p_editdate, p_editor, p_jurisdiction, + + p_locationname, + p_zone, + p_zone2, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_symbology, + p_externalid, + p_nextactiondatescheduled, + p_locationnumber, + p_lastinspectdate, + p_lastinspectspecies, + p_lastinspectaction, + p_lastinspectconditions, + p_lastinspectrodentevidence, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_jurisdiction, + p_geometry, + p_geospatial, v_next_version ); @@ -760,12 +2576,59 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_samplecollection( p_objectid bigint, - p_loc_id uuid,p_startdatetime timestamp,p_enddatetime timestamp,p_sitecond varchar,p_sampleid varchar,p_survtech varchar,p_datesent timestamp,p_datetested timestamp,p_testtech varchar,p_comments varchar,p_processed smallint,p_sampletype varchar,p_samplecond varchar,p_species varchar,p_sex varchar,p_avetemp double precision,p_windspeed double precision,p_winddir varchar,p_raingauge double precision,p_activity varchar,p_testmethod varchar,p_diseasetested varchar,p_diseasepos varchar,p_reviewed smallint,p_reviewedby varchar,p_revieweddate timestamp,p_locationname varchar,p_zone varchar,p_recordstatus smallint,p_zone2 varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_lab varchar,p_fieldtech varchar,p_flockid uuid,p_samplecount smallint,p_chickenid uuid,p_gatewaysync smallint,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_loc_id uuid, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_sitecond varchar, + p_sampleid varchar, + p_survtech varchar, + p_datesent timestamp, + p_datetested timestamp, + p_testtech varchar, + p_comments varchar, + p_processed smallint, + p_sampletype varchar, + p_samplecond varchar, + p_species varchar, + p_sex varchar, + p_avetemp double precision, + p_windspeed double precision, + p_winddir varchar, + p_raingauge double precision, + p_activity varchar, + p_testmethod varchar, + p_diseasetested varchar, + p_diseasepos varchar, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_recordstatus smallint, + p_zone2 varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_lab varchar, + p_fieldtech varchar, + p_flockid uuid, + p_samplecount smallint, + p_chickenid uuid, + p_gatewaysync smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -775,7 +2638,54 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.samplecollection lv WHERE lv.objectid = p_objectid - AND lv.loc_id IS NOT DISTINCT FROM p_loc_id AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime AND lv.sitecond IS NOT DISTINCT FROM p_sitecond AND lv.sampleid IS NOT DISTINCT FROM p_sampleid AND lv.survtech IS NOT DISTINCT FROM p_survtech AND lv.datesent IS NOT DISTINCT FROM p_datesent AND lv.datetested IS NOT DISTINCT FROM p_datetested AND lv.testtech IS NOT DISTINCT FROM p_testtech AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.processed IS NOT DISTINCT FROM p_processed AND lv.sampletype IS NOT DISTINCT FROM p_sampletype AND lv.samplecond IS NOT DISTINCT FROM p_samplecond AND lv.species IS NOT DISTINCT FROM p_species AND lv.sex IS NOT DISTINCT FROM p_sex AND lv.avetemp IS NOT DISTINCT FROM p_avetemp AND lv.windspeed IS NOT DISTINCT FROM p_windspeed AND lv.winddir IS NOT DISTINCT FROM p_winddir AND lv.raingauge IS NOT DISTINCT FROM p_raingauge AND lv.activity IS NOT DISTINCT FROM p_activity AND lv.testmethod IS NOT DISTINCT FROM p_testmethod AND lv.diseasetested IS NOT DISTINCT FROM p_diseasetested AND lv.diseasepos IS NOT DISTINCT FROM p_diseasepos AND lv.reviewed IS NOT DISTINCT FROM p_reviewed AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate AND lv.locationname IS NOT DISTINCT FROM p_locationname AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.lab IS NOT DISTINCT FROM p_lab AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech AND lv.flockid IS NOT DISTINCT FROM p_flockid AND lv.samplecount IS NOT DISTINCT FROM p_samplecount AND lv.chickenid IS NOT DISTINCT FROM p_chickenid AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.loc_id IS NOT DISTINCT FROM p_loc_id + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.sampleid IS NOT DISTINCT FROM p_sampleid + AND lv.survtech IS NOT DISTINCT FROM p_survtech + AND lv.datesent IS NOT DISTINCT FROM p_datesent + AND lv.datetested IS NOT DISTINCT FROM p_datetested + AND lv.testtech IS NOT DISTINCT FROM p_testtech + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.sampletype IS NOT DISTINCT FROM p_sampletype + AND lv.samplecond IS NOT DISTINCT FROM p_samplecond + AND lv.species IS NOT DISTINCT FROM p_species + AND lv.sex IS NOT DISTINCT FROM p_sex + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.testmethod IS NOT DISTINCT FROM p_testmethod + AND lv.diseasetested IS NOT DISTINCT FROM p_diseasetested + AND lv.diseasepos IS NOT DISTINCT FROM p_diseasepos + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.lab IS NOT DISTINCT FROM p_lab + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.flockid IS NOT DISTINCT FROM p_flockid + AND lv.samplecount IS NOT DISTINCT FROM p_samplecount + AND lv.chickenid IS NOT DISTINCT FROM p_chickenid + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -797,11 +2707,105 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.samplecollection ( objectid, - loc_id, startdatetime, enddatetime, sitecond, sampleid, survtech, datesent, datetested, testtech, comments, processed, sampletype, samplecond, species, sex, avetemp, windspeed, winddir, raingauge, activity, testmethod, diseasetested, diseasepos, reviewed, reviewedby, revieweddate, locationname, zone, recordstatus, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, lab, fieldtech, flockid, samplecount, chickenid, gatewaysync, creationdate, creator, editdate, editor, + + loc_id, + startdatetime, + enddatetime, + sitecond, + sampleid, + survtech, + datesent, + datetested, + testtech, + comments, + processed, + sampletype, + samplecond, + species, + sex, + avetemp, + windspeed, + winddir, + raingauge, + activity, + testmethod, + diseasetested, + diseasepos, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + recordstatus, + zone2, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + lab, + fieldtech, + flockid, + samplecount, + chickenid, + gatewaysync, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_loc_id, p_startdatetime, p_enddatetime, p_sitecond, p_sampleid, p_survtech, p_datesent, p_datetested, p_testtech, p_comments, p_processed, p_sampletype, p_samplecond, p_species, p_sex, p_avetemp, p_windspeed, p_winddir, p_raingauge, p_activity, p_testmethod, p_diseasetested, p_diseasepos, p_reviewed, p_reviewedby, p_revieweddate, p_locationname, p_zone, p_recordstatus, p_zone2, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_lab, p_fieldtech, p_flockid, p_samplecount, p_chickenid, p_gatewaysync, p_creationdate, p_creator, p_editdate, p_editor, + + p_loc_id, + p_startdatetime, + p_enddatetime, + p_sitecond, + p_sampleid, + p_survtech, + p_datesent, + p_datetested, + p_testtech, + p_comments, + p_processed, + p_sampletype, + p_samplecond, + p_species, + p_sex, + p_avetemp, + p_windspeed, + p_winddir, + p_raingauge, + p_activity, + p_testmethod, + p_diseasetested, + p_diseasepos, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_recordstatus, + p_zone2, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_lab, + p_fieldtech, + p_flockid, + p_samplecount, + p_chickenid, + p_gatewaysync, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -809,12 +2813,37 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_samplelocation( p_objectid bigint, - p_name varchar,p_zone varchar,p_habitat varchar,p_priority varchar,p_usetype varchar,p_active smallint,p_description varchar,p_accessdesc varchar,p_comments varchar,p_externalid varchar,p_nextactiondatescheduled timestamp,p_zone2 varchar,p_locationnumber integer,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_gatewaysync smallint,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_externalid varchar, + p_nextactiondatescheduled timestamp, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_gatewaysync smallint, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -824,7 +2853,32 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.samplelocation lv WHERE lv.objectid = p_objectid - AND lv.name IS NOT DISTINCT FROM p_name AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.habitat IS NOT DISTINCT FROM p_habitat AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.usetype IS NOT DISTINCT FROM p_usetype AND lv.active IS NOT DISTINCT FROM p_active AND lv.description IS NOT DISTINCT FROM p_description AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -846,11 +2900,61 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.samplelocation ( objectid, - name, zone, habitat, priority, usetype, active, description, accessdesc, comments, externalid, nextactiondatescheduled, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, gatewaysync, creationdate, creator, editdate, editor, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + externalid, + nextactiondatescheduled, + zone2, + locationnumber, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + gatewaysync, + creationdate, + creator, + editdate, + editor, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_name, p_zone, p_habitat, p_priority, p_usetype, p_active, p_description, p_accessdesc, p_comments, p_externalid, p_nextactiondatescheduled, p_zone2, p_locationnumber, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_gatewaysync, p_creationdate, p_creator, p_editdate, p_editor, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_externalid, + p_nextactiondatescheduled, + p_zone2, + p_locationnumber, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_gatewaysync, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_geometry, + p_geospatial, v_next_version ); @@ -858,12 +2962,99 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_servicerequest( p_objectid bigint, - p_recdatetime timestamp,p_source varchar,p_entrytech varchar,p_priority varchar,p_supervisor varchar,p_assignedtech varchar,p_status varchar,p_clranon smallint,p_clrfname varchar,p_clrphone1 varchar,p_clrphone2 varchar,p_clremail varchar,p_clrcompany varchar,p_clraddr1 varchar,p_clraddr2 varchar,p_clrcity varchar,p_clrstate varchar,p_clrzip varchar,p_clrother varchar,p_clrcontpref varchar,p_reqcompany varchar,p_reqaddr1 varchar,p_reqaddr2 varchar,p_reqcity varchar,p_reqstate varchar,p_reqzip varchar,p_reqcrossst varchar,p_reqsubdiv varchar,p_reqmapgrid varchar,p_reqpermission smallint,p_reqtarget varchar,p_reqdescr varchar,p_reqnotesfortech varchar,p_reqnotesforcust varchar,p_reqfldnotes varchar,p_reqprogramactions varchar,p_datetimeclosed timestamp,p_techclosed varchar,p_sr_number integer,p_reviewed smallint,p_reviewedby varchar,p_revieweddate timestamp,p_accepted smallint,p_accepteddate timestamp,p_rejectedby varchar,p_rejecteddate timestamp,p_rejectedreason varchar,p_duedate timestamp,p_acceptedby varchar,p_comments varchar,p_estcompletedate timestamp,p_nextaction varchar,p_recordstatus smallint,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_firstresponsedate timestamp,p_responsedaycount smallint,p_allowed varchar,p_xvalue varchar,p_yvalue varchar,p_validx varchar,p_validy varchar,p_externalid varchar,p_externalerror varchar,p_pointlocid uuid,p_notified smallint,p_notifieddate timestamp,p_scheduled smallint,p_scheduleddate timestamp,p_dog integer,p_schedule_period varchar,p_schedule_notes varchar,p_spanish integer,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_issuesreported varchar,p_jurisdiction varchar,p_notificationtimestamp varchar,p_zone varchar,p_zone2 varchar + + p_recdatetime timestamp, + p_source varchar, + p_entrytech varchar, + p_priority varchar, + p_supervisor varchar, + p_assignedtech varchar, + p_status varchar, + p_clranon smallint, + p_clrfname varchar, + p_clrphone1 varchar, + p_clrphone2 varchar, + p_clremail varchar, + p_clrcompany varchar, + p_clraddr1 varchar, + p_clraddr2 varchar, + p_clrcity varchar, + p_clrstate varchar, + p_clrzip varchar, + p_clrother varchar, + p_clrcontpref varchar, + p_reqcompany varchar, + p_reqaddr1 varchar, + p_reqaddr2 varchar, + p_reqcity varchar, + p_reqstate varchar, + p_reqzip varchar, + p_reqcrossst varchar, + p_reqsubdiv varchar, + p_reqmapgrid varchar, + p_reqpermission smallint, + p_reqtarget varchar, + p_reqdescr varchar, + p_reqnotesfortech varchar, + p_reqnotesforcust varchar, + p_reqfldnotes varchar, + p_reqprogramactions varchar, + p_datetimeclosed timestamp, + p_techclosed varchar, + p_sr_number integer, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_accepted smallint, + p_accepteddate timestamp, + p_rejectedby varchar, + p_rejecteddate timestamp, + p_rejectedreason varchar, + p_duedate timestamp, + p_acceptedby varchar, + p_comments varchar, + p_estcompletedate timestamp, + p_nextaction varchar, + p_recordstatus smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_firstresponsedate timestamp, + p_responsedaycount smallint, + p_allowed varchar, + p_xvalue varchar, + p_yvalue varchar, + p_validx varchar, + p_validy varchar, + p_externalid varchar, + p_externalerror varchar, + p_pointlocid uuid, + p_notified smallint, + p_notifieddate timestamp, + p_scheduled smallint, + p_scheduleddate timestamp, + p_dog integer, + p_schedule_period varchar, + p_schedule_notes varchar, + p_spanish integer, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_issuesreported varchar, + p_jurisdiction varchar, + p_notificationtimestamp varchar, + p_zone varchar, + p_zone2 varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -873,7 +3064,94 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.servicerequest lv WHERE lv.objectid = p_objectid - AND lv.recdatetime IS NOT DISTINCT FROM p_recdatetime AND lv.source IS NOT DISTINCT FROM p_source AND lv.entrytech IS NOT DISTINCT FROM p_entrytech AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.supervisor IS NOT DISTINCT FROM p_supervisor AND lv.assignedtech IS NOT DISTINCT FROM p_assignedtech AND lv.status IS NOT DISTINCT FROM p_status AND lv.clranon IS NOT DISTINCT FROM p_clranon AND lv.clrfname IS NOT DISTINCT FROM p_clrfname AND lv.clrphone1 IS NOT DISTINCT FROM p_clrphone1 AND lv.clrphone2 IS NOT DISTINCT FROM p_clrphone2 AND lv.clremail IS NOT DISTINCT FROM p_clremail AND lv.clrcompany IS NOT DISTINCT FROM p_clrcompany AND lv.clraddr1 IS NOT DISTINCT FROM p_clraddr1 AND lv.clraddr2 IS NOT DISTINCT FROM p_clraddr2 AND lv.clrcity IS NOT DISTINCT FROM p_clrcity AND lv.clrstate IS NOT DISTINCT FROM p_clrstate AND lv.clrzip IS NOT DISTINCT FROM p_clrzip AND lv.clrother IS NOT DISTINCT FROM p_clrother AND lv.clrcontpref IS NOT DISTINCT FROM p_clrcontpref AND lv.reqcompany IS NOT DISTINCT FROM p_reqcompany AND lv.reqaddr1 IS NOT DISTINCT FROM p_reqaddr1 AND lv.reqaddr2 IS NOT DISTINCT FROM p_reqaddr2 AND lv.reqcity IS NOT DISTINCT FROM p_reqcity AND lv.reqstate IS NOT DISTINCT FROM p_reqstate AND lv.reqzip IS NOT DISTINCT FROM p_reqzip AND lv.reqcrossst IS NOT DISTINCT FROM p_reqcrossst AND lv.reqsubdiv IS NOT DISTINCT FROM p_reqsubdiv AND lv.reqmapgrid IS NOT DISTINCT FROM p_reqmapgrid AND lv.reqpermission IS NOT DISTINCT FROM p_reqpermission AND lv.reqtarget IS NOT DISTINCT FROM p_reqtarget AND lv.reqdescr IS NOT DISTINCT FROM p_reqdescr AND lv.reqnotesfortech IS NOT DISTINCT FROM p_reqnotesfortech AND lv.reqnotesforcust IS NOT DISTINCT FROM p_reqnotesforcust AND lv.reqfldnotes IS NOT DISTINCT FROM p_reqfldnotes AND lv.reqprogramactions IS NOT DISTINCT FROM p_reqprogramactions AND lv.datetimeclosed IS NOT DISTINCT FROM p_datetimeclosed AND lv.techclosed IS NOT DISTINCT FROM p_techclosed AND lv.sr_number IS NOT DISTINCT FROM p_sr_number AND lv.reviewed IS NOT DISTINCT FROM p_reviewed AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate AND lv.accepted IS NOT DISTINCT FROM p_accepted AND lv.accepteddate IS NOT DISTINCT FROM p_accepteddate AND lv.rejectedby IS NOT DISTINCT FROM p_rejectedby AND lv.rejecteddate IS NOT DISTINCT FROM p_rejecteddate AND lv.rejectedreason IS NOT DISTINCT FROM p_rejectedreason AND lv.duedate IS NOT DISTINCT FROM p_duedate AND lv.acceptedby IS NOT DISTINCT FROM p_acceptedby AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.estcompletedate IS NOT DISTINCT FROM p_estcompletedate AND lv.nextaction IS NOT DISTINCT FROM p_nextaction AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.firstresponsedate IS NOT DISTINCT FROM p_firstresponsedate AND lv.responsedaycount IS NOT DISTINCT FROM p_responsedaycount AND lv.allowed IS NOT DISTINCT FROM p_allowed AND lv.xvalue IS NOT DISTINCT FROM p_xvalue AND lv.yvalue IS NOT DISTINCT FROM p_yvalue AND lv.validx IS NOT DISTINCT FROM p_validx AND lv.validy IS NOT DISTINCT FROM p_validy AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.externalerror IS NOT DISTINCT FROM p_externalerror AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid AND lv.notified IS NOT DISTINCT FROM p_notified AND lv.notifieddate IS NOT DISTINCT FROM p_notifieddate AND lv.scheduled IS NOT DISTINCT FROM p_scheduled AND lv.scheduleddate IS NOT DISTINCT FROM p_scheduleddate AND lv.dog IS NOT DISTINCT FROM p_dog AND lv.schedule_period IS NOT DISTINCT FROM p_schedule_period AND lv.schedule_notes IS NOT DISTINCT FROM p_schedule_notes AND lv.spanish IS NOT DISTINCT FROM p_spanish AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.issuesreported IS NOT DISTINCT FROM p_issuesreported AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction AND lv.notificationtimestamp IS NOT DISTINCT FROM p_notificationtimestamp AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + + AND lv.recdatetime IS NOT DISTINCT FROM p_recdatetime + AND lv.source IS NOT DISTINCT FROM p_source + AND lv.entrytech IS NOT DISTINCT FROM p_entrytech + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.supervisor IS NOT DISTINCT FROM p_supervisor + AND lv.assignedtech IS NOT DISTINCT FROM p_assignedtech + AND lv.status IS NOT DISTINCT FROM p_status + AND lv.clranon IS NOT DISTINCT FROM p_clranon + AND lv.clrfname IS NOT DISTINCT FROM p_clrfname + AND lv.clrphone1 IS NOT DISTINCT FROM p_clrphone1 + AND lv.clrphone2 IS NOT DISTINCT FROM p_clrphone2 + AND lv.clremail IS NOT DISTINCT FROM p_clremail + AND lv.clrcompany IS NOT DISTINCT FROM p_clrcompany + AND lv.clraddr1 IS NOT DISTINCT FROM p_clraddr1 + AND lv.clraddr2 IS NOT DISTINCT FROM p_clraddr2 + AND lv.clrcity IS NOT DISTINCT FROM p_clrcity + AND lv.clrstate IS NOT DISTINCT FROM p_clrstate + AND lv.clrzip IS NOT DISTINCT FROM p_clrzip + AND lv.clrother IS NOT DISTINCT FROM p_clrother + AND lv.clrcontpref IS NOT DISTINCT FROM p_clrcontpref + AND lv.reqcompany IS NOT DISTINCT FROM p_reqcompany + AND lv.reqaddr1 IS NOT DISTINCT FROM p_reqaddr1 + AND lv.reqaddr2 IS NOT DISTINCT FROM p_reqaddr2 + AND lv.reqcity IS NOT DISTINCT FROM p_reqcity + AND lv.reqstate IS NOT DISTINCT FROM p_reqstate + AND lv.reqzip IS NOT DISTINCT FROM p_reqzip + AND lv.reqcrossst IS NOT DISTINCT FROM p_reqcrossst + AND lv.reqsubdiv IS NOT DISTINCT FROM p_reqsubdiv + AND lv.reqmapgrid IS NOT DISTINCT FROM p_reqmapgrid + AND lv.reqpermission IS NOT DISTINCT FROM p_reqpermission + AND lv.reqtarget IS NOT DISTINCT FROM p_reqtarget + AND lv.reqdescr IS NOT DISTINCT FROM p_reqdescr + AND lv.reqnotesfortech IS NOT DISTINCT FROM p_reqnotesfortech + AND lv.reqnotesforcust IS NOT DISTINCT FROM p_reqnotesforcust + AND lv.reqfldnotes IS NOT DISTINCT FROM p_reqfldnotes + AND lv.reqprogramactions IS NOT DISTINCT FROM p_reqprogramactions + AND lv.datetimeclosed IS NOT DISTINCT FROM p_datetimeclosed + AND lv.techclosed IS NOT DISTINCT FROM p_techclosed + AND lv.sr_number IS NOT DISTINCT FROM p_sr_number + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.accepted IS NOT DISTINCT FROM p_accepted + AND lv.accepteddate IS NOT DISTINCT FROM p_accepteddate + AND lv.rejectedby IS NOT DISTINCT FROM p_rejectedby + AND lv.rejecteddate IS NOT DISTINCT FROM p_rejecteddate + AND lv.rejectedreason IS NOT DISTINCT FROM p_rejectedreason + AND lv.duedate IS NOT DISTINCT FROM p_duedate + AND lv.acceptedby IS NOT DISTINCT FROM p_acceptedby + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.estcompletedate IS NOT DISTINCT FROM p_estcompletedate + AND lv.nextaction IS NOT DISTINCT FROM p_nextaction + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.firstresponsedate IS NOT DISTINCT FROM p_firstresponsedate + AND lv.responsedaycount IS NOT DISTINCT FROM p_responsedaycount + AND lv.allowed IS NOT DISTINCT FROM p_allowed + AND lv.xvalue IS NOT DISTINCT FROM p_xvalue + AND lv.yvalue IS NOT DISTINCT FROM p_yvalue + AND lv.validx IS NOT DISTINCT FROM p_validx + AND lv.validy IS NOT DISTINCT FROM p_validy + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.externalerror IS NOT DISTINCT FROM p_externalerror + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.notified IS NOT DISTINCT FROM p_notified + AND lv.notifieddate IS NOT DISTINCT FROM p_notifieddate + AND lv.scheduled IS NOT DISTINCT FROM p_scheduled + AND lv.scheduleddate IS NOT DISTINCT FROM p_scheduleddate + AND lv.dog IS NOT DISTINCT FROM p_dog + AND lv.schedule_period IS NOT DISTINCT FROM p_schedule_period + AND lv.schedule_notes IS NOT DISTINCT FROM p_schedule_notes + AND lv.spanish IS NOT DISTINCT FROM p_spanish + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.issuesreported IS NOT DISTINCT FROM p_issuesreported + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.notificationtimestamp IS NOT DISTINCT FROM p_notificationtimestamp + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -895,11 +3173,185 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.servicerequest ( objectid, - recdatetime, source, entrytech, priority, supervisor, assignedtech, status, clranon, clrfname, clrphone1, clrphone2, clremail, clrcompany, clraddr1, clraddr2, clrcity, clrstate, clrzip, clrother, clrcontpref, reqcompany, reqaddr1, reqaddr2, reqcity, reqstate, reqzip, reqcrossst, reqsubdiv, reqmapgrid, reqpermission, reqtarget, reqdescr, reqnotesfortech, reqnotesforcust, reqfldnotes, reqprogramactions, datetimeclosed, techclosed, sr_number, reviewed, reviewedby, revieweddate, accepted, accepteddate, rejectedby, rejecteddate, rejectedreason, duedate, acceptedby, comments, estcompletedate, nextaction, recordstatus, globalid, created_user, created_date, last_edited_user, last_edited_date, firstresponsedate, responsedaycount, allowed, xvalue, yvalue, validx, validy, externalid, externalerror, pointlocid, notified, notifieddate, scheduled, scheduleddate, dog, schedule_period, schedule_notes, spanish, creationdate, creator, editdate, editor, issuesreported, jurisdiction, notificationtimestamp, zone, zone2, + + recdatetime, + source, + entrytech, + priority, + supervisor, + assignedtech, + status, + clranon, + clrfname, + clrphone1, + clrphone2, + clremail, + clrcompany, + clraddr1, + clraddr2, + clrcity, + clrstate, + clrzip, + clrother, + clrcontpref, + reqcompany, + reqaddr1, + reqaddr2, + reqcity, + reqstate, + reqzip, + reqcrossst, + reqsubdiv, + reqmapgrid, + reqpermission, + reqtarget, + reqdescr, + reqnotesfortech, + reqnotesforcust, + reqfldnotes, + reqprogramactions, + datetimeclosed, + techclosed, + sr_number, + reviewed, + reviewedby, + revieweddate, + accepted, + accepteddate, + rejectedby, + rejecteddate, + rejectedreason, + duedate, + acceptedby, + comments, + estcompletedate, + nextaction, + recordstatus, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + firstresponsedate, + responsedaycount, + allowed, + xvalue, + yvalue, + validx, + validy, + externalid, + externalerror, + pointlocid, + notified, + notifieddate, + scheduled, + scheduleddate, + dog, + schedule_period, + schedule_notes, + spanish, + creationdate, + creator, + editdate, + editor, + issuesreported, + jurisdiction, + notificationtimestamp, + zone, + zone2, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_recdatetime, p_source, p_entrytech, p_priority, p_supervisor, p_assignedtech, p_status, p_clranon, p_clrfname, p_clrphone1, p_clrphone2, p_clremail, p_clrcompany, p_clraddr1, p_clraddr2, p_clrcity, p_clrstate, p_clrzip, p_clrother, p_clrcontpref, p_reqcompany, p_reqaddr1, p_reqaddr2, p_reqcity, p_reqstate, p_reqzip, p_reqcrossst, p_reqsubdiv, p_reqmapgrid, p_reqpermission, p_reqtarget, p_reqdescr, p_reqnotesfortech, p_reqnotesforcust, p_reqfldnotes, p_reqprogramactions, p_datetimeclosed, p_techclosed, p_sr_number, p_reviewed, p_reviewedby, p_revieweddate, p_accepted, p_accepteddate, p_rejectedby, p_rejecteddate, p_rejectedreason, p_duedate, p_acceptedby, p_comments, p_estcompletedate, p_nextaction, p_recordstatus, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_firstresponsedate, p_responsedaycount, p_allowed, p_xvalue, p_yvalue, p_validx, p_validy, p_externalid, p_externalerror, p_pointlocid, p_notified, p_notifieddate, p_scheduled, p_scheduleddate, p_dog, p_schedule_period, p_schedule_notes, p_spanish, p_creationdate, p_creator, p_editdate, p_editor, p_issuesreported, p_jurisdiction, p_notificationtimestamp, p_zone, p_zone2, + + p_recdatetime, + p_source, + p_entrytech, + p_priority, + p_supervisor, + p_assignedtech, + p_status, + p_clranon, + p_clrfname, + p_clrphone1, + p_clrphone2, + p_clremail, + p_clrcompany, + p_clraddr1, + p_clraddr2, + p_clrcity, + p_clrstate, + p_clrzip, + p_clrother, + p_clrcontpref, + p_reqcompany, + p_reqaddr1, + p_reqaddr2, + p_reqcity, + p_reqstate, + p_reqzip, + p_reqcrossst, + p_reqsubdiv, + p_reqmapgrid, + p_reqpermission, + p_reqtarget, + p_reqdescr, + p_reqnotesfortech, + p_reqnotesforcust, + p_reqfldnotes, + p_reqprogramactions, + p_datetimeclosed, + p_techclosed, + p_sr_number, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_accepted, + p_accepteddate, + p_rejectedby, + p_rejecteddate, + p_rejectedreason, + p_duedate, + p_acceptedby, + p_comments, + p_estcompletedate, + p_nextaction, + p_recordstatus, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_firstresponsedate, + p_responsedaycount, + p_allowed, + p_xvalue, + p_yvalue, + p_validx, + p_validy, + p_externalid, + p_externalerror, + p_pointlocid, + p_notified, + p_notifieddate, + p_scheduled, + p_scheduleddate, + p_dog, + p_schedule_period, + p_schedule_notes, + p_spanish, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_issuesreported, + p_jurisdiction, + p_notificationtimestamp, + p_zone, + p_zone2, + p_geometry, + p_geospatial, v_next_version ); @@ -907,12 +3359,42 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_speciesabundance( p_objectid bigint, - p_trapdata_id uuid,p_species varchar,p_males smallint,p_unknown smallint,p_bloodedfem smallint,p_gravidfem smallint,p_larvae smallint,p_poolstogen smallint,p_processed smallint,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_pupae smallint,p_eggs smallint,p_females integer,p_total integer,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_yearweek integer,p_globalzscore double precision,p_r7score double precision,p_r8score double precision,p_h3r7 varchar,p_h3r8 varchar + + p_trapdata_id uuid, + p_species varchar, + p_males smallint, + p_unknown smallint, + p_bloodedfem smallint, + p_gravidfem smallint, + p_larvae smallint, + p_poolstogen smallint, + p_processed smallint, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_pupae smallint, + p_eggs smallint, + p_females integer, + p_total integer, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_yearweek integer, + p_globalzscore double precision, + p_r7score double precision, + p_r8score double precision, + p_h3r7 varchar, + p_h3r8 varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -922,7 +3404,37 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.speciesabundance lv WHERE lv.objectid = p_objectid - AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id AND lv.species IS NOT DISTINCT FROM p_species AND lv.males IS NOT DISTINCT FROM p_males AND lv.unknown IS NOT DISTINCT FROM p_unknown AND lv.bloodedfem IS NOT DISTINCT FROM p_bloodedfem AND lv.gravidfem IS NOT DISTINCT FROM p_gravidfem AND lv.larvae IS NOT DISTINCT FROM p_larvae AND lv.poolstogen IS NOT DISTINCT FROM p_poolstogen AND lv.processed IS NOT DISTINCT FROM p_processed AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.pupae IS NOT DISTINCT FROM p_pupae AND lv.eggs IS NOT DISTINCT FROM p_eggs AND lv.females IS NOT DISTINCT FROM p_females AND lv.total IS NOT DISTINCT FROM p_total AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.yearweek IS NOT DISTINCT FROM p_yearweek AND lv.globalzscore IS NOT DISTINCT FROM p_globalzscore AND lv.r7score IS NOT DISTINCT FROM p_r7score AND lv.r8score IS NOT DISTINCT FROM p_r8score AND lv.h3r7 IS NOT DISTINCT FROM p_h3r7 AND lv.h3r8 IS NOT DISTINCT FROM p_h3r8 + + AND lv.trapdata_id IS NOT DISTINCT FROM p_trapdata_id + AND lv.species IS NOT DISTINCT FROM p_species + AND lv.males IS NOT DISTINCT FROM p_males + AND lv.unknown IS NOT DISTINCT FROM p_unknown + AND lv.bloodedfem IS NOT DISTINCT FROM p_bloodedfem + AND lv.gravidfem IS NOT DISTINCT FROM p_gravidfem + AND lv.larvae IS NOT DISTINCT FROM p_larvae + AND lv.poolstogen IS NOT DISTINCT FROM p_poolstogen + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.pupae IS NOT DISTINCT FROM p_pupae + AND lv.eggs IS NOT DISTINCT FROM p_eggs + AND lv.females IS NOT DISTINCT FROM p_females + AND lv.total IS NOT DISTINCT FROM p_total + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.yearweek IS NOT DISTINCT FROM p_yearweek + AND lv.globalzscore IS NOT DISTINCT FROM p_globalzscore + AND lv.r7score IS NOT DISTINCT FROM p_r7score + AND lv.r8score IS NOT DISTINCT FROM p_r8score + AND lv.h3r7 IS NOT DISTINCT FROM p_h3r7 + AND lv.h3r8 IS NOT DISTINCT FROM p_h3r8 + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -944,11 +3456,71 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.speciesabundance ( objectid, - trapdata_id, species, males, unknown, bloodedfem, gravidfem, larvae, poolstogen, processed, globalid, created_user, created_date, last_edited_user, last_edited_date, pupae, eggs, females, total, creationdate, creator, editdate, editor, yearweek, globalzscore, r7score, r8score, h3r7, h3r8, + + trapdata_id, + species, + males, + unknown, + bloodedfem, + gravidfem, + larvae, + poolstogen, + processed, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + pupae, + eggs, + females, + total, + creationdate, + creator, + editdate, + editor, + yearweek, + globalzscore, + r7score, + r8score, + h3r7, + h3r8, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_trapdata_id, p_species, p_males, p_unknown, p_bloodedfem, p_gravidfem, p_larvae, p_poolstogen, p_processed, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_pupae, p_eggs, p_females, p_total, p_creationdate, p_creator, p_editdate, p_editor, p_yearweek, p_globalzscore, p_r7score, p_r8score, p_h3r7, p_h3r8, + + p_trapdata_id, + p_species, + p_males, + p_unknown, + p_bloodedfem, + p_gravidfem, + p_larvae, + p_poolstogen, + p_processed, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_pupae, + p_eggs, + p_females, + p_total, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_yearweek, + p_globalzscore, + p_r7score, + p_r8score, + p_h3r7, + p_h3r8, + p_geometry, + p_geospatial, v_next_version ); @@ -956,12 +3528,32 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_stormdrain( p_objectid bigint, - p_nexttreatmentdate timestamp,p_lasttreatdate timestamp,p_lastaction varchar,p_symbology varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_laststatus varchar,p_zone varchar,p_zone2 varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_type varchar,p_jurisdiction varchar + + p_nexttreatmentdate timestamp, + p_lasttreatdate timestamp, + p_lastaction varchar, + p_symbology varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_laststatus varchar, + p_zone varchar, + p_zone2 varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_type varchar, + p_jurisdiction varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -971,7 +3563,27 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.stormdrain lv WHERE lv.objectid = p_objectid - AND lv.nexttreatmentdate IS NOT DISTINCT FROM p_nexttreatmentdate AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate AND lv.lastaction IS NOT DISTINCT FROM p_lastaction AND lv.symbology IS NOT DISTINCT FROM p_symbology AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.laststatus IS NOT DISTINCT FROM p_laststatus AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.type IS NOT DISTINCT FROM p_type AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + + AND lv.nexttreatmentdate IS NOT DISTINCT FROM p_nexttreatmentdate + AND lv.lasttreatdate IS NOT DISTINCT FROM p_lasttreatdate + AND lv.lastaction IS NOT DISTINCT FROM p_lastaction + AND lv.symbology IS NOT DISTINCT FROM p_symbology + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.laststatus IS NOT DISTINCT FROM p_laststatus + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.type IS NOT DISTINCT FROM p_type + AND lv.jurisdiction IS NOT DISTINCT FROM p_jurisdiction + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -993,11 +3605,51 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.stormdrain ( objectid, - nexttreatmentdate, lasttreatdate, lastaction, symbology, globalid, created_user, created_date, last_edited_user, last_edited_date, laststatus, zone, zone2, creationdate, creator, editdate, editor, type, jurisdiction, + + nexttreatmentdate, + lasttreatdate, + lastaction, + symbology, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + laststatus, + zone, + zone2, + creationdate, + creator, + editdate, + editor, + type, + jurisdiction, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_nexttreatmentdate, p_lasttreatdate, p_lastaction, p_symbology, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_laststatus, p_zone, p_zone2, p_creationdate, p_creator, p_editdate, p_editor, p_type, p_jurisdiction, + + p_nexttreatmentdate, + p_lasttreatdate, + p_lastaction, + p_symbology, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_laststatus, + p_zone, + p_zone2, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_type, + p_jurisdiction, + p_geometry, + p_geospatial, v_next_version ); @@ -1005,12 +3657,41 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_timecard( p_objectid bigint, - p_activity varchar,p_startdatetime timestamp,p_enddatetime timestamp,p_comments varchar,p_externalid varchar,p_equiptype varchar,p_locationname varchar,p_zone varchar,p_zone2 varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_linelocid uuid,p_pointlocid uuid,p_polygonlocid uuid,p_lclocid uuid,p_samplelocid uuid,p_srid uuid,p_traplocid uuid,p_fieldtech varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_rodentlocid uuid + + p_activity varchar, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_comments varchar, + p_externalid varchar, + p_equiptype varchar, + p_locationname varchar, + p_zone varchar, + p_zone2 varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_lclocid uuid, + p_samplelocid uuid, + p_srid uuid, + p_traplocid uuid, + p_fieldtech varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_rodentlocid uuid, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -1020,7 +3701,36 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.timecard lv WHERE lv.objectid = p_objectid - AND lv.activity IS NOT DISTINCT FROM p_activity AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.equiptype IS NOT DISTINCT FROM p_equiptype AND lv.locationname IS NOT DISTINCT FROM p_locationname AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.linelocid IS NOT DISTINCT FROM p_linelocid AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid AND lv.lclocid IS NOT DISTINCT FROM p_lclocid AND lv.samplelocid IS NOT DISTINCT FROM p_samplelocid AND lv.srid IS NOT DISTINCT FROM p_srid AND lv.traplocid IS NOT DISTINCT FROM p_traplocid AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.rodentlocid IS NOT DISTINCT FROM p_rodentlocid + + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.equiptype IS NOT DISTINCT FROM p_equiptype + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.lclocid IS NOT DISTINCT FROM p_lclocid + AND lv.samplelocid IS NOT DISTINCT FROM p_samplelocid + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.traplocid IS NOT DISTINCT FROM p_traplocid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.rodentlocid IS NOT DISTINCT FROM p_rodentlocid + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -1042,11 +3752,69 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.timecard ( objectid, - activity, startdatetime, enddatetime, comments, externalid, equiptype, locationname, zone, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, linelocid, pointlocid, polygonlocid, lclocid, samplelocid, srid, traplocid, fieldtech, creationdate, creator, editdate, editor, rodentlocid, + + activity, + startdatetime, + enddatetime, + comments, + externalid, + equiptype, + locationname, + zone, + zone2, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + linelocid, + pointlocid, + polygonlocid, + lclocid, + samplelocid, + srid, + traplocid, + fieldtech, + creationdate, + creator, + editdate, + editor, + rodentlocid, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_activity, p_startdatetime, p_enddatetime, p_comments, p_externalid, p_equiptype, p_locationname, p_zone, p_zone2, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_linelocid, p_pointlocid, p_polygonlocid, p_lclocid, p_samplelocid, p_srid, p_traplocid, p_fieldtech, p_creationdate, p_creator, p_editdate, p_editor, p_rodentlocid, + + p_activity, + p_startdatetime, + p_enddatetime, + p_comments, + p_externalid, + p_equiptype, + p_locationname, + p_zone, + p_zone2, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_lclocid, + p_samplelocid, + p_srid, + p_traplocid, + p_fieldtech, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_rodentlocid, + p_geometry, + p_geospatial, v_next_version ); @@ -1054,12 +3822,55 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_trapdata( p_objectid bigint, - p_traptype varchar,p_trapactivitytype varchar,p_startdatetime timestamp,p_enddatetime timestamp,p_comments varchar,p_idbytech varchar,p_sortbytech varchar,p_processed smallint,p_sitecond varchar,p_locationname varchar,p_recordstatus smallint,p_reviewed smallint,p_reviewedby varchar,p_revieweddate timestamp,p_trapcondition varchar,p_trapnights smallint,p_zone varchar,p_zone2 varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_srid uuid,p_fieldtech varchar,p_gatewaysync smallint,p_loc_id uuid,p_voltage double precision,p_winddir varchar,p_windspeed double precision,p_avetemp double precision,p_raingauge double precision,p_lr smallint,p_field integer,p_vectorsurvtrapdataid varchar,p_vectorsurvtraplocationid varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_lure varchar + + p_traptype varchar, + p_trapactivitytype varchar, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_comments varchar, + p_idbytech varchar, + p_sortbytech varchar, + p_processed smallint, + p_sitecond varchar, + p_locationname varchar, + p_recordstatus smallint, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_trapcondition varchar, + p_trapnights smallint, + p_zone varchar, + p_zone2 varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_srid uuid, + p_fieldtech varchar, + p_gatewaysync smallint, + p_loc_id uuid, + p_voltage double precision, + p_winddir varchar, + p_windspeed double precision, + p_avetemp double precision, + p_raingauge double precision, + p_lr smallint, + p_field integer, + p_vectorsurvtrapdataid varchar, + p_vectorsurvtraplocationid varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_lure varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -1069,7 +3880,50 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.trapdata lv WHERE lv.objectid = p_objectid - AND lv.traptype IS NOT DISTINCT FROM p_traptype AND lv.trapactivitytype IS NOT DISTINCT FROM p_trapactivitytype AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.idbytech IS NOT DISTINCT FROM p_idbytech AND lv.sortbytech IS NOT DISTINCT FROM p_sortbytech AND lv.processed IS NOT DISTINCT FROM p_processed AND lv.sitecond IS NOT DISTINCT FROM p_sitecond AND lv.locationname IS NOT DISTINCT FROM p_locationname AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus AND lv.reviewed IS NOT DISTINCT FROM p_reviewed AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate AND lv.trapcondition IS NOT DISTINCT FROM p_trapcondition AND lv.trapnights IS NOT DISTINCT FROM p_trapnights AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.srid IS NOT DISTINCT FROM p_srid AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync AND lv.loc_id IS NOT DISTINCT FROM p_loc_id AND lv.voltage IS NOT DISTINCT FROM p_voltage AND lv.winddir IS NOT DISTINCT FROM p_winddir AND lv.windspeed IS NOT DISTINCT FROM p_windspeed AND lv.avetemp IS NOT DISTINCT FROM p_avetemp AND lv.raingauge IS NOT DISTINCT FROM p_raingauge AND lv.lr IS NOT DISTINCT FROM p_lr AND lv.field IS NOT DISTINCT FROM p_field AND lv.vectorsurvtrapdataid IS NOT DISTINCT FROM p_vectorsurvtrapdataid AND lv.vectorsurvtraplocationid IS NOT DISTINCT FROM p_vectorsurvtraplocationid AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.lure IS NOT DISTINCT FROM p_lure + + AND lv.traptype IS NOT DISTINCT FROM p_traptype + AND lv.trapactivitytype IS NOT DISTINCT FROM p_trapactivitytype + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.idbytech IS NOT DISTINCT FROM p_idbytech + AND lv.sortbytech IS NOT DISTINCT FROM p_sortbytech + AND lv.processed IS NOT DISTINCT FROM p_processed + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.trapcondition IS NOT DISTINCT FROM p_trapcondition + AND lv.trapnights IS NOT DISTINCT FROM p_trapnights + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.loc_id IS NOT DISTINCT FROM p_loc_id + AND lv.voltage IS NOT DISTINCT FROM p_voltage + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.lr IS NOT DISTINCT FROM p_lr + AND lv.field IS NOT DISTINCT FROM p_field + AND lv.vectorsurvtrapdataid IS NOT DISTINCT FROM p_vectorsurvtrapdataid + AND lv.vectorsurvtraplocationid IS NOT DISTINCT FROM p_vectorsurvtraplocationid + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.lure IS NOT DISTINCT FROM p_lure + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -1091,11 +3945,97 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.trapdata ( objectid, - traptype, trapactivitytype, startdatetime, enddatetime, comments, idbytech, sortbytech, processed, sitecond, locationname, recordstatus, reviewed, reviewedby, revieweddate, trapcondition, trapnights, zone, zone2, globalid, created_user, created_date, last_edited_user, last_edited_date, srid, fieldtech, gatewaysync, loc_id, voltage, winddir, windspeed, avetemp, raingauge, lr, field, vectorsurvtrapdataid, vectorsurvtraplocationid, creationdate, creator, editdate, editor, lure, + + traptype, + trapactivitytype, + startdatetime, + enddatetime, + comments, + idbytech, + sortbytech, + processed, + sitecond, + locationname, + recordstatus, + reviewed, + reviewedby, + revieweddate, + trapcondition, + trapnights, + zone, + zone2, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + srid, + fieldtech, + gatewaysync, + loc_id, + voltage, + winddir, + windspeed, + avetemp, + raingauge, + lr, + field, + vectorsurvtrapdataid, + vectorsurvtraplocationid, + creationdate, + creator, + editdate, + editor, + lure, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_traptype, p_trapactivitytype, p_startdatetime, p_enddatetime, p_comments, p_idbytech, p_sortbytech, p_processed, p_sitecond, p_locationname, p_recordstatus, p_reviewed, p_reviewedby, p_revieweddate, p_trapcondition, p_trapnights, p_zone, p_zone2, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_srid, p_fieldtech, p_gatewaysync, p_loc_id, p_voltage, p_winddir, p_windspeed, p_avetemp, p_raingauge, p_lr, p_field, p_vectorsurvtrapdataid, p_vectorsurvtraplocationid, p_creationdate, p_creator, p_editdate, p_editor, p_lure, + + p_traptype, + p_trapactivitytype, + p_startdatetime, + p_enddatetime, + p_comments, + p_idbytech, + p_sortbytech, + p_processed, + p_sitecond, + p_locationname, + p_recordstatus, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_trapcondition, + p_trapnights, + p_zone, + p_zone2, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_srid, + p_fieldtech, + p_gatewaysync, + p_loc_id, + p_voltage, + p_winddir, + p_windspeed, + p_avetemp, + p_raingauge, + p_lr, + p_field, + p_vectorsurvtrapdataid, + p_vectorsurvtraplocationid, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_lure, + p_geometry, + p_geospatial, v_next_version ); @@ -1103,12 +4043,43 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_traplocation( p_objectid bigint, - p_name varchar,p_zone varchar,p_habitat varchar,p_priority varchar,p_usetype varchar,p_active smallint,p_description varchar,p_accessdesc varchar,p_comments varchar,p_externalid varchar,p_nextactiondatescheduled timestamp,p_zone2 varchar,p_locationnumber integer,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_gatewaysync smallint,p_route integer,p_set_dow integer,p_route_order integer,p_vectorsurvsiteid varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_h3r7 varchar,p_h3r8 varchar + + p_name varchar, + p_zone varchar, + p_habitat varchar, + p_priority varchar, + p_usetype varchar, + p_active smallint, + p_description varchar, + p_accessdesc varchar, + p_comments varchar, + p_externalid varchar, + p_nextactiondatescheduled timestamp, + p_zone2 varchar, + p_locationnumber integer, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_gatewaysync smallint, + p_route integer, + p_set_dow integer, + p_route_order integer, + p_vectorsurvsiteid varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_h3r7 varchar, + p_h3r8 varchar, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -1118,7 +4089,38 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.traplocation lv WHERE lv.objectid = p_objectid - AND lv.name IS NOT DISTINCT FROM p_name AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.habitat IS NOT DISTINCT FROM p_habitat AND lv.priority IS NOT DISTINCT FROM p_priority AND lv.usetype IS NOT DISTINCT FROM p_usetype AND lv.active IS NOT DISTINCT FROM p_active AND lv.description IS NOT DISTINCT FROM p_description AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.externalid IS NOT DISTINCT FROM p_externalid AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync AND lv.route IS NOT DISTINCT FROM p_route AND lv.set_dow IS NOT DISTINCT FROM p_set_dow AND lv.route_order IS NOT DISTINCT FROM p_route_order AND lv.vectorsurvsiteid IS NOT DISTINCT FROM p_vectorsurvsiteid AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.h3r7 IS NOT DISTINCT FROM p_h3r7 AND lv.h3r8 IS NOT DISTINCT FROM p_h3r8 + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.priority IS NOT DISTINCT FROM p_priority + AND lv.usetype IS NOT DISTINCT FROM p_usetype + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.description IS NOT DISTINCT FROM p_description + AND lv.accessdesc IS NOT DISTINCT FROM p_accessdesc + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.externalid IS NOT DISTINCT FROM p_externalid + AND lv.nextactiondatescheduled IS NOT DISTINCT FROM p_nextactiondatescheduled + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.locationnumber IS NOT DISTINCT FROM p_locationnumber + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.gatewaysync IS NOT DISTINCT FROM p_gatewaysync + AND lv.route IS NOT DISTINCT FROM p_route + AND lv.set_dow IS NOT DISTINCT FROM p_set_dow + AND lv.route_order IS NOT DISTINCT FROM p_route_order + AND lv.vectorsurvsiteid IS NOT DISTINCT FROM p_vectorsurvsiteid + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.h3r7 IS NOT DISTINCT FROM p_h3r7 + AND lv.h3r8 IS NOT DISTINCT FROM p_h3r8 + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -1140,11 +4142,73 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.traplocation ( objectid, - name, zone, habitat, priority, usetype, active, description, accessdesc, comments, externalid, nextactiondatescheduled, zone2, locationnumber, globalid, created_user, created_date, last_edited_user, last_edited_date, gatewaysync, route, set_dow, route_order, vectorsurvsiteid, creationdate, creator, editdate, editor, h3r7, h3r8, + + name, + zone, + habitat, + priority, + usetype, + active, + description, + accessdesc, + comments, + externalid, + nextactiondatescheduled, + zone2, + locationnumber, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + gatewaysync, + route, + set_dow, + route_order, + vectorsurvsiteid, + creationdate, + creator, + editdate, + editor, + h3r7, + h3r8, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_name, p_zone, p_habitat, p_priority, p_usetype, p_active, p_description, p_accessdesc, p_comments, p_externalid, p_nextactiondatescheduled, p_zone2, p_locationnumber, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_gatewaysync, p_route, p_set_dow, p_route_order, p_vectorsurvsiteid, p_creationdate, p_creator, p_editdate, p_editor, p_h3r7, p_h3r8, + + p_name, + p_zone, + p_habitat, + p_priority, + p_usetype, + p_active, + p_description, + p_accessdesc, + p_comments, + p_externalid, + p_nextactiondatescheduled, + p_zone2, + p_locationnumber, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_gatewaysync, + p_route, + p_set_dow, + p_route_order, + p_vectorsurvsiteid, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_h3r7, + p_h3r8, + p_geometry, + p_geospatial, v_next_version ); @@ -1152,61 +4216,31 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd --- +goose StatementBegin -CREATE OR REPLACE FUNCTION fieldseeker.insert_treatment( - p_objectid bigint, - p_activity varchar,p_treatarea double precision,p_areaunit varchar,p_product varchar,p_qty double precision,p_qtyunit varchar,p_method varchar,p_equiptype varchar,p_comments varchar,p_avetemp double precision,p_windspeed double precision,p_winddir varchar,p_raingauge double precision,p_startdatetime timestamp,p_enddatetime timestamp,p_insp_id uuid,p_reviewed smallint,p_reviewedby varchar,p_revieweddate timestamp,p_locationname varchar,p_zone varchar,p_warningoverride smallint,p_recordstatus smallint,p_zone2 varchar,p_treatacres double precision,p_tirecount smallint,p_cbcount smallint,p_containercount smallint,p_globalid uuid,p_treatmentlength double precision,p_treatmenthours double precision,p_treatmentlengthunits varchar,p_linelocid uuid,p_pointlocid uuid,p_polygonlocid uuid,p_srid uuid,p_sdid uuid,p_barrierrouteid uuid,p_ulvrouteid uuid,p_fieldtech varchar,p_ptaid uuid,p_flowrate double precision,p_habitat varchar,p_treathectares double precision,p_invloc varchar,p_temp_sitecond varchar,p_sitecond varchar,p_totalcostprodcut double precision,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_targetspecies varchar -) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ -DECLARE - v_next_version integer; - v_changes_exist boolean; -BEGIN - -- Check if changes exist - SELECT NOT EXISTS ( - SELECT 1 FROM fieldseeker.treatment lv - WHERE lv.objectid = p_objectid - AND lv.activity IS NOT DISTINCT FROM p_activity AND lv.treatarea IS NOT DISTINCT FROM p_treatarea AND lv.areaunit IS NOT DISTINCT FROM p_areaunit AND lv.product IS NOT DISTINCT FROM p_product AND lv.qty IS NOT DISTINCT FROM p_qty AND lv.qtyunit IS NOT DISTINCT FROM p_qtyunit AND lv.method IS NOT DISTINCT FROM p_method AND lv.equiptype IS NOT DISTINCT FROM p_equiptype AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.avetemp IS NOT DISTINCT FROM p_avetemp AND lv.windspeed IS NOT DISTINCT FROM p_windspeed AND lv.winddir IS NOT DISTINCT FROM p_winddir AND lv.raingauge IS NOT DISTINCT FROM p_raingauge AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime AND lv.insp_id IS NOT DISTINCT FROM p_insp_id AND lv.reviewed IS NOT DISTINCT FROM p_reviewed AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate AND lv.locationname IS NOT DISTINCT FROM p_locationname AND lv.zone IS NOT DISTINCT FROM p_zone AND lv.warningoverride IS NOT DISTINCT FROM p_warningoverride AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus AND lv.zone2 IS NOT DISTINCT FROM p_zone2 AND lv.treatacres IS NOT DISTINCT FROM p_treatacres AND lv.tirecount IS NOT DISTINCT FROM p_tirecount AND lv.cbcount IS NOT DISTINCT FROM p_cbcount AND lv.containercount IS NOT DISTINCT FROM p_containercount AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.treatmentlength IS NOT DISTINCT FROM p_treatmentlength AND lv.treatmenthours IS NOT DISTINCT FROM p_treatmenthours AND lv.treatmentlengthunits IS NOT DISTINCT FROM p_treatmentlengthunits AND lv.linelocid IS NOT DISTINCT FROM p_linelocid AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid AND lv.srid IS NOT DISTINCT FROM p_srid AND lv.sdid IS NOT DISTINCT FROM p_sdid AND lv.barrierrouteid IS NOT DISTINCT FROM p_barrierrouteid AND lv.ulvrouteid IS NOT DISTINCT FROM p_ulvrouteid AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech AND lv.ptaid IS NOT DISTINCT FROM p_ptaid AND lv.flowrate IS NOT DISTINCT FROM p_flowrate AND lv.habitat IS NOT DISTINCT FROM p_habitat AND lv.treathectares IS NOT DISTINCT FROM p_treathectares AND lv.invloc IS NOT DISTINCT FROM p_invloc AND lv.temp_sitecond IS NOT DISTINCT FROM p_temp_sitecond AND lv.sitecond IS NOT DISTINCT FROM p_sitecond AND lv.totalcostprodcut IS NOT DISTINCT FROM p_totalcostprodcut AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.targetspecies IS NOT DISTINCT FROM p_targetspecies - ORDER BY VERSION DESC LIMIT 1 - ) INTO v_changes_exist; - - -- If no changes, return false with current version - IF NOT v_changes_exist THEN - RETURN QUERY - SELECT - FALSE AS row_inserted, - (SELECT VERSION FROM fieldseeker.treatment - WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; - RETURN; - END IF; - - -- Calculate next version - SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version - FROM fieldseeker.treatment - WHERE objectid = p_objectid; - - -- Insert new version - INSERT INTO fieldseeker.treatment ( - objectid, - activity, treatarea, areaunit, product, qty, qtyunit, method, equiptype, comments, avetemp, windspeed, winddir, raingauge, startdatetime, enddatetime, insp_id, reviewed, reviewedby, revieweddate, locationname, zone, warningoverride, recordstatus, zone2, treatacres, tirecount, cbcount, containercount, globalid, treatmentlength, treatmenthours, treatmentlengthunits, linelocid, pointlocid, polygonlocid, srid, sdid, barrierrouteid, ulvrouteid, fieldtech, ptaid, flowrate, habitat, treathectares, invloc, temp_sitecond, sitecond, totalcostprodcut, creationdate, creator, editdate, editor, targetspecies, - VERSION - ) VALUES ( - p_objectid, - p_activity, p_treatarea, p_areaunit, p_product, p_qty, p_qtyunit, p_method, p_equiptype, p_comments, p_avetemp, p_windspeed, p_winddir, p_raingauge, p_startdatetime, p_enddatetime, p_insp_id, p_reviewed, p_reviewedby, p_revieweddate, p_locationname, p_zone, p_warningoverride, p_recordstatus, p_zone2, p_treatacres, p_tirecount, p_cbcount, p_containercount, p_globalid, p_treatmentlength, p_treatmenthours, p_treatmentlengthunits, p_linelocid, p_pointlocid, p_polygonlocid, p_srid, p_sdid, p_barrierrouteid, p_ulvrouteid, p_fieldtech, p_ptaid, p_flowrate, p_habitat, p_treathectares, p_invloc, p_temp_sitecond, p_sitecond, p_totalcostprodcut, p_creationdate, p_creator, p_editdate, p_editor, p_targetspecies, - v_next_version - ); - - -- Return success with new version - RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; -END; -$$ LANGUAGE plpgsql; --- +goose StatementEnd -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_treatmentarea( p_objectid bigint, - p_treat_id uuid,p_session_id uuid,p_treatdate timestamp,p_comments varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_notified smallint,p_type varchar,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_shape__area double precision,p_shape__length double precision + + p_treat_id uuid, + p_session_id uuid, + p_treatdate timestamp, + p_comments varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_notified smallint, + p_type varchar, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -1216,7 +4250,26 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.treatmentarea lv WHERE lv.objectid = p_objectid - AND lv.treat_id IS NOT DISTINCT FROM p_treat_id AND lv.session_id IS NOT DISTINCT FROM p_session_id AND lv.treatdate IS NOT DISTINCT FROM p_treatdate AND lv.comments IS NOT DISTINCT FROM p_comments AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.notified IS NOT DISTINCT FROM p_notified AND lv.type IS NOT DISTINCT FROM p_type AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.shape__area IS NOT DISTINCT FROM p_shape__area AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + + AND lv.treat_id IS NOT DISTINCT FROM p_treat_id + AND lv.session_id IS NOT DISTINCT FROM p_session_id + AND lv.treatdate IS NOT DISTINCT FROM p_treatdate + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.notified IS NOT DISTINCT FROM p_notified + AND lv.type IS NOT DISTINCT FROM p_type + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -1238,11 +4291,49 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.treatmentarea ( objectid, - treat_id, session_id, treatdate, comments, globalid, created_user, created_date, last_edited_user, last_edited_date, notified, type, creationdate, creator, editdate, editor, shape__area, shape__length, + + treat_id, + session_id, + treatdate, + comments, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + notified, + type, + creationdate, + creator, + editdate, + editor, + shape__area, + shape__length, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_treat_id, p_session_id, p_treatdate, p_comments, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_notified, p_type, p_creationdate, p_creator, p_editdate, p_editor, p_shape__area, p_shape__length, + + p_treat_id, + p_session_id, + p_treatdate, + p_comments, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_notified, + p_type, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, v_next_version ); @@ -1250,12 +4341,295 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + +-- +goose StatementBegin +CREATE OR REPLACE FUNCTION fieldseeker.insert_treatment( + p_objectid bigint, + + p_activity varchar, + p_treatarea double precision, + p_areaunit varchar, + p_product varchar, + p_qty double precision, + p_qtyunit varchar, + p_method varchar, + p_equiptype varchar, + p_comments varchar, + p_avetemp double precision, + p_windspeed double precision, + p_winddir varchar, + p_raingauge double precision, + p_startdatetime timestamp, + p_enddatetime timestamp, + p_insp_id uuid, + p_reviewed smallint, + p_reviewedby varchar, + p_revieweddate timestamp, + p_locationname varchar, + p_zone varchar, + p_warningoverride smallint, + p_recordstatus smallint, + p_zone2 varchar, + p_treatacres double precision, + p_tirecount smallint, + p_cbcount smallint, + p_containercount smallint, + p_globalid uuid, + p_treatmentlength double precision, + p_treatmenthours double precision, + p_treatmentlengthunits varchar, + p_linelocid uuid, + p_pointlocid uuid, + p_polygonlocid uuid, + p_srid uuid, + p_sdid uuid, + p_barrierrouteid uuid, + p_ulvrouteid uuid, + p_fieldtech varchar, + p_ptaid uuid, + p_flowrate double precision, + p_habitat varchar, + p_treathectares double precision, + p_invloc varchar, + p_temp_sitecond varchar, + p_sitecond varchar, + p_totalcostprodcut double precision, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_targetspecies varchar, + p_geometry jsonb, + p_geospatial geometry +) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ +DECLARE + v_next_version integer; + v_changes_exist boolean; +BEGIN + -- Check if changes exist + SELECT NOT EXISTS ( + SELECT 1 FROM fieldseeker.treatment lv + WHERE lv.objectid = p_objectid + + AND lv.activity IS NOT DISTINCT FROM p_activity + AND lv.treatarea IS NOT DISTINCT FROM p_treatarea + AND lv.areaunit IS NOT DISTINCT FROM p_areaunit + AND lv.product IS NOT DISTINCT FROM p_product + AND lv.qty IS NOT DISTINCT FROM p_qty + AND lv.qtyunit IS NOT DISTINCT FROM p_qtyunit + AND lv.method IS NOT DISTINCT FROM p_method + AND lv.equiptype IS NOT DISTINCT FROM p_equiptype + AND lv.comments IS NOT DISTINCT FROM p_comments + AND lv.avetemp IS NOT DISTINCT FROM p_avetemp + AND lv.windspeed IS NOT DISTINCT FROM p_windspeed + AND lv.winddir IS NOT DISTINCT FROM p_winddir + AND lv.raingauge IS NOT DISTINCT FROM p_raingauge + AND lv.startdatetime IS NOT DISTINCT FROM p_startdatetime + AND lv.enddatetime IS NOT DISTINCT FROM p_enddatetime + AND lv.insp_id IS NOT DISTINCT FROM p_insp_id + AND lv.reviewed IS NOT DISTINCT FROM p_reviewed + AND lv.reviewedby IS NOT DISTINCT FROM p_reviewedby + AND lv.revieweddate IS NOT DISTINCT FROM p_revieweddate + AND lv.locationname IS NOT DISTINCT FROM p_locationname + AND lv.zone IS NOT DISTINCT FROM p_zone + AND lv.warningoverride IS NOT DISTINCT FROM p_warningoverride + AND lv.recordstatus IS NOT DISTINCT FROM p_recordstatus + AND lv.zone2 IS NOT DISTINCT FROM p_zone2 + AND lv.treatacres IS NOT DISTINCT FROM p_treatacres + AND lv.tirecount IS NOT DISTINCT FROM p_tirecount + AND lv.cbcount IS NOT DISTINCT FROM p_cbcount + AND lv.containercount IS NOT DISTINCT FROM p_containercount + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.treatmentlength IS NOT DISTINCT FROM p_treatmentlength + AND lv.treatmenthours IS NOT DISTINCT FROM p_treatmenthours + AND lv.treatmentlengthunits IS NOT DISTINCT FROM p_treatmentlengthunits + AND lv.linelocid IS NOT DISTINCT FROM p_linelocid + AND lv.pointlocid IS NOT DISTINCT FROM p_pointlocid + AND lv.polygonlocid IS NOT DISTINCT FROM p_polygonlocid + AND lv.srid IS NOT DISTINCT FROM p_srid + AND lv.sdid IS NOT DISTINCT FROM p_sdid + AND lv.barrierrouteid IS NOT DISTINCT FROM p_barrierrouteid + AND lv.ulvrouteid IS NOT DISTINCT FROM p_ulvrouteid + AND lv.fieldtech IS NOT DISTINCT FROM p_fieldtech + AND lv.ptaid IS NOT DISTINCT FROM p_ptaid + AND lv.flowrate IS NOT DISTINCT FROM p_flowrate + AND lv.habitat IS NOT DISTINCT FROM p_habitat + AND lv.treathectares IS NOT DISTINCT FROM p_treathectares + AND lv.invloc IS NOT DISTINCT FROM p_invloc + AND lv.temp_sitecond IS NOT DISTINCT FROM p_temp_sitecond + AND lv.sitecond IS NOT DISTINCT FROM p_sitecond + AND lv.totalcostprodcut IS NOT DISTINCT FROM p_totalcostprodcut + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.targetspecies IS NOT DISTINCT FROM p_targetspecies + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial + ORDER BY VERSION DESC LIMIT 1 + ) INTO v_changes_exist; + + -- If no changes, return false with current version + IF NOT v_changes_exist THEN + RETURN QUERY + SELECT + FALSE AS row_inserted, + (SELECT VERSION FROM fieldseeker.treatment + WHERE objectid = p_objectid ORDER BY VERSION DESC LIMIT 1) AS version_num; + RETURN; + END IF; + + -- Calculate next version + SELECT COALESCE(MAX(VERSION) + 1, 1) INTO v_next_version + FROM fieldseeker.treatment + WHERE objectid = p_objectid; + + -- Insert new version + INSERT INTO fieldseeker.treatment ( + objectid, + + activity, + treatarea, + areaunit, + product, + qty, + qtyunit, + method, + equiptype, + comments, + avetemp, + windspeed, + winddir, + raingauge, + startdatetime, + enddatetime, + insp_id, + reviewed, + reviewedby, + revieweddate, + locationname, + zone, + warningoverride, + recordstatus, + zone2, + treatacres, + tirecount, + cbcount, + containercount, + globalid, + treatmentlength, + treatmenthours, + treatmentlengthunits, + linelocid, + pointlocid, + polygonlocid, + srid, + sdid, + barrierrouteid, + ulvrouteid, + fieldtech, + ptaid, + flowrate, + habitat, + treathectares, + invloc, + temp_sitecond, + sitecond, + totalcostprodcut, + creationdate, + creator, + editdate, + editor, + targetspecies, + geometry, + geospatial, + VERSION + ) VALUES ( + p_objectid, + + p_activity, + p_treatarea, + p_areaunit, + p_product, + p_qty, + p_qtyunit, + p_method, + p_equiptype, + p_comments, + p_avetemp, + p_windspeed, + p_winddir, + p_raingauge, + p_startdatetime, + p_enddatetime, + p_insp_id, + p_reviewed, + p_reviewedby, + p_revieweddate, + p_locationname, + p_zone, + p_warningoverride, + p_recordstatus, + p_zone2, + p_treatacres, + p_tirecount, + p_cbcount, + p_containercount, + p_globalid, + p_treatmentlength, + p_treatmenthours, + p_treatmentlengthunits, + p_linelocid, + p_pointlocid, + p_polygonlocid, + p_srid, + p_sdid, + p_barrierrouteid, + p_ulvrouteid, + p_fieldtech, + p_ptaid, + p_flowrate, + p_habitat, + p_treathectares, + p_invloc, + p_temp_sitecond, + p_sitecond, + p_totalcostprodcut, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_targetspecies, + p_geometry, + p_geospatial, + v_next_version + ); + + -- Return success with new version + RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; +END; +$$ LANGUAGE plpgsql; +-- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_zones2( p_objectid bigint, - p_name varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_shape__area double precision,p_shape__length double precision + + p_name varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -1265,7 +4639,21 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.zones2 lv WHERE lv.objectid = p_objectid - AND lv.name IS NOT DISTINCT FROM p_name AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.shape__area IS NOT DISTINCT FROM p_shape__area AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -1287,11 +4675,39 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.zones2 ( objectid, - name, globalid, created_user, created_date, last_edited_user, last_edited_date, creationdate, creator, editdate, editor, shape__area, shape__length, + + name, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + creationdate, + creator, + editdate, + editor, + shape__area, + shape__length, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_name, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_creationdate, p_creator, p_editdate, p_editor, p_shape__area, p_shape__length, + + p_name, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, v_next_version ); @@ -1299,12 +4715,27 @@ BEGIN RETURN QUERY SELECT TRUE AS row_inserted, v_next_version AS version_num; END; $$ LANGUAGE plpgsql; - -- +goose StatementEnd + -- +goose StatementBegin CREATE OR REPLACE FUNCTION fieldseeker.insert_zones( p_objectid bigint, - p_name varchar,p_globalid uuid,p_created_user varchar,p_created_date timestamp,p_last_edited_user varchar,p_last_edited_date timestamp,p_active integer,p_creationdate timestamp,p_creator varchar,p_editdate timestamp,p_editor varchar,p_shape__area double precision,p_shape__length double precision + + p_name varchar, + p_globalid uuid, + p_created_user varchar, + p_created_date timestamp, + p_last_edited_user varchar, + p_last_edited_date timestamp, + p_active integer, + p_creationdate timestamp, + p_creator varchar, + p_editdate timestamp, + p_editor varchar, + p_shape__area double precision, + p_shape__length double precision, + p_geometry jsonb, + p_geospatial geometry ) RETURNS TABLE(row_inserted boolean, version_num integer) AS $$ DECLARE v_next_version integer; @@ -1314,7 +4745,22 @@ BEGIN SELECT NOT EXISTS ( SELECT 1 FROM fieldseeker.zones lv WHERE lv.objectid = p_objectid - AND lv.name IS NOT DISTINCT FROM p_name AND lv.globalid IS NOT DISTINCT FROM p_globalid AND lv.created_user IS NOT DISTINCT FROM p_created_user AND lv.created_date IS NOT DISTINCT FROM p_created_date AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date AND lv.active IS NOT DISTINCT FROM p_active AND lv.creationdate IS NOT DISTINCT FROM p_creationdate AND lv.creator IS NOT DISTINCT FROM p_creator AND lv.editdate IS NOT DISTINCT FROM p_editdate AND lv.editor IS NOT DISTINCT FROM p_editor AND lv.shape__area IS NOT DISTINCT FROM p_shape__area AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + + AND lv.name IS NOT DISTINCT FROM p_name + AND lv.globalid IS NOT DISTINCT FROM p_globalid + AND lv.created_user IS NOT DISTINCT FROM p_created_user + AND lv.created_date IS NOT DISTINCT FROM p_created_date + AND lv.last_edited_user IS NOT DISTINCT FROM p_last_edited_user + AND lv.last_edited_date IS NOT DISTINCT FROM p_last_edited_date + AND lv.active IS NOT DISTINCT FROM p_active + AND lv.creationdate IS NOT DISTINCT FROM p_creationdate + AND lv.creator IS NOT DISTINCT FROM p_creator + AND lv.editdate IS NOT DISTINCT FROM p_editdate + AND lv.editor IS NOT DISTINCT FROM p_editor + AND lv.shape__area IS NOT DISTINCT FROM p_shape__area + AND lv.shape__length IS NOT DISTINCT FROM p_shape__length + AND lv.geometry IS NOT DISTINCT FROM p_geometry + AND lv.geospatial IS NOT DISTINCT FROM p_geospatial ORDER BY VERSION DESC LIMIT 1 ) INTO v_changes_exist; @@ -1336,11 +4782,41 @@ BEGIN -- Insert new version INSERT INTO fieldseeker.zones ( objectid, - name, globalid, created_user, created_date, last_edited_user, last_edited_date, active, creationdate, creator, editdate, editor, shape__area, shape__length, + + name, + globalid, + created_user, + created_date, + last_edited_user, + last_edited_date, + active, + creationdate, + creator, + editdate, + editor, + shape__area, + shape__length, + geometry, + geospatial, VERSION ) VALUES ( p_objectid, - p_name, p_globalid, p_created_user, p_created_date, p_last_edited_user, p_last_edited_date, p_active, p_creationdate, p_creator, p_editdate, p_editor, p_shape__area, p_shape__length, + + p_name, + p_globalid, + p_created_user, + p_created_date, + p_last_edited_user, + p_last_edited_date, + p_active, + p_creationdate, + p_creator, + p_editdate, + p_editor, + p_shape__area, + p_shape__length, + p_geometry, + p_geospatial, v_next_version ); @@ -1377,3 +4853,5 @@ DROP FUNCTION fieldseeker.insert_treatment; DROP FUNCTION fieldseeker.insert_treatmentarea; DROP FUNCTION fieldseeker.insert_zones2; DROP FUNCTION fieldseeker.insert_zones; + + diff --git a/db/models/bob_joins.bob.go b/db/models/bob_joins.bob.go index dc751bdf..d6a5fdd0 100644 --- a/db/models/bob_joins.bob.go +++ b/db/models/bob_joins.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -32,7 +32,6 @@ func (j joinSet[Q]) AliasedAs(alias string) joinSet[Q] { } type joins[Q dialect.Joinable] struct { - FieldseekerRodentlocations joinSet[fieldseekerRodentlocationJoins[Q]] FieldseekerSyncs joinSet[fieldseekerSyncJoins[Q]] FSContainerrelates joinSet[fsContainerrelateJoins[Q]] FSFieldscoutinglogs joinSet[fsFieldscoutinglogJoins[Q]] @@ -105,7 +104,6 @@ func buildJoinSet[Q interface{ aliasedAs(string) Q }, C any, F func(C, string) Q func getJoins[Q dialect.Joinable]() joins[Q] { return joins[Q]{ - FieldseekerRodentlocations: buildJoinSet[fieldseekerRodentlocationJoins[Q]](FieldseekerRodentlocations.Columns, buildFieldseekerRodentlocationJoins), FieldseekerSyncs: buildJoinSet[fieldseekerSyncJoins[Q]](FieldseekerSyncs.Columns, buildFieldseekerSyncJoins), FSContainerrelates: buildJoinSet[fsContainerrelateJoins[Q]](FSContainerrelates.Columns, buildFSContainerrelateJoins), FSFieldscoutinglogs: buildJoinSet[fsFieldscoutinglogJoins[Q]](FSFieldscoutinglogs.Columns, buildFSFieldscoutinglogJoins), diff --git a/db/models/bob_loaders.bob.go b/db/models/bob_loaders.bob.go index b35690dc..2fe41202 100644 --- a/db/models/bob_loaders.bob.go +++ b/db/models/bob_loaders.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -17,7 +17,6 @@ import ( var Preload = getPreloaders() type preloaders struct { - FieldseekerRodentlocation fieldseekerRodentlocationPreloader FieldseekerSync fieldseekerSyncPreloader FSContainerrelate fsContainerrelatePreloader FSFieldscoutinglog fsFieldscoutinglogPreloader @@ -82,7 +81,6 @@ type preloaders struct { func getPreloaders() preloaders { return preloaders{ - FieldseekerRodentlocation: buildFieldseekerRodentlocationPreloader(), FieldseekerSync: buildFieldseekerSyncPreloader(), FSContainerrelate: buildFSContainerrelatePreloader(), FSFieldscoutinglog: buildFSFieldscoutinglogPreloader(), @@ -153,7 +151,6 @@ var ( ) type thenLoaders[Q orm.Loadable] struct { - FieldseekerRodentlocation fieldseekerRodentlocationThenLoader[Q] FieldseekerSync fieldseekerSyncThenLoader[Q] FSContainerrelate fsContainerrelateThenLoader[Q] FSFieldscoutinglog fsFieldscoutinglogThenLoader[Q] @@ -218,7 +215,6 @@ type thenLoaders[Q orm.Loadable] struct { func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] { return thenLoaders[Q]{ - FieldseekerRodentlocation: buildFieldseekerRodentlocationThenLoader[Q](), FieldseekerSync: buildFieldseekerSyncThenLoader[Q](), FSContainerrelate: buildFSContainerrelateThenLoader[Q](), FSFieldscoutinglog: buildFSFieldscoutinglogThenLoader[Q](), diff --git a/db/models/bob_types.bob_test.go b/db/models/bob_types.bob_test.go index 142533a6..2d097340 100644 --- a/db/models/bob_types.bob_test.go +++ b/db/models/bob_types.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -16,18 +16,6 @@ import ( // Set the testDB to enable tests that use the database var testDB bob.Transactor[bob.Tx] -// Make sure the type FieldseekerAerialsprayline runs hooks after queries -var _ bob.HookableType = &FieldseekerAerialsprayline{} - -// Make sure the type FieldseekerAerialspraysession runs hooks after queries -var _ bob.HookableType = &FieldseekerAerialspraysession{} - -// Make sure the type FieldseekerBarrierspray runs hooks after queries -var _ bob.HookableType = &FieldseekerBarrierspray{} - -// Make sure the type FieldseekerBarriersprayroute runs hooks after queries -var _ bob.HookableType = &FieldseekerBarriersprayroute{} - // Make sure the type FieldseekerContainerrelate runs hooks after queries var _ bob.HookableType = &FieldseekerContainerrelate{} @@ -43,12 +31,6 @@ var _ bob.HookableType = &FieldseekerInspectionsample{} // Make sure the type FieldseekerInspectionsampledetail runs hooks after queries var _ bob.HookableType = &FieldseekerInspectionsampledetail{} -// Make sure the type FieldseekerLandingcount runs hooks after queries -var _ bob.HookableType = &FieldseekerLandingcount{} - -// Make sure the type FieldseekerLandingcountlocation runs hooks after queries -var _ bob.HookableType = &FieldseekerLandingcountlocation{} - // Make sure the type FieldseekerLinelocation runs hooks after queries var _ bob.HookableType = &FieldseekerLinelocation{} @@ -67,30 +49,15 @@ var _ bob.HookableType = &FieldseekerPolygonlocation{} // Make sure the type FieldseekerPool runs hooks after queries var _ bob.HookableType = &FieldseekerPool{} -// Make sure the type FieldseekerPoolbuffer runs hooks after queries -var _ bob.HookableType = &FieldseekerPoolbuffer{} - // Make sure the type FieldseekerPooldetail runs hooks after queries var _ bob.HookableType = &FieldseekerPooldetail{} // Make sure the type FieldseekerProposedtreatmentarea runs hooks after queries var _ bob.HookableType = &FieldseekerProposedtreatmentarea{} -// Make sure the type FieldseekerQalarvcount runs hooks after queries -var _ bob.HookableType = &FieldseekerQalarvcount{} - // Make sure the type FieldseekerQamosquitoinspection runs hooks after queries var _ bob.HookableType = &FieldseekerQamosquitoinspection{} -// Make sure the type FieldseekerQaproductobservation runs hooks after queries -var _ bob.HookableType = &FieldseekerQaproductobservation{} - -// Make sure the type FieldseekerRestrictedarea runs hooks after queries -var _ bob.HookableType = &FieldseekerRestrictedarea{} - -// Make sure the type FieldseekerRodentinspection runs hooks after queries -var _ bob.HookableType = &FieldseekerRodentinspection{} - // Make sure the type FieldseekerRodentlocation runs hooks after queries var _ bob.HookableType = &FieldseekerRodentlocation{} @@ -112,9 +79,6 @@ var _ bob.HookableType = &FieldseekerStormdrain{} // Make sure the type FieldseekerTimecard runs hooks after queries var _ bob.HookableType = &FieldseekerTimecard{} -// Make sure the type FieldseekerTracklog runs hooks after queries -var _ bob.HookableType = &FieldseekerTracklog{} - // Make sure the type FieldseekerTrapdatum runs hooks after queries var _ bob.HookableType = &FieldseekerTrapdatum{} @@ -127,9 +91,6 @@ var _ bob.HookableType = &FieldseekerTreatment{} // Make sure the type FieldseekerTreatmentarea runs hooks after queries var _ bob.HookableType = &FieldseekerTreatmentarea{} -// Make sure the type FieldseekerUlvsprayroute runs hooks after queries -var _ bob.HookableType = &FieldseekerUlvsprayroute{} - // Make sure the type FieldseekerZone runs hooks after queries var _ bob.HookableType = &FieldseekerZone{} diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go index 4517994d..888a7988 100644 --- a/db/models/bob_where.bob.go +++ b/db/models/bob_where.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -17,31 +17,20 @@ var ( ) func Where[Q psql.Filterable]() struct { - FieldseekerAerialspraylines fieldseekerAerialspraylineWhere[Q] - FieldseekerAerialspraysessions fieldseekerAerialspraysessionWhere[Q] - FieldseekerBarriersprays fieldseekerBarriersprayWhere[Q] - FieldseekerBarriersprayroutes fieldseekerBarriersprayrouteWhere[Q] FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q] FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q] FieldseekerHabitatrelates fieldseekerHabitatrelateWhere[Q] FieldseekerInspectionsamples fieldseekerInspectionsampleWhere[Q] FieldseekerInspectionsampledetails fieldseekerInspectionsampledetailWhere[Q] - FieldseekerLandingcounts fieldseekerLandingcountWhere[Q] - FieldseekerLandingcountlocations fieldseekerLandingcountlocationWhere[Q] FieldseekerLinelocations fieldseekerLinelocationWhere[Q] FieldseekerLocationtrackings fieldseekerLocationtrackingWhere[Q] FieldseekerMosquitoinspections fieldseekerMosquitoinspectionWhere[Q] FieldseekerPointlocations fieldseekerPointlocationWhere[Q] FieldseekerPolygonlocations fieldseekerPolygonlocationWhere[Q] FieldseekerPools fieldseekerPoolWhere[Q] - FieldseekerPoolbuffers fieldseekerPoolbufferWhere[Q] FieldseekerPooldetails fieldseekerPooldetailWhere[Q] FieldseekerProposedtreatmentareas fieldseekerProposedtreatmentareaWhere[Q] - FieldseekerQalarvcounts fieldseekerQalarvcountWhere[Q] FieldseekerQamosquitoinspections fieldseekerQamosquitoinspectionWhere[Q] - FieldseekerQaproductobservations fieldseekerQaproductobservationWhere[Q] - FieldseekerRestrictedareas fieldseekerRestrictedareaWhere[Q] - FieldseekerRodentinspections fieldseekerRodentinspectionWhere[Q] FieldseekerRodentlocations fieldseekerRodentlocationWhere[Q] FieldseekerSamplecollections fieldseekerSamplecollectionWhere[Q] FieldseekerSamplelocations fieldseekerSamplelocationWhere[Q] @@ -49,12 +38,10 @@ func Where[Q psql.Filterable]() struct { FieldseekerSpeciesabundances fieldseekerSpeciesabundanceWhere[Q] FieldseekerStormdrains fieldseekerStormdrainWhere[Q] FieldseekerTimecards fieldseekerTimecardWhere[Q] - FieldseekerTracklogs fieldseekerTracklogWhere[Q] FieldseekerTrapdata fieldseekerTrapdatumWhere[Q] FieldseekerTraplocations fieldseekerTraplocationWhere[Q] FieldseekerTreatments fieldseekerTreatmentWhere[Q] FieldseekerTreatmentareas fieldseekerTreatmentareaWhere[Q] - FieldseekerUlvsprayroutes fieldseekerUlvsprayrouteWhere[Q] FieldseekerZones fieldseekerZoneWhere[Q] FieldseekerZones2s fieldseekerZones2Where[Q] FieldseekerSyncs fieldseekerSyncWhere[Q] @@ -126,31 +113,20 @@ func Where[Q psql.Filterable]() struct { Users userWhere[Q] } { return struct { - FieldseekerAerialspraylines fieldseekerAerialspraylineWhere[Q] - FieldseekerAerialspraysessions fieldseekerAerialspraysessionWhere[Q] - FieldseekerBarriersprays fieldseekerBarriersprayWhere[Q] - FieldseekerBarriersprayroutes fieldseekerBarriersprayrouteWhere[Q] FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q] FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q] FieldseekerHabitatrelates fieldseekerHabitatrelateWhere[Q] FieldseekerInspectionsamples fieldseekerInspectionsampleWhere[Q] FieldseekerInspectionsampledetails fieldseekerInspectionsampledetailWhere[Q] - FieldseekerLandingcounts fieldseekerLandingcountWhere[Q] - FieldseekerLandingcountlocations fieldseekerLandingcountlocationWhere[Q] FieldseekerLinelocations fieldseekerLinelocationWhere[Q] FieldseekerLocationtrackings fieldseekerLocationtrackingWhere[Q] FieldseekerMosquitoinspections fieldseekerMosquitoinspectionWhere[Q] FieldseekerPointlocations fieldseekerPointlocationWhere[Q] FieldseekerPolygonlocations fieldseekerPolygonlocationWhere[Q] FieldseekerPools fieldseekerPoolWhere[Q] - FieldseekerPoolbuffers fieldseekerPoolbufferWhere[Q] FieldseekerPooldetails fieldseekerPooldetailWhere[Q] FieldseekerProposedtreatmentareas fieldseekerProposedtreatmentareaWhere[Q] - FieldseekerQalarvcounts fieldseekerQalarvcountWhere[Q] FieldseekerQamosquitoinspections fieldseekerQamosquitoinspectionWhere[Q] - FieldseekerQaproductobservations fieldseekerQaproductobservationWhere[Q] - FieldseekerRestrictedareas fieldseekerRestrictedareaWhere[Q] - FieldseekerRodentinspections fieldseekerRodentinspectionWhere[Q] FieldseekerRodentlocations fieldseekerRodentlocationWhere[Q] FieldseekerSamplecollections fieldseekerSamplecollectionWhere[Q] FieldseekerSamplelocations fieldseekerSamplelocationWhere[Q] @@ -158,12 +134,10 @@ func Where[Q psql.Filterable]() struct { FieldseekerSpeciesabundances fieldseekerSpeciesabundanceWhere[Q] FieldseekerStormdrains fieldseekerStormdrainWhere[Q] FieldseekerTimecards fieldseekerTimecardWhere[Q] - FieldseekerTracklogs fieldseekerTracklogWhere[Q] FieldseekerTrapdata fieldseekerTrapdatumWhere[Q] FieldseekerTraplocations fieldseekerTraplocationWhere[Q] FieldseekerTreatments fieldseekerTreatmentWhere[Q] FieldseekerTreatmentareas fieldseekerTreatmentareaWhere[Q] - FieldseekerUlvsprayroutes fieldseekerUlvsprayrouteWhere[Q] FieldseekerZones fieldseekerZoneWhere[Q] FieldseekerZones2s fieldseekerZones2Where[Q] FieldseekerSyncs fieldseekerSyncWhere[Q] @@ -234,31 +208,20 @@ func Where[Q psql.Filterable]() struct { SpatialRefSys spatialRefSyWhere[Q] Users userWhere[Q] }{ - FieldseekerAerialspraylines: buildFieldseekerAerialspraylineWhere[Q](FieldseekerAerialspraylines.Columns), - FieldseekerAerialspraysessions: buildFieldseekerAerialspraysessionWhere[Q](FieldseekerAerialspraysessions.Columns), - FieldseekerBarriersprays: buildFieldseekerBarriersprayWhere[Q](FieldseekerBarriersprays.Columns), - FieldseekerBarriersprayroutes: buildFieldseekerBarriersprayrouteWhere[Q](FieldseekerBarriersprayroutes.Columns), FieldseekerContainerrelates: buildFieldseekerContainerrelateWhere[Q](FieldseekerContainerrelates.Columns), FieldseekerFieldscoutinglogs: buildFieldseekerFieldscoutinglogWhere[Q](FieldseekerFieldscoutinglogs.Columns), FieldseekerHabitatrelates: buildFieldseekerHabitatrelateWhere[Q](FieldseekerHabitatrelates.Columns), FieldseekerInspectionsamples: buildFieldseekerInspectionsampleWhere[Q](FieldseekerInspectionsamples.Columns), FieldseekerInspectionsampledetails: buildFieldseekerInspectionsampledetailWhere[Q](FieldseekerInspectionsampledetails.Columns), - FieldseekerLandingcounts: buildFieldseekerLandingcountWhere[Q](FieldseekerLandingcounts.Columns), - FieldseekerLandingcountlocations: buildFieldseekerLandingcountlocationWhere[Q](FieldseekerLandingcountlocations.Columns), FieldseekerLinelocations: buildFieldseekerLinelocationWhere[Q](FieldseekerLinelocations.Columns), FieldseekerLocationtrackings: buildFieldseekerLocationtrackingWhere[Q](FieldseekerLocationtrackings.Columns), FieldseekerMosquitoinspections: buildFieldseekerMosquitoinspectionWhere[Q](FieldseekerMosquitoinspections.Columns), FieldseekerPointlocations: buildFieldseekerPointlocationWhere[Q](FieldseekerPointlocations.Columns), FieldseekerPolygonlocations: buildFieldseekerPolygonlocationWhere[Q](FieldseekerPolygonlocations.Columns), FieldseekerPools: buildFieldseekerPoolWhere[Q](FieldseekerPools.Columns), - FieldseekerPoolbuffers: buildFieldseekerPoolbufferWhere[Q](FieldseekerPoolbuffers.Columns), FieldseekerPooldetails: buildFieldseekerPooldetailWhere[Q](FieldseekerPooldetails.Columns), FieldseekerProposedtreatmentareas: buildFieldseekerProposedtreatmentareaWhere[Q](FieldseekerProposedtreatmentareas.Columns), - FieldseekerQalarvcounts: buildFieldseekerQalarvcountWhere[Q](FieldseekerQalarvcounts.Columns), FieldseekerQamosquitoinspections: buildFieldseekerQamosquitoinspectionWhere[Q](FieldseekerQamosquitoinspections.Columns), - FieldseekerQaproductobservations: buildFieldseekerQaproductobservationWhere[Q](FieldseekerQaproductobservations.Columns), - FieldseekerRestrictedareas: buildFieldseekerRestrictedareaWhere[Q](FieldseekerRestrictedareas.Columns), - FieldseekerRodentinspections: buildFieldseekerRodentinspectionWhere[Q](FieldseekerRodentinspections.Columns), FieldseekerRodentlocations: buildFieldseekerRodentlocationWhere[Q](FieldseekerRodentlocations.Columns), FieldseekerSamplecollections: buildFieldseekerSamplecollectionWhere[Q](FieldseekerSamplecollections.Columns), FieldseekerSamplelocations: buildFieldseekerSamplelocationWhere[Q](FieldseekerSamplelocations.Columns), @@ -266,12 +229,10 @@ func Where[Q psql.Filterable]() struct { FieldseekerSpeciesabundances: buildFieldseekerSpeciesabundanceWhere[Q](FieldseekerSpeciesabundances.Columns), FieldseekerStormdrains: buildFieldseekerStormdrainWhere[Q](FieldseekerStormdrains.Columns), FieldseekerTimecards: buildFieldseekerTimecardWhere[Q](FieldseekerTimecards.Columns), - FieldseekerTracklogs: buildFieldseekerTracklogWhere[Q](FieldseekerTracklogs.Columns), FieldseekerTrapdata: buildFieldseekerTrapdatumWhere[Q](FieldseekerTrapdata.Columns), FieldseekerTraplocations: buildFieldseekerTraplocationWhere[Q](FieldseekerTraplocations.Columns), FieldseekerTreatments: buildFieldseekerTreatmentWhere[Q](FieldseekerTreatments.Columns), FieldseekerTreatmentareas: buildFieldseekerTreatmentareaWhere[Q](FieldseekerTreatmentareas.Columns), - FieldseekerUlvsprayroutes: buildFieldseekerUlvsprayrouteWhere[Q](FieldseekerUlvsprayroutes.Columns), FieldseekerZones: buildFieldseekerZoneWhere[Q](FieldseekerZones.Columns), FieldseekerZones2s: buildFieldseekerZones2Where[Q](FieldseekerZones2s.Columns), FieldseekerSyncs: buildFieldseekerSyncWhere[Q](FieldseekerSyncs.Columns), diff --git a/db/models/fieldseeker.aerialsprayline.bob.go b/db/models/fieldseeker.aerialsprayline.bob.go deleted file mode 100644 index bb7b402d..00000000 --- a/db/models/fieldseeker.aerialsprayline.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerAerialsprayline is an object representing the database table. -type FieldseekerAerialsprayline struct{} - -// FieldseekerAerialspraylineSlice is an alias for a slice of pointers to FieldseekerAerialsprayline. -// This should almost always be used instead of []*FieldseekerAerialsprayline. -type FieldseekerAerialspraylineSlice []*FieldseekerAerialsprayline - -// FieldseekerAerialspraylines contains methods to work with the aerialsprayline view -var FieldseekerAerialspraylines = psql.NewViewx[*FieldseekerAerialsprayline, FieldseekerAerialspraylineSlice]("fieldseeker", "aerialsprayline", buildFieldseekerAerialspraylineColumns("fieldseeker.aerialsprayline")) - -// FieldseekerAerialspraylinesQuery is a query on the aerialsprayline view -type FieldseekerAerialspraylinesQuery = *psql.ViewQuery[*FieldseekerAerialsprayline, FieldseekerAerialspraylineSlice] - -func buildFieldseekerAerialspraylineColumns(alias string) fieldseekerAerialspraylineColumns { - return fieldseekerAerialspraylineColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.aerialsprayline"), - tableAlias: alias, - } -} - -type fieldseekerAerialspraylineColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerAerialspraylineColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerAerialspraylineColumns) AliasedAs(alias string) fieldseekerAerialspraylineColumns { - return buildFieldseekerAerialspraylineColumns(alias) -} - -// AfterQueryHook is called after FieldseekerAerialsprayline is retrieved from the database -func (o *FieldseekerAerialsprayline) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerAerialspraylines.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerAerialspraylineSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerAerialspraylineSlice is retrieved from the database -func (o FieldseekerAerialspraylineSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerAerialspraylines.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerAerialspraylineWhere[Q psql.Filterable] struct{} - -func (fieldseekerAerialspraylineWhere[Q]) AliasedAs(alias string) fieldseekerAerialspraylineWhere[Q] { - return buildFieldseekerAerialspraylineWhere[Q](buildFieldseekerAerialspraylineColumns(alias)) -} - -func buildFieldseekerAerialspraylineWhere[Q psql.Filterable](cols fieldseekerAerialspraylineColumns) fieldseekerAerialspraylineWhere[Q] { - return fieldseekerAerialspraylineWhere[Q]{} -} diff --git a/db/models/fieldseeker.aerialspraysession.bob.go b/db/models/fieldseeker.aerialspraysession.bob.go deleted file mode 100644 index 54dcc805..00000000 --- a/db/models/fieldseeker.aerialspraysession.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerAerialspraysession is an object representing the database table. -type FieldseekerAerialspraysession struct{} - -// FieldseekerAerialspraysessionSlice is an alias for a slice of pointers to FieldseekerAerialspraysession. -// This should almost always be used instead of []*FieldseekerAerialspraysession. -type FieldseekerAerialspraysessionSlice []*FieldseekerAerialspraysession - -// FieldseekerAerialspraysessions contains methods to work with the aerialspraysession view -var FieldseekerAerialspraysessions = psql.NewViewx[*FieldseekerAerialspraysession, FieldseekerAerialspraysessionSlice]("fieldseeker", "aerialspraysession", buildFieldseekerAerialspraysessionColumns("fieldseeker.aerialspraysession")) - -// FieldseekerAerialspraysessionsQuery is a query on the aerialspraysession view -type FieldseekerAerialspraysessionsQuery = *psql.ViewQuery[*FieldseekerAerialspraysession, FieldseekerAerialspraysessionSlice] - -func buildFieldseekerAerialspraysessionColumns(alias string) fieldseekerAerialspraysessionColumns { - return fieldseekerAerialspraysessionColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.aerialspraysession"), - tableAlias: alias, - } -} - -type fieldseekerAerialspraysessionColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerAerialspraysessionColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerAerialspraysessionColumns) AliasedAs(alias string) fieldseekerAerialspraysessionColumns { - return buildFieldseekerAerialspraysessionColumns(alias) -} - -// AfterQueryHook is called after FieldseekerAerialspraysession is retrieved from the database -func (o *FieldseekerAerialspraysession) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerAerialspraysessions.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerAerialspraysessionSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerAerialspraysessionSlice is retrieved from the database -func (o FieldseekerAerialspraysessionSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerAerialspraysessions.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerAerialspraysessionWhere[Q psql.Filterable] struct{} - -func (fieldseekerAerialspraysessionWhere[Q]) AliasedAs(alias string) fieldseekerAerialspraysessionWhere[Q] { - return buildFieldseekerAerialspraysessionWhere[Q](buildFieldseekerAerialspraysessionColumns(alias)) -} - -func buildFieldseekerAerialspraysessionWhere[Q psql.Filterable](cols fieldseekerAerialspraysessionColumns) fieldseekerAerialspraysessionWhere[Q] { - return fieldseekerAerialspraysessionWhere[Q]{} -} diff --git a/db/models/fieldseeker.barrierspray.bob.go b/db/models/fieldseeker.barrierspray.bob.go deleted file mode 100644 index c4f56130..00000000 --- a/db/models/fieldseeker.barrierspray.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerBarrierspray is an object representing the database table. -type FieldseekerBarrierspray struct{} - -// FieldseekerBarrierspraySlice is an alias for a slice of pointers to FieldseekerBarrierspray. -// This should almost always be used instead of []*FieldseekerBarrierspray. -type FieldseekerBarrierspraySlice []*FieldseekerBarrierspray - -// FieldseekerBarriersprays contains methods to work with the barrierspray view -var FieldseekerBarriersprays = psql.NewViewx[*FieldseekerBarrierspray, FieldseekerBarrierspraySlice]("fieldseeker", "barrierspray", buildFieldseekerBarriersprayColumns("fieldseeker.barrierspray")) - -// FieldseekerBarrierspraysQuery is a query on the barrierspray view -type FieldseekerBarrierspraysQuery = *psql.ViewQuery[*FieldseekerBarrierspray, FieldseekerBarrierspraySlice] - -func buildFieldseekerBarriersprayColumns(alias string) fieldseekerBarriersprayColumns { - return fieldseekerBarriersprayColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.barrierspray"), - tableAlias: alias, - } -} - -type fieldseekerBarriersprayColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerBarriersprayColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerBarriersprayColumns) AliasedAs(alias string) fieldseekerBarriersprayColumns { - return buildFieldseekerBarriersprayColumns(alias) -} - -// AfterQueryHook is called after FieldseekerBarrierspray is retrieved from the database -func (o *FieldseekerBarrierspray) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerBarriersprays.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerBarrierspraySlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerBarrierspraySlice is retrieved from the database -func (o FieldseekerBarrierspraySlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerBarriersprays.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerBarriersprayWhere[Q psql.Filterable] struct{} - -func (fieldseekerBarriersprayWhere[Q]) AliasedAs(alias string) fieldseekerBarriersprayWhere[Q] { - return buildFieldseekerBarriersprayWhere[Q](buildFieldseekerBarriersprayColumns(alias)) -} - -func buildFieldseekerBarriersprayWhere[Q psql.Filterable](cols fieldseekerBarriersprayColumns) fieldseekerBarriersprayWhere[Q] { - return fieldseekerBarriersprayWhere[Q]{} -} diff --git a/db/models/fieldseeker.barriersprayroute.bob.go b/db/models/fieldseeker.barriersprayroute.bob.go deleted file mode 100644 index 9d2806a0..00000000 --- a/db/models/fieldseeker.barriersprayroute.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerBarriersprayroute is an object representing the database table. -type FieldseekerBarriersprayroute struct{} - -// FieldseekerBarriersprayrouteSlice is an alias for a slice of pointers to FieldseekerBarriersprayroute. -// This should almost always be used instead of []*FieldseekerBarriersprayroute. -type FieldseekerBarriersprayrouteSlice []*FieldseekerBarriersprayroute - -// FieldseekerBarriersprayroutes contains methods to work with the barriersprayroute view -var FieldseekerBarriersprayroutes = psql.NewViewx[*FieldseekerBarriersprayroute, FieldseekerBarriersprayrouteSlice]("fieldseeker", "barriersprayroute", buildFieldseekerBarriersprayrouteColumns("fieldseeker.barriersprayroute")) - -// FieldseekerBarriersprayroutesQuery is a query on the barriersprayroute view -type FieldseekerBarriersprayroutesQuery = *psql.ViewQuery[*FieldseekerBarriersprayroute, FieldseekerBarriersprayrouteSlice] - -func buildFieldseekerBarriersprayrouteColumns(alias string) fieldseekerBarriersprayrouteColumns { - return fieldseekerBarriersprayrouteColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.barriersprayroute"), - tableAlias: alias, - } -} - -type fieldseekerBarriersprayrouteColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerBarriersprayrouteColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerBarriersprayrouteColumns) AliasedAs(alias string) fieldseekerBarriersprayrouteColumns { - return buildFieldseekerBarriersprayrouteColumns(alias) -} - -// AfterQueryHook is called after FieldseekerBarriersprayroute is retrieved from the database -func (o *FieldseekerBarriersprayroute) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerBarriersprayroutes.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerBarriersprayrouteSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerBarriersprayrouteSlice is retrieved from the database -func (o FieldseekerBarriersprayrouteSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerBarriersprayroutes.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerBarriersprayrouteWhere[Q psql.Filterable] struct{} - -func (fieldseekerBarriersprayrouteWhere[Q]) AliasedAs(alias string) fieldseekerBarriersprayrouteWhere[Q] { - return buildFieldseekerBarriersprayrouteWhere[Q](buildFieldseekerBarriersprayrouteColumns(alias)) -} - -func buildFieldseekerBarriersprayrouteWhere[Q psql.Filterable](cols fieldseekerBarriersprayrouteColumns) fieldseekerBarriersprayrouteWhere[Q] { - return fieldseekerBarriersprayrouteWhere[Q]{} -} diff --git a/db/models/fieldseeker.containerrelate.bob.go b/db/models/fieldseeker.containerrelate.bob.go index 715e1bb9..dab4cec1 100644 --- a/db/models/fieldseeker.containerrelate.bob.go +++ b/db/models/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -39,6 +39,8 @@ type FieldseekerContainerrelate struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerContainerrelateSlice is an alias for a slice of pointers to FieldseekerContainerrelate. @@ -54,7 +56,7 @@ type FieldseekerContainerrelatesQuery = *psql.ViewQuery[*FieldseekerContainerrel func buildFieldseekerContainerrelateColumns(alias string) fieldseekerContainerrelateColumns { return fieldseekerContainerrelateColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "inspsampleid", "mosquitoinspid", "treatmentid", "containertype", "creationdate", "creator", "editdate", "editor", + "objectid", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "inspsampleid", "mosquitoinspid", "treatmentid", "containertype", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.containerrelate"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -71,6 +73,7 @@ func buildFieldseekerContainerrelateColumns(alias string) fieldseekerContainerre Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -91,6 +94,7 @@ type fieldseekerContainerrelateColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerContainerrelateColumns) Alias() string { @@ -119,10 +123,11 @@ type FieldseekerContainerrelateSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerContainerrelateSetter) SetColumns() []string { - vals := make([]string, 0, 14) + vals := make([]string, 0, 15) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -165,6 +170,9 @@ func (s FieldseekerContainerrelateSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -211,6 +219,9 @@ func (s FieldseekerContainerrelateSetter) Overwrite(t *FieldseekerContainerrelat if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerContainerrelateSetter) Apply(q *dialect.InsertQuery) { @@ -219,7 +230,7 @@ func (s *FieldseekerContainerrelateSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 14) + vals := make([]bob.Expression, 15) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -304,6 +315,12 @@ func (s *FieldseekerContainerrelateSetter) Apply(q *dialect.InsertQuery) { vals[13] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[14] = psql.Arg(s.Version.MustGet()) + } else { + vals[14] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -313,7 +330,7 @@ func (s FieldseekerContainerrelateSetter) UpdateMod() bob.Mod[*dialect.UpdateQue } func (s FieldseekerContainerrelateSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 14) + exprs := make([]bob.Expression, 0, 15) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -413,28 +430,38 @@ func (s FieldseekerContainerrelateSetter) Expressions(prefix ...string) []bob.Ex }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerContainerrelate retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerContainerrelate(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerContainerrelate, error) { +func FindFieldseekerContainerrelate(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerContainerrelate, error) { if len(cols) == 0 { return FieldseekerContainerrelates.Query( sm.Where(FieldseekerContainerrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerContainerrelates.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerContainerrelates.Query( sm.Where(FieldseekerContainerrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerContainerrelates.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerContainerrelates.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerContainerrelateExists checks the presence of a single record by primary key -func FieldseekerContainerrelateExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerContainerrelateExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerContainerrelates.Query( sm.Where(FieldseekerContainerrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerContainerrelates.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -458,11 +485,14 @@ func (o *FieldseekerContainerrelate) AfterQueryHook(ctx context.Context, exec bo // primaryKeyVals returns the primary key values of the FieldseekerContainerrelate func (o *FieldseekerContainerrelate) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerContainerrelate) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.containerrelate", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.containerrelate", "objectid"), psql.Quote("fieldseeker.containerrelate", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -489,6 +519,7 @@ func (o *FieldseekerContainerrelate) Delete(ctx context.Context, exec bob.Execut func (o *FieldseekerContainerrelate) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerContainerrelates.Query( sm.Where(FieldseekerContainerrelates.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerContainerrelates.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -522,7 +553,7 @@ func (o FieldseekerContainerrelateSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.containerrelate", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.containerrelate", "objectid"), psql.Quote("fieldseeker.containerrelate", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -540,6 +571,9 @@ func (o FieldseekerContainerrelateSlice) copyMatchingRows(from ...*FieldseekerCo if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -653,6 +687,7 @@ type fieldseekerContainerrelateWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerContainerrelateWhere[Q]) AliasedAs(alias string) fieldseekerContainerrelateWhere[Q] { @@ -675,5 +710,6 @@ func buildFieldseekerContainerrelateWhere[Q psql.Filterable](cols fieldseekerCon Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.fieldscoutinglog.bob.go b/db/models/fieldseeker.fieldscoutinglog.bob.go index 85e41656..0e582dab 100644 --- a/db/models/fieldseeker.fieldscoutinglog.bob.go +++ b/db/models/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -36,6 +36,8 @@ type FieldseekerFieldscoutinglog struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerFieldscoutinglogSlice is an alias for a slice of pointers to FieldseekerFieldscoutinglog. @@ -51,7 +53,7 @@ type FieldseekerFieldscoutinglogsQuery = *psql.ViewQuery[*FieldseekerFieldscouti func buildFieldseekerFieldscoutinglogColumns(alias string) fieldseekerFieldscoutinglogColumns { return fieldseekerFieldscoutinglogColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "status", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", + "objectid", "status", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.fieldscoutinglog"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -65,6 +67,7 @@ func buildFieldseekerFieldscoutinglogColumns(alias string) fieldseekerFieldscout Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -82,6 +85,7 @@ type fieldseekerFieldscoutinglogColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerFieldscoutinglogColumns) Alias() string { @@ -107,10 +111,11 @@ type FieldseekerFieldscoutinglogSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerFieldscoutinglogSetter) SetColumns() []string { - vals := make([]string, 0, 11) + vals := make([]string, 0, 12) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -144,6 +149,9 @@ func (s FieldseekerFieldscoutinglogSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -181,6 +189,9 @@ func (s FieldseekerFieldscoutinglogSetter) Overwrite(t *FieldseekerFieldscouting if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerFieldscoutinglogSetter) Apply(q *dialect.InsertQuery) { @@ -189,7 +200,7 @@ func (s *FieldseekerFieldscoutinglogSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 11) + vals := make([]bob.Expression, 12) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -256,6 +267,12 @@ func (s *FieldseekerFieldscoutinglogSetter) Apply(q *dialect.InsertQuery) { vals[10] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[11] = psql.Arg(s.Version.MustGet()) + } else { + vals[11] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -265,7 +282,7 @@ func (s FieldseekerFieldscoutinglogSetter) UpdateMod() bob.Mod[*dialect.UpdateQu } func (s FieldseekerFieldscoutinglogSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 11) + exprs := make([]bob.Expression, 0, 12) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -344,28 +361,38 @@ func (s FieldseekerFieldscoutinglogSetter) Expressions(prefix ...string) []bob.E }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerFieldscoutinglog retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerFieldscoutinglog(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerFieldscoutinglog, error) { +func FindFieldseekerFieldscoutinglog(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerFieldscoutinglog, error) { if len(cols) == 0 { return FieldseekerFieldscoutinglogs.Query( sm.Where(FieldseekerFieldscoutinglogs.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerFieldscoutinglogs.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerFieldscoutinglogs.Query( sm.Where(FieldseekerFieldscoutinglogs.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerFieldscoutinglogs.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerFieldscoutinglogs.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerFieldscoutinglogExists checks the presence of a single record by primary key -func FieldseekerFieldscoutinglogExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerFieldscoutinglogExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerFieldscoutinglogs.Query( sm.Where(FieldseekerFieldscoutinglogs.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerFieldscoutinglogs.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -389,11 +416,14 @@ func (o *FieldseekerFieldscoutinglog) AfterQueryHook(ctx context.Context, exec b // primaryKeyVals returns the primary key values of the FieldseekerFieldscoutinglog func (o *FieldseekerFieldscoutinglog) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerFieldscoutinglog) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.fieldscoutinglog", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.fieldscoutinglog", "objectid"), psql.Quote("fieldseeker.fieldscoutinglog", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -420,6 +450,7 @@ func (o *FieldseekerFieldscoutinglog) Delete(ctx context.Context, exec bob.Execu func (o *FieldseekerFieldscoutinglog) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerFieldscoutinglogs.Query( sm.Where(FieldseekerFieldscoutinglogs.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerFieldscoutinglogs.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -453,7 +484,7 @@ func (o FieldseekerFieldscoutinglogSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.fieldscoutinglog", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.fieldscoutinglog", "objectid"), psql.Quote("fieldseeker.fieldscoutinglog", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -471,6 +502,9 @@ func (o FieldseekerFieldscoutinglogSlice) copyMatchingRows(from ...*FieldseekerF if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -581,6 +615,7 @@ type fieldseekerFieldscoutinglogWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerFieldscoutinglogWhere[Q]) AliasedAs(alias string) fieldseekerFieldscoutinglogWhere[Q] { @@ -600,5 +635,6 @@ func buildFieldseekerFieldscoutinglogWhere[Q psql.Filterable](cols fieldseekerFi Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.habitatrelate.bob.go b/db/models/fieldseeker.habitatrelate.bob.go index 89c91c0f..5630ec64 100644 --- a/db/models/fieldseeker.habitatrelate.bob.go +++ b/db/models/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -37,6 +37,8 @@ type FieldseekerHabitatrelate struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerHabitatrelateSlice is an alias for a slice of pointers to FieldseekerHabitatrelate. @@ -52,7 +54,7 @@ type FieldseekerHabitatrelatesQuery = *psql.ViewQuery[*FieldseekerHabitatrelate, func buildFieldseekerHabitatrelateColumns(alias string) fieldseekerHabitatrelateColumns { return fieldseekerHabitatrelateColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "foreign_id", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "habitattype", "creationdate", "creator", "editdate", "editor", + "objectid", "foreign_id", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "habitattype", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.habitatrelate"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -67,6 +69,7 @@ func buildFieldseekerHabitatrelateColumns(alias string) fieldseekerHabitatrelate Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -85,6 +88,7 @@ type fieldseekerHabitatrelateColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerHabitatrelateColumns) Alias() string { @@ -111,10 +115,11 @@ type FieldseekerHabitatrelateSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerHabitatrelateSetter) SetColumns() []string { - vals := make([]string, 0, 12) + vals := make([]string, 0, 13) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -151,6 +156,9 @@ func (s FieldseekerHabitatrelateSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -191,6 +199,9 @@ func (s FieldseekerHabitatrelateSetter) Overwrite(t *FieldseekerHabitatrelate) { if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerHabitatrelateSetter) Apply(q *dialect.InsertQuery) { @@ -199,7 +210,7 @@ func (s *FieldseekerHabitatrelateSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 12) + vals := make([]bob.Expression, 13) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -272,6 +283,12 @@ func (s *FieldseekerHabitatrelateSetter) Apply(q *dialect.InsertQuery) { vals[11] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[12] = psql.Arg(s.Version.MustGet()) + } else { + vals[12] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -281,7 +298,7 @@ func (s FieldseekerHabitatrelateSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery } func (s FieldseekerHabitatrelateSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 12) + exprs := make([]bob.Expression, 0, 13) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -367,28 +384,38 @@ func (s FieldseekerHabitatrelateSetter) Expressions(prefix ...string) []bob.Expr }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerHabitatrelate retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerHabitatrelate(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerHabitatrelate, error) { +func FindFieldseekerHabitatrelate(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerHabitatrelate, error) { if len(cols) == 0 { return FieldseekerHabitatrelates.Query( sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerHabitatrelates.Query( sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerHabitatrelates.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerHabitatrelateExists checks the presence of a single record by primary key -func FieldseekerHabitatrelateExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerHabitatrelateExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerHabitatrelates.Query( sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -412,11 +439,14 @@ func (o *FieldseekerHabitatrelate) AfterQueryHook(ctx context.Context, exec bob. // primaryKeyVals returns the primary key values of the FieldseekerHabitatrelate func (o *FieldseekerHabitatrelate) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerHabitatrelate) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.habitatrelate", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.habitatrelate", "objectid"), psql.Quote("fieldseeker.habitatrelate", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -443,6 +473,7 @@ func (o *FieldseekerHabitatrelate) Delete(ctx context.Context, exec bob.Executor func (o *FieldseekerHabitatrelate) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerHabitatrelates.Query( sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -476,7 +507,7 @@ func (o FieldseekerHabitatrelateSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.habitatrelate", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.habitatrelate", "objectid"), psql.Quote("fieldseeker.habitatrelate", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -494,6 +525,9 @@ func (o FieldseekerHabitatrelateSlice) copyMatchingRows(from ...*FieldseekerHabi if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -605,6 +639,7 @@ type fieldseekerHabitatrelateWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerHabitatrelateWhere[Q]) AliasedAs(alias string) fieldseekerHabitatrelateWhere[Q] { @@ -625,5 +660,6 @@ func buildFieldseekerHabitatrelateWhere[Q psql.Filterable](cols fieldseekerHabit Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.inspectionsample.bob.go b/db/models/fieldseeker.inspectionsample.bob.go index 1641b5fb..809aab0b 100644 --- a/db/models/fieldseeker.inspectionsample.bob.go +++ b/db/models/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -41,6 +41,8 @@ type FieldseekerInspectionsample struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerInspectionsampleSlice is an alias for a slice of pointers to FieldseekerInspectionsample. @@ -56,7 +58,7 @@ type FieldseekerInspectionsamplesQuery = *psql.ViewQuery[*FieldseekerInspections func buildFieldseekerInspectionsampleColumns(alias string) fieldseekerInspectionsampleColumns { return fieldseekerInspectionsampleColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "insp_id", "sampleid", "processed", "idbytech", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", + "objectid", "insp_id", "sampleid", "processed", "idbytech", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.inspectionsample"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -73,6 +75,7 @@ func buildFieldseekerInspectionsampleColumns(alias string) fieldseekerInspection Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -93,6 +96,7 @@ type fieldseekerInspectionsampleColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerInspectionsampleColumns) Alias() string { @@ -121,10 +125,11 @@ type FieldseekerInspectionsampleSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerInspectionsampleSetter) SetColumns() []string { - vals := make([]string, 0, 14) + vals := make([]string, 0, 15) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -167,6 +172,9 @@ func (s FieldseekerInspectionsampleSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -213,6 +221,9 @@ func (s FieldseekerInspectionsampleSetter) Overwrite(t *FieldseekerInspectionsam if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerInspectionsampleSetter) Apply(q *dialect.InsertQuery) { @@ -221,7 +232,7 @@ func (s *FieldseekerInspectionsampleSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 14) + vals := make([]bob.Expression, 15) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -306,6 +317,12 @@ func (s *FieldseekerInspectionsampleSetter) Apply(q *dialect.InsertQuery) { vals[13] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[14] = psql.Arg(s.Version.MustGet()) + } else { + vals[14] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -315,7 +332,7 @@ func (s FieldseekerInspectionsampleSetter) UpdateMod() bob.Mod[*dialect.UpdateQu } func (s FieldseekerInspectionsampleSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 14) + exprs := make([]bob.Expression, 0, 15) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -415,28 +432,38 @@ func (s FieldseekerInspectionsampleSetter) Expressions(prefix ...string) []bob.E }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerInspectionsample retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerInspectionsample(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerInspectionsample, error) { +func FindFieldseekerInspectionsample(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerInspectionsample, error) { if len(cols) == 0 { return FieldseekerInspectionsamples.Query( sm.Where(FieldseekerInspectionsamples.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerInspectionsamples.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerInspectionsamples.Query( sm.Where(FieldseekerInspectionsamples.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerInspectionsamples.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerInspectionsamples.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerInspectionsampleExists checks the presence of a single record by primary key -func FieldseekerInspectionsampleExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerInspectionsampleExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerInspectionsamples.Query( sm.Where(FieldseekerInspectionsamples.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerInspectionsamples.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -460,11 +487,14 @@ func (o *FieldseekerInspectionsample) AfterQueryHook(ctx context.Context, exec b // primaryKeyVals returns the primary key values of the FieldseekerInspectionsample func (o *FieldseekerInspectionsample) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerInspectionsample) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.inspectionsample", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.inspectionsample", "objectid"), psql.Quote("fieldseeker.inspectionsample", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -491,6 +521,7 @@ func (o *FieldseekerInspectionsample) Delete(ctx context.Context, exec bob.Execu func (o *FieldseekerInspectionsample) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerInspectionsamples.Query( sm.Where(FieldseekerInspectionsamples.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerInspectionsamples.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -524,7 +555,7 @@ func (o FieldseekerInspectionsampleSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.inspectionsample", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.inspectionsample", "objectid"), psql.Quote("fieldseeker.inspectionsample", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -542,6 +573,9 @@ func (o FieldseekerInspectionsampleSlice) copyMatchingRows(from ...*FieldseekerI if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -655,6 +689,7 @@ type fieldseekerInspectionsampleWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerInspectionsampleWhere[Q]) AliasedAs(alias string) fieldseekerInspectionsampleWhere[Q] { @@ -677,5 +712,6 @@ func buildFieldseekerInspectionsampleWhere[Q psql.Filterable](cols fieldseekerIn Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.inspectionsampledetail.bob.go b/db/models/fieldseeker.inspectionsampledetail.bob.go index 3b592de5..fe7d8446 100644 --- a/db/models/fieldseeker.inspectionsampledetail.bob.go +++ b/db/models/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -62,6 +62,8 @@ type FieldseekerInspectionsampledetail struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerInspectionsampledetailSlice is an alias for a slice of pointers to FieldseekerInspectionsampledetail. @@ -77,7 +79,7 @@ type FieldseekerInspectionsampledetailsQuery = *psql.ViewQuery[*FieldseekerInspe func buildFieldseekerInspectionsampledetailColumns(alias string) fieldseekerInspectionsampledetailColumns { return fieldseekerInspectionsampledetailColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "inspsample_id", "fieldspecies", "flarvcount", "fpupcount", "feggcount", "flstages", "fdomstage", "fadultact", "labspecies", "llarvcount", "lpupcount", "leggcount", "ldomstage", "comments", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "processed", "creationdate", "creator", "editdate", "editor", + "objectid", "inspsample_id", "fieldspecies", "flarvcount", "fpupcount", "feggcount", "flstages", "fdomstage", "fadultact", "labspecies", "llarvcount", "lpupcount", "leggcount", "ldomstage", "comments", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "processed", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.inspectionsampledetail"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -105,6 +107,7 @@ func buildFieldseekerInspectionsampledetailColumns(alias string) fieldseekerInsp Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -136,6 +139,7 @@ type fieldseekerInspectionsampledetailColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerInspectionsampledetailColumns) Alias() string { @@ -175,10 +179,11 @@ type FieldseekerInspectionsampledetailSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerInspectionsampledetailSetter) SetColumns() []string { - vals := make([]string, 0, 25) + vals := make([]string, 0, 26) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -254,6 +259,9 @@ func (s FieldseekerInspectionsampledetailSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -333,6 +341,9 @@ func (s FieldseekerInspectionsampledetailSetter) Overwrite(t *FieldseekerInspect if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerInspectionsampledetailSetter) Apply(q *dialect.InsertQuery) { @@ -341,7 +352,7 @@ func (s *FieldseekerInspectionsampledetailSetter) Apply(q *dialect.InsertQuery) }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 25) + vals := make([]bob.Expression, 26) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -492,6 +503,12 @@ func (s *FieldseekerInspectionsampledetailSetter) Apply(q *dialect.InsertQuery) vals[24] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[25] = psql.Arg(s.Version.MustGet()) + } else { + vals[25] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -501,7 +518,7 @@ func (s FieldseekerInspectionsampledetailSetter) UpdateMod() bob.Mod[*dialect.Up } func (s FieldseekerInspectionsampledetailSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 25) + exprs := make([]bob.Expression, 0, 26) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -678,28 +695,38 @@ func (s FieldseekerInspectionsampledetailSetter) Expressions(prefix ...string) [ }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerInspectionsampledetail retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerInspectionsampledetail(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerInspectionsampledetail, error) { +func FindFieldseekerInspectionsampledetail(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerInspectionsampledetail, error) { if len(cols) == 0 { return FieldseekerInspectionsampledetails.Query( sm.Where(FieldseekerInspectionsampledetails.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerInspectionsampledetails.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerInspectionsampledetails.Query( sm.Where(FieldseekerInspectionsampledetails.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerInspectionsampledetails.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerInspectionsampledetails.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerInspectionsampledetailExists checks the presence of a single record by primary key -func FieldseekerInspectionsampledetailExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerInspectionsampledetailExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerInspectionsampledetails.Query( sm.Where(FieldseekerInspectionsampledetails.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerInspectionsampledetails.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -723,11 +750,14 @@ func (o *FieldseekerInspectionsampledetail) AfterQueryHook(ctx context.Context, // primaryKeyVals returns the primary key values of the FieldseekerInspectionsampledetail func (o *FieldseekerInspectionsampledetail) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerInspectionsampledetail) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.inspectionsampledetail", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.inspectionsampledetail", "objectid"), psql.Quote("fieldseeker.inspectionsampledetail", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -754,6 +784,7 @@ func (o *FieldseekerInspectionsampledetail) Delete(ctx context.Context, exec bob func (o *FieldseekerInspectionsampledetail) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerInspectionsampledetails.Query( sm.Where(FieldseekerInspectionsampledetails.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerInspectionsampledetails.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -787,7 +818,7 @@ func (o FieldseekerInspectionsampledetailSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.inspectionsampledetail", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.inspectionsampledetail", "objectid"), psql.Quote("fieldseeker.inspectionsampledetail", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -805,6 +836,9 @@ func (o FieldseekerInspectionsampledetailSlice) copyMatchingRows(from ...*Fields if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -929,6 +963,7 @@ type fieldseekerInspectionsampledetailWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerInspectionsampledetailWhere[Q]) AliasedAs(alias string) fieldseekerInspectionsampledetailWhere[Q] { @@ -962,5 +997,6 @@ func buildFieldseekerInspectionsampledetailWhere[Q psql.Filterable](cols fieldse Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.landingcount.bob.go b/db/models/fieldseeker.landingcount.bob.go deleted file mode 100644 index 9d2a3afe..00000000 --- a/db/models/fieldseeker.landingcount.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerLandingcount is an object representing the database table. -type FieldseekerLandingcount struct{} - -// FieldseekerLandingcountSlice is an alias for a slice of pointers to FieldseekerLandingcount. -// This should almost always be used instead of []*FieldseekerLandingcount. -type FieldseekerLandingcountSlice []*FieldseekerLandingcount - -// FieldseekerLandingcounts contains methods to work with the landingcount view -var FieldseekerLandingcounts = psql.NewViewx[*FieldseekerLandingcount, FieldseekerLandingcountSlice]("fieldseeker", "landingcount", buildFieldseekerLandingcountColumns("fieldseeker.landingcount")) - -// FieldseekerLandingcountsQuery is a query on the landingcount view -type FieldseekerLandingcountsQuery = *psql.ViewQuery[*FieldseekerLandingcount, FieldseekerLandingcountSlice] - -func buildFieldseekerLandingcountColumns(alias string) fieldseekerLandingcountColumns { - return fieldseekerLandingcountColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.landingcount"), - tableAlias: alias, - } -} - -type fieldseekerLandingcountColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerLandingcountColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerLandingcountColumns) AliasedAs(alias string) fieldseekerLandingcountColumns { - return buildFieldseekerLandingcountColumns(alias) -} - -// AfterQueryHook is called after FieldseekerLandingcount is retrieved from the database -func (o *FieldseekerLandingcount) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerLandingcounts.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerLandingcountSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerLandingcountSlice is retrieved from the database -func (o FieldseekerLandingcountSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerLandingcounts.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerLandingcountWhere[Q psql.Filterable] struct{} - -func (fieldseekerLandingcountWhere[Q]) AliasedAs(alias string) fieldseekerLandingcountWhere[Q] { - return buildFieldseekerLandingcountWhere[Q](buildFieldseekerLandingcountColumns(alias)) -} - -func buildFieldseekerLandingcountWhere[Q psql.Filterable](cols fieldseekerLandingcountColumns) fieldseekerLandingcountWhere[Q] { - return fieldseekerLandingcountWhere[Q]{} -} diff --git a/db/models/fieldseeker.landingcountlocation.bob.go b/db/models/fieldseeker.landingcountlocation.bob.go deleted file mode 100644 index 4ad1b61b..00000000 --- a/db/models/fieldseeker.landingcountlocation.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerLandingcountlocation is an object representing the database table. -type FieldseekerLandingcountlocation struct{} - -// FieldseekerLandingcountlocationSlice is an alias for a slice of pointers to FieldseekerLandingcountlocation. -// This should almost always be used instead of []*FieldseekerLandingcountlocation. -type FieldseekerLandingcountlocationSlice []*FieldseekerLandingcountlocation - -// FieldseekerLandingcountlocations contains methods to work with the landingcountlocation view -var FieldseekerLandingcountlocations = psql.NewViewx[*FieldseekerLandingcountlocation, FieldseekerLandingcountlocationSlice]("fieldseeker", "landingcountlocation", buildFieldseekerLandingcountlocationColumns("fieldseeker.landingcountlocation")) - -// FieldseekerLandingcountlocationsQuery is a query on the landingcountlocation view -type FieldseekerLandingcountlocationsQuery = *psql.ViewQuery[*FieldseekerLandingcountlocation, FieldseekerLandingcountlocationSlice] - -func buildFieldseekerLandingcountlocationColumns(alias string) fieldseekerLandingcountlocationColumns { - return fieldseekerLandingcountlocationColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.landingcountlocation"), - tableAlias: alias, - } -} - -type fieldseekerLandingcountlocationColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerLandingcountlocationColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerLandingcountlocationColumns) AliasedAs(alias string) fieldseekerLandingcountlocationColumns { - return buildFieldseekerLandingcountlocationColumns(alias) -} - -// AfterQueryHook is called after FieldseekerLandingcountlocation is retrieved from the database -func (o *FieldseekerLandingcountlocation) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerLandingcountlocations.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerLandingcountlocationSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerLandingcountlocationSlice is retrieved from the database -func (o FieldseekerLandingcountlocationSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerLandingcountlocations.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerLandingcountlocationWhere[Q psql.Filterable] struct{} - -func (fieldseekerLandingcountlocationWhere[Q]) AliasedAs(alias string) fieldseekerLandingcountlocationWhere[Q] { - return buildFieldseekerLandingcountlocationWhere[Q](buildFieldseekerLandingcountlocationColumns(alias)) -} - -func buildFieldseekerLandingcountlocationWhere[Q psql.Filterable](cols fieldseekerLandingcountlocationColumns) fieldseekerLandingcountlocationWhere[Q] { - return fieldseekerLandingcountlocationWhere[Q]{} -} diff --git a/db/models/fieldseeker.linelocation.bob.go b/db/models/fieldseeker.linelocation.bob.go index 55dd21a2..0c970fde 100644 --- a/db/models/fieldseeker.linelocation.bob.go +++ b/db/models/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -108,6 +108,8 @@ type FieldseekerLinelocation struct { // Jurisdiction Jurisdiction null.Val[string] `db:"jurisdiction" ` ShapeLength null.Val[float64] `db:"shape__length" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerLinelocationSlice is an alias for a slice of pointers to FieldseekerLinelocation. @@ -123,7 +125,7 @@ type FieldseekerLinelocationsQuery = *psql.ViewQuery[*FieldseekerLinelocation, F func buildFieldseekerLinelocationColumns(alias string) fieldseekerLinelocationColumns { return fieldseekerLinelocationColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "acres", "nextactiondatescheduled", "larvinspectinterval", "length_ft", "width_ft", "zone2", "locationnumber", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "hectares", "lastinspectactivity", "lasttreatactivity", "length_meters", "width_meters", "lastinspectconditions", "waterorigin", "creationdate", "creator", "editdate", "editor", "jurisdiction", "shape__length", + "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "acres", "nextactiondatescheduled", "larvinspectinterval", "length_ft", "width_ft", "zone2", "locationnumber", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "hectares", "lastinspectactivity", "lasttreatactivity", "length_meters", "width_meters", "lastinspectconditions", "waterorigin", "creationdate", "creator", "editdate", "editor", "jurisdiction", "shape__length", "version", ).WithParent("fieldseeker.linelocation"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -174,6 +176,7 @@ func buildFieldseekerLinelocationColumns(alias string) fieldseekerLinelocationCo Editor: psql.Quote(alias, "editor"), Jurisdiction: psql.Quote(alias, "jurisdiction"), ShapeLength: psql.Quote(alias, "shape__length"), + Version: psql.Quote(alias, "version"), } } @@ -228,6 +231,7 @@ type fieldseekerLinelocationColumns struct { Editor psql.Expression Jurisdiction psql.Expression ShapeLength psql.Expression + Version psql.Expression } func (c fieldseekerLinelocationColumns) Alias() string { @@ -290,10 +294,11 @@ type FieldseekerLinelocationSetter struct { Editor omitnull.Val[string] `db:"editor" ` Jurisdiction omitnull.Val[string] `db:"jurisdiction" ` ShapeLength omitnull.Val[float64] `db:"shape__length" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerLinelocationSetter) SetColumns() []string { - vals := make([]string, 0, 48) + vals := make([]string, 0, 49) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -438,6 +443,9 @@ func (s FieldseekerLinelocationSetter) SetColumns() []string { if !s.ShapeLength.IsUnset() { vals = append(vals, "shape__length") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -586,6 +594,9 @@ func (s FieldseekerLinelocationSetter) Overwrite(t *FieldseekerLinelocation) { if !s.ShapeLength.IsUnset() { t.ShapeLength = s.ShapeLength.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerLinelocationSetter) Apply(q *dialect.InsertQuery) { @@ -594,7 +605,7 @@ func (s *FieldseekerLinelocationSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 48) + vals := make([]bob.Expression, 49) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -883,6 +894,12 @@ func (s *FieldseekerLinelocationSetter) Apply(q *dialect.InsertQuery) { vals[47] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[48] = psql.Arg(s.Version.MustGet()) + } else { + vals[48] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -892,7 +909,7 @@ func (s FieldseekerLinelocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] } func (s FieldseekerLinelocationSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 48) + exprs := make([]bob.Expression, 0, 49) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1230,28 +1247,38 @@ func (s FieldseekerLinelocationSetter) Expressions(prefix ...string) []bob.Expre }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerLinelocation retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerLinelocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerLinelocation, error) { +func FindFieldseekerLinelocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerLinelocation, error) { if len(cols) == 0 { return FieldseekerLinelocations.Query( sm.Where(FieldseekerLinelocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerLinelocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerLinelocations.Query( sm.Where(FieldseekerLinelocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerLinelocations.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerLinelocations.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerLinelocationExists checks the presence of a single record by primary key -func FieldseekerLinelocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerLinelocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerLinelocations.Query( sm.Where(FieldseekerLinelocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerLinelocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1275,11 +1302,14 @@ func (o *FieldseekerLinelocation) AfterQueryHook(ctx context.Context, exec bob.E // primaryKeyVals returns the primary key values of the FieldseekerLinelocation func (o *FieldseekerLinelocation) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerLinelocation) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.linelocation", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.linelocation", "objectid"), psql.Quote("fieldseeker.linelocation", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1306,6 +1336,7 @@ func (o *FieldseekerLinelocation) Delete(ctx context.Context, exec bob.Executor) func (o *FieldseekerLinelocation) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerLinelocations.Query( sm.Where(FieldseekerLinelocations.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerLinelocations.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1339,7 +1370,7 @@ func (o FieldseekerLinelocationSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.linelocation", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.linelocation", "objectid"), psql.Quote("fieldseeker.linelocation", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1357,6 +1388,9 @@ func (o FieldseekerLinelocationSlice) copyMatchingRows(from ...*FieldseekerLinel if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1504,6 +1538,7 @@ type fieldseekerLinelocationWhere[Q psql.Filterable] struct { Editor psql.WhereNullMod[Q, string] Jurisdiction psql.WhereNullMod[Q, string] ShapeLength psql.WhereNullMod[Q, float64] + Version psql.WhereMod[Q, int32] } func (fieldseekerLinelocationWhere[Q]) AliasedAs(alias string) fieldseekerLinelocationWhere[Q] { @@ -1560,5 +1595,6 @@ func buildFieldseekerLinelocationWhere[Q psql.Filterable](cols fieldseekerLinelo Editor: psql.WhereNull[Q, string](cols.Editor), Jurisdiction: psql.WhereNull[Q, string](cols.Jurisdiction), ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.locationtracking.bob.go b/db/models/fieldseeker.locationtracking.bob.go index 47b17975..5843927b 100644 --- a/db/models/fieldseeker.locationtracking.bob.go +++ b/db/models/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -37,6 +37,8 @@ type FieldseekerLocationtracking struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerLocationtrackingSlice is an alias for a slice of pointers to FieldseekerLocationtracking. @@ -52,7 +54,7 @@ type FieldseekerLocationtrackingsQuery = *psql.ViewQuery[*FieldseekerLocationtra func buildFieldseekerLocationtrackingColumns(alias string) fieldseekerLocationtrackingColumns { return fieldseekerLocationtrackingColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "accuracy", "created_user", "created_date", "last_edited_user", "last_edited_date", "globalid", "fieldtech", "creationdate", "creator", "editdate", "editor", + "objectid", "accuracy", "created_user", "created_date", "last_edited_user", "last_edited_date", "globalid", "fieldtech", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.locationtracking"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -67,6 +69,7 @@ func buildFieldseekerLocationtrackingColumns(alias string) fieldseekerLocationtr Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -85,6 +88,7 @@ type fieldseekerLocationtrackingColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerLocationtrackingColumns) Alias() string { @@ -111,10 +115,11 @@ type FieldseekerLocationtrackingSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerLocationtrackingSetter) SetColumns() []string { - vals := make([]string, 0, 12) + vals := make([]string, 0, 13) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -151,6 +156,9 @@ func (s FieldseekerLocationtrackingSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -191,6 +199,9 @@ func (s FieldseekerLocationtrackingSetter) Overwrite(t *FieldseekerLocationtrack if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerLocationtrackingSetter) Apply(q *dialect.InsertQuery) { @@ -199,7 +210,7 @@ func (s *FieldseekerLocationtrackingSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 12) + vals := make([]bob.Expression, 13) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -272,6 +283,12 @@ func (s *FieldseekerLocationtrackingSetter) Apply(q *dialect.InsertQuery) { vals[11] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[12] = psql.Arg(s.Version.MustGet()) + } else { + vals[12] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -281,7 +298,7 @@ func (s FieldseekerLocationtrackingSetter) UpdateMod() bob.Mod[*dialect.UpdateQu } func (s FieldseekerLocationtrackingSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 12) + exprs := make([]bob.Expression, 0, 13) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -367,28 +384,38 @@ func (s FieldseekerLocationtrackingSetter) Expressions(prefix ...string) []bob.E }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerLocationtracking retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerLocationtracking(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerLocationtracking, error) { +func FindFieldseekerLocationtracking(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerLocationtracking, error) { if len(cols) == 0 { return FieldseekerLocationtrackings.Query( sm.Where(FieldseekerLocationtrackings.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerLocationtrackings.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerLocationtrackings.Query( sm.Where(FieldseekerLocationtrackings.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerLocationtrackings.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerLocationtrackings.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerLocationtrackingExists checks the presence of a single record by primary key -func FieldseekerLocationtrackingExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerLocationtrackingExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerLocationtrackings.Query( sm.Where(FieldseekerLocationtrackings.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerLocationtrackings.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -412,11 +439,14 @@ func (o *FieldseekerLocationtracking) AfterQueryHook(ctx context.Context, exec b // primaryKeyVals returns the primary key values of the FieldseekerLocationtracking func (o *FieldseekerLocationtracking) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerLocationtracking) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.locationtracking", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.locationtracking", "objectid"), psql.Quote("fieldseeker.locationtracking", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -443,6 +473,7 @@ func (o *FieldseekerLocationtracking) Delete(ctx context.Context, exec bob.Execu func (o *FieldseekerLocationtracking) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerLocationtrackings.Query( sm.Where(FieldseekerLocationtrackings.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerLocationtrackings.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -476,7 +507,7 @@ func (o FieldseekerLocationtrackingSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.locationtracking", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.locationtracking", "objectid"), psql.Quote("fieldseeker.locationtracking", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -494,6 +525,9 @@ func (o FieldseekerLocationtrackingSlice) copyMatchingRows(from ...*FieldseekerL if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -605,6 +639,7 @@ type fieldseekerLocationtrackingWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerLocationtrackingWhere[Q]) AliasedAs(alias string) fieldseekerLocationtrackingWhere[Q] { @@ -625,5 +660,6 @@ func buildFieldseekerLocationtrackingWhere[Q psql.Filterable](cols fieldseekerLo Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.mosquitoinspection.bob.go b/db/models/fieldseeker.mosquitoinspection.bob.go index d05bed61..c126e367 100644 --- a/db/models/fieldseeker.mosquitoinspection.bob.go +++ b/db/models/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -122,6 +122,8 @@ type FieldseekerMosquitoinspection struct { Vmcomments null.Val[string] `db:"vmcomments" ` Adminaction null.Val[enums.FieldseekerMosquitoinspectionMosquitoinspectionAdminactionB74ae1bbC98B] `db:"adminaction" ` Ptaid null.Val[uuid.UUID] `db:"ptaid" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerMosquitoinspectionSlice is an alias for a slice of pointers to FieldseekerMosquitoinspection. @@ -137,7 +139,7 @@ type FieldseekerMosquitoinspectionsQuery = *psql.ViewQuery[*FieldseekerMosquitoi func buildFieldseekerMosquitoinspectionColumns(alias string) fieldseekerMosquitoinspectionColumns { return fieldseekerMosquitoinspectionColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "numdips", "activity", "breeding", "totlarvae", "totpupae", "eggs", "posdips", "adultact", "lstages", "domstage", "actiontaken", "comments", "avetemp", "windspeed", "raingauge", "startdatetime", "enddatetime", "winddir", "avglarvae", "avgpupae", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "personalcontact", "tirecount", "cbcount", "containercount", "fieldspecies", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "linelocid", "pointlocid", "polygonlocid", "srid", "fieldtech", "larvaepresent", "pupaepresent", "sdid", "sitecond", "positivecontainercount", "creationdate", "creator", "editdate", "editor", "jurisdiction", "visualmonitoring", "vmcomments", "adminaction", "ptaid", + "objectid", "numdips", "activity", "breeding", "totlarvae", "totpupae", "eggs", "posdips", "adultact", "lstages", "domstage", "actiontaken", "comments", "avetemp", "windspeed", "raingauge", "startdatetime", "enddatetime", "winddir", "avglarvae", "avgpupae", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "personalcontact", "tirecount", "cbcount", "containercount", "fieldspecies", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "linelocid", "pointlocid", "polygonlocid", "srid", "fieldtech", "larvaepresent", "pupaepresent", "sdid", "sitecond", "positivecontainercount", "creationdate", "creator", "editdate", "editor", "jurisdiction", "visualmonitoring", "vmcomments", "adminaction", "ptaid", "version", ).WithParent("fieldseeker.mosquitoinspection"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -197,6 +199,7 @@ func buildFieldseekerMosquitoinspectionColumns(alias string) fieldseekerMosquito Vmcomments: psql.Quote(alias, "vmcomments"), Adminaction: psql.Quote(alias, "adminaction"), Ptaid: psql.Quote(alias, "ptaid"), + Version: psql.Quote(alias, "version"), } } @@ -260,6 +263,7 @@ type fieldseekerMosquitoinspectionColumns struct { Vmcomments psql.Expression Adminaction psql.Expression Ptaid psql.Expression + Version psql.Expression } func (c fieldseekerMosquitoinspectionColumns) Alias() string { @@ -331,10 +335,11 @@ type FieldseekerMosquitoinspectionSetter struct { Vmcomments omitnull.Val[string] `db:"vmcomments" ` Adminaction omitnull.Val[enums.FieldseekerMosquitoinspectionMosquitoinspectionAdminactionB74ae1bbC98B] `db:"adminaction" ` Ptaid omitnull.Val[uuid.UUID] `db:"ptaid" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerMosquitoinspectionSetter) SetColumns() []string { - vals := make([]string, 0, 57) + vals := make([]string, 0, 58) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -506,6 +511,9 @@ func (s FieldseekerMosquitoinspectionSetter) SetColumns() []string { if !s.Ptaid.IsUnset() { vals = append(vals, "ptaid") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -681,6 +689,9 @@ func (s FieldseekerMosquitoinspectionSetter) Overwrite(t *FieldseekerMosquitoins if !s.Ptaid.IsUnset() { t.Ptaid = s.Ptaid.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerMosquitoinspectionSetter) Apply(q *dialect.InsertQuery) { @@ -689,7 +700,7 @@ func (s *FieldseekerMosquitoinspectionSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 57) + vals := make([]bob.Expression, 58) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -1032,6 +1043,12 @@ func (s *FieldseekerMosquitoinspectionSetter) Apply(q *dialect.InsertQuery) { vals[56] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[57] = psql.Arg(s.Version.MustGet()) + } else { + vals[57] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -1041,7 +1058,7 @@ func (s FieldseekerMosquitoinspectionSetter) UpdateMod() bob.Mod[*dialect.Update } func (s FieldseekerMosquitoinspectionSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 57) + exprs := make([]bob.Expression, 0, 58) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1442,28 +1459,38 @@ func (s FieldseekerMosquitoinspectionSetter) Expressions(prefix ...string) []bob }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerMosquitoinspection retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerMosquitoinspection(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerMosquitoinspection, error) { +func FindFieldseekerMosquitoinspection(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerMosquitoinspection, error) { if len(cols) == 0 { return FieldseekerMosquitoinspections.Query( sm.Where(FieldseekerMosquitoinspections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerMosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerMosquitoinspections.Query( sm.Where(FieldseekerMosquitoinspections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerMosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerMosquitoinspections.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerMosquitoinspectionExists checks the presence of a single record by primary key -func FieldseekerMosquitoinspectionExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerMosquitoinspectionExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerMosquitoinspections.Query( sm.Where(FieldseekerMosquitoinspections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerMosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1487,11 +1514,14 @@ func (o *FieldseekerMosquitoinspection) AfterQueryHook(ctx context.Context, exec // primaryKeyVals returns the primary key values of the FieldseekerMosquitoinspection func (o *FieldseekerMosquitoinspection) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerMosquitoinspection) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.mosquitoinspection", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.mosquitoinspection", "objectid"), psql.Quote("fieldseeker.mosquitoinspection", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1518,6 +1548,7 @@ func (o *FieldseekerMosquitoinspection) Delete(ctx context.Context, exec bob.Exe func (o *FieldseekerMosquitoinspection) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerMosquitoinspections.Query( sm.Where(FieldseekerMosquitoinspections.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerMosquitoinspections.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1551,7 +1582,7 @@ func (o FieldseekerMosquitoinspectionSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.mosquitoinspection", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.mosquitoinspection", "objectid"), psql.Quote("fieldseeker.mosquitoinspection", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1569,6 +1600,9 @@ func (o FieldseekerMosquitoinspectionSlice) copyMatchingRows(from ...*Fieldseeke if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1725,6 +1759,7 @@ type fieldseekerMosquitoinspectionWhere[Q psql.Filterable] struct { Vmcomments psql.WhereNullMod[Q, string] Adminaction psql.WhereNullMod[Q, enums.FieldseekerMosquitoinspectionMosquitoinspectionAdminactionB74ae1bbC98B] Ptaid psql.WhereNullMod[Q, uuid.UUID] + Version psql.WhereMod[Q, int32] } func (fieldseekerMosquitoinspectionWhere[Q]) AliasedAs(alias string) fieldseekerMosquitoinspectionWhere[Q] { @@ -1790,5 +1825,6 @@ func buildFieldseekerMosquitoinspectionWhere[Q psql.Filterable](cols fieldseeker Vmcomments: psql.WhereNull[Q, string](cols.Vmcomments), Adminaction: psql.WhereNull[Q, enums.FieldseekerMosquitoinspectionMosquitoinspectionAdminactionB74ae1bbC98B](cols.Adminaction), Ptaid: psql.WhereNull[Q, uuid.UUID](cols.Ptaid), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.pointlocation.bob.go b/db/models/fieldseeker.pointlocation.bob.go index b4d1e0ea..44cc29d6 100644 --- a/db/models/fieldseeker.pointlocation.bob.go +++ b/db/models/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -101,6 +101,8 @@ type FieldseekerPointlocation struct { DeactivateReason null.Val[enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489] `db:"deactivate_reason" ` Scalarpriority null.Val[int32] `db:"scalarpriority" ` Sourcestatus null.Val[string] `db:"sourcestatus" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerPointlocationSlice is an alias for a slice of pointers to FieldseekerPointlocation. @@ -116,7 +118,7 @@ type FieldseekerPointlocationsQuery = *psql.ViewQuery[*FieldseekerPointlocation, func buildFieldseekerPointlocationColumns(alias string) fieldseekerPointlocationColumns { return fieldseekerPointlocationColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "stype", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "x", "y", "assignedtech", "creationdate", "creator", "editdate", "editor", "jurisdiction", "deactivate_reason", "scalarpriority", "sourcestatus", + "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "stype", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "x", "y", "assignedtech", "creationdate", "creator", "editdate", "editor", "jurisdiction", "deactivate_reason", "scalarpriority", "sourcestatus", "version", ).WithParent("fieldseeker.pointlocation"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -163,6 +165,7 @@ func buildFieldseekerPointlocationColumns(alias string) fieldseekerPointlocation DeactivateReason: psql.Quote(alias, "deactivate_reason"), Scalarpriority: psql.Quote(alias, "scalarpriority"), Sourcestatus: psql.Quote(alias, "sourcestatus"), + Version: psql.Quote(alias, "version"), } } @@ -213,6 +216,7 @@ type fieldseekerPointlocationColumns struct { DeactivateReason psql.Expression Scalarpriority psql.Expression Sourcestatus psql.Expression + Version psql.Expression } func (c fieldseekerPointlocationColumns) Alias() string { @@ -271,10 +275,11 @@ type FieldseekerPointlocationSetter struct { DeactivateReason omitnull.Val[enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489] `db:"deactivate_reason" ` Scalarpriority omitnull.Val[int32] `db:"scalarpriority" ` Sourcestatus omitnull.Val[string] `db:"sourcestatus" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerPointlocationSetter) SetColumns() []string { - vals := make([]string, 0, 44) + vals := make([]string, 0, 45) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -407,6 +412,9 @@ func (s FieldseekerPointlocationSetter) SetColumns() []string { if !s.Sourcestatus.IsUnset() { vals = append(vals, "sourcestatus") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -543,6 +551,9 @@ func (s FieldseekerPointlocationSetter) Overwrite(t *FieldseekerPointlocation) { if !s.Sourcestatus.IsUnset() { t.Sourcestatus = s.Sourcestatus.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerPointlocationSetter) Apply(q *dialect.InsertQuery) { @@ -551,7 +562,7 @@ func (s *FieldseekerPointlocationSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 44) + vals := make([]bob.Expression, 45) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -816,6 +827,12 @@ func (s *FieldseekerPointlocationSetter) Apply(q *dialect.InsertQuery) { vals[43] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[44] = psql.Arg(s.Version.MustGet()) + } else { + vals[44] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -825,7 +842,7 @@ func (s FieldseekerPointlocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery } func (s FieldseekerPointlocationSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 44) + exprs := make([]bob.Expression, 0, 45) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1135,28 +1152,38 @@ func (s FieldseekerPointlocationSetter) Expressions(prefix ...string) []bob.Expr }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerPointlocation retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerPointlocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerPointlocation, error) { +func FindFieldseekerPointlocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerPointlocation, error) { if len(cols) == 0 { return FieldseekerPointlocations.Query( sm.Where(FieldseekerPointlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPointlocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerPointlocations.Query( sm.Where(FieldseekerPointlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPointlocations.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerPointlocations.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerPointlocationExists checks the presence of a single record by primary key -func FieldseekerPointlocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerPointlocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerPointlocations.Query( sm.Where(FieldseekerPointlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPointlocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1180,11 +1207,14 @@ func (o *FieldseekerPointlocation) AfterQueryHook(ctx context.Context, exec bob. // primaryKeyVals returns the primary key values of the FieldseekerPointlocation func (o *FieldseekerPointlocation) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerPointlocation) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.pointlocation", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.pointlocation", "objectid"), psql.Quote("fieldseeker.pointlocation", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1211,6 +1241,7 @@ func (o *FieldseekerPointlocation) Delete(ctx context.Context, exec bob.Executor func (o *FieldseekerPointlocation) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerPointlocations.Query( sm.Where(FieldseekerPointlocations.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerPointlocations.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1244,7 +1275,7 @@ func (o FieldseekerPointlocationSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.pointlocation", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.pointlocation", "objectid"), psql.Quote("fieldseeker.pointlocation", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1262,6 +1293,9 @@ func (o FieldseekerPointlocationSlice) copyMatchingRows(from ...*FieldseekerPoin if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1405,6 +1439,7 @@ type fieldseekerPointlocationWhere[Q psql.Filterable] struct { DeactivateReason psql.WhereNullMod[Q, enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489] Scalarpriority psql.WhereNullMod[Q, int32] Sourcestatus psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerPointlocationWhere[Q]) AliasedAs(alias string) fieldseekerPointlocationWhere[Q] { @@ -1457,5 +1492,6 @@ func buildFieldseekerPointlocationWhere[Q psql.Filterable](cols fieldseekerPoint DeactivateReason: psql.WhereNull[Q, enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489](cols.DeactivateReason), Scalarpriority: psql.WhereNull[Q, int32](cols.Scalarpriority), Sourcestatus: psql.WhereNull[Q, string](cols.Sourcestatus), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.polygonlocation.bob.go b/db/models/fieldseeker.polygonlocation.bob.go index 18b83c12..72e67361 100644 --- a/db/models/fieldseeker.polygonlocation.bob.go +++ b/db/models/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -98,6 +98,8 @@ type FieldseekerPolygonlocation struct { Jurisdiction null.Val[string] `db:"jurisdiction" ` ShapeArea null.Val[float64] `db:"shape__area" ` ShapeLength null.Val[float64] `db:"shape__length" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerPolygonlocationSlice is an alias for a slice of pointers to FieldseekerPolygonlocation. @@ -113,7 +115,7 @@ type FieldseekerPolygonlocationsQuery = *psql.ViewQuery[*FieldseekerPolygonlocat func buildFieldseekerPolygonlocationColumns(alias string) fieldseekerPolygonlocationColumns { return fieldseekerPolygonlocationColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "acres", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "hectares", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "filter", "creationdate", "creator", "editdate", "editor", "jurisdiction", "shape__area", "shape__length", + "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "acres", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "hectares", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "filter", "creationdate", "creator", "editdate", "editor", "jurisdiction", "shape__area", "shape__length", "version", ).WithParent("fieldseeker.polygonlocation"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -158,6 +160,7 @@ func buildFieldseekerPolygonlocationColumns(alias string) fieldseekerPolygonloca Jurisdiction: psql.Quote(alias, "jurisdiction"), ShapeArea: psql.Quote(alias, "shape__area"), ShapeLength: psql.Quote(alias, "shape__length"), + Version: psql.Quote(alias, "version"), } } @@ -206,6 +209,7 @@ type fieldseekerPolygonlocationColumns struct { Jurisdiction psql.Expression ShapeArea psql.Expression ShapeLength psql.Expression + Version psql.Expression } func (c fieldseekerPolygonlocationColumns) Alias() string { @@ -262,10 +266,11 @@ type FieldseekerPolygonlocationSetter struct { Jurisdiction omitnull.Val[string] `db:"jurisdiction" ` ShapeArea omitnull.Val[float64] `db:"shape__area" ` ShapeLength omitnull.Val[float64] `db:"shape__length" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerPolygonlocationSetter) SetColumns() []string { - vals := make([]string, 0, 42) + vals := make([]string, 0, 43) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -392,6 +397,9 @@ func (s FieldseekerPolygonlocationSetter) SetColumns() []string { if !s.ShapeLength.IsUnset() { vals = append(vals, "shape__length") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -522,6 +530,9 @@ func (s FieldseekerPolygonlocationSetter) Overwrite(t *FieldseekerPolygonlocatio if !s.ShapeLength.IsUnset() { t.ShapeLength = s.ShapeLength.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerPolygonlocationSetter) Apply(q *dialect.InsertQuery) { @@ -530,7 +541,7 @@ func (s *FieldseekerPolygonlocationSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 42) + vals := make([]bob.Expression, 43) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -783,6 +794,12 @@ func (s *FieldseekerPolygonlocationSetter) Apply(q *dialect.InsertQuery) { vals[41] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[42] = psql.Arg(s.Version.MustGet()) + } else { + vals[42] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -792,7 +809,7 @@ func (s FieldseekerPolygonlocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQue } func (s FieldseekerPolygonlocationSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 42) + exprs := make([]bob.Expression, 0, 43) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1088,28 +1105,38 @@ func (s FieldseekerPolygonlocationSetter) Expressions(prefix ...string) []bob.Ex }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerPolygonlocation retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerPolygonlocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerPolygonlocation, error) { +func FindFieldseekerPolygonlocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerPolygonlocation, error) { if len(cols) == 0 { return FieldseekerPolygonlocations.Query( sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerPolygonlocations.Query( sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerPolygonlocations.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerPolygonlocationExists checks the presence of a single record by primary key -func FieldseekerPolygonlocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerPolygonlocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerPolygonlocations.Query( sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1133,11 +1160,14 @@ func (o *FieldseekerPolygonlocation) AfterQueryHook(ctx context.Context, exec bo // primaryKeyVals returns the primary key values of the FieldseekerPolygonlocation func (o *FieldseekerPolygonlocation) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerPolygonlocation) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.polygonlocation", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.polygonlocation", "objectid"), psql.Quote("fieldseeker.polygonlocation", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1164,6 +1194,7 @@ func (o *FieldseekerPolygonlocation) Delete(ctx context.Context, exec bob.Execut func (o *FieldseekerPolygonlocation) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerPolygonlocations.Query( sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1197,7 +1228,7 @@ func (o FieldseekerPolygonlocationSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.polygonlocation", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.polygonlocation", "objectid"), psql.Quote("fieldseeker.polygonlocation", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1215,6 +1246,9 @@ func (o FieldseekerPolygonlocationSlice) copyMatchingRows(from ...*FieldseekerPo if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1356,6 +1390,7 @@ type fieldseekerPolygonlocationWhere[Q psql.Filterable] struct { Jurisdiction psql.WhereNullMod[Q, string] ShapeArea psql.WhereNullMod[Q, float64] ShapeLength psql.WhereNullMod[Q, float64] + Version psql.WhereMod[Q, int32] } func (fieldseekerPolygonlocationWhere[Q]) AliasedAs(alias string) fieldseekerPolygonlocationWhere[Q] { @@ -1406,5 +1441,6 @@ func buildFieldseekerPolygonlocationWhere[Q psql.Filterable](cols fieldseekerPol Jurisdiction: psql.WhereNull[Q, string](cols.Jurisdiction), ShapeArea: psql.WhereNull[Q, float64](cols.ShapeArea), ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.pool.bob.go b/db/models/fieldseeker.pool.bob.go index b2f7f469..70b95958 100644 --- a/db/models/fieldseeker.pool.bob.go +++ b/db/models/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -65,6 +65,8 @@ type FieldseekerPool struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerPoolSlice is an alias for a slice of pointers to FieldseekerPool. @@ -80,7 +82,7 @@ type FieldseekerPoolsQuery = *psql.ViewQuery[*FieldseekerPool, FieldseekerPoolSl func buildFieldseekerPoolColumns(alias string) fieldseekerPoolColumns { return fieldseekerPoolColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "trapdata_id", "datesent", "survtech", "datetested", "testtech", "comments", "sampleid", "processed", "lab_id", "testmethod", "diseasetested", "diseasepos", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "lab", "poolyear", "gatewaysync", "vectorsurvcollectionid", "vectorsurvpoolid", "vectorsurvtrapdataid", "creationdate", "creator", "editdate", "editor", + "objectid", "trapdata_id", "datesent", "survtech", "datetested", "testtech", "comments", "sampleid", "processed", "lab_id", "testmethod", "diseasetested", "diseasepos", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "lab", "poolyear", "gatewaysync", "vectorsurvcollectionid", "vectorsurvpoolid", "vectorsurvtrapdataid", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.pool"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -111,6 +113,7 @@ func buildFieldseekerPoolColumns(alias string) fieldseekerPoolColumns { Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -145,6 +148,7 @@ type fieldseekerPoolColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerPoolColumns) Alias() string { @@ -187,10 +191,11 @@ type FieldseekerPoolSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerPoolSetter) SetColumns() []string { - vals := make([]string, 0, 28) + vals := make([]string, 0, 29) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -275,6 +280,9 @@ func (s FieldseekerPoolSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -363,6 +371,9 @@ func (s FieldseekerPoolSetter) Overwrite(t *FieldseekerPool) { if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerPoolSetter) Apply(q *dialect.InsertQuery) { @@ -371,7 +382,7 @@ func (s *FieldseekerPoolSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 28) + vals := make([]bob.Expression, 29) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -540,6 +551,12 @@ func (s *FieldseekerPoolSetter) Apply(q *dialect.InsertQuery) { vals[27] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[28] = psql.Arg(s.Version.MustGet()) + } else { + vals[28] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -549,7 +566,7 @@ func (s FieldseekerPoolSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerPoolSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 28) + exprs := make([]bob.Expression, 0, 29) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -747,28 +764,38 @@ func (s FieldseekerPoolSetter) Expressions(prefix ...string) []bob.Expression { }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerPool retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerPool(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerPool, error) { +func FindFieldseekerPool(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerPool, error) { if len(cols) == 0 { return FieldseekerPools.Query( sm.Where(FieldseekerPools.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPools.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerPools.Query( sm.Where(FieldseekerPools.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPools.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerPools.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerPoolExists checks the presence of a single record by primary key -func FieldseekerPoolExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerPoolExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerPools.Query( sm.Where(FieldseekerPools.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPools.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -792,11 +819,14 @@ func (o *FieldseekerPool) AfterQueryHook(ctx context.Context, exec bob.Executor, // primaryKeyVals returns the primary key values of the FieldseekerPool func (o *FieldseekerPool) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerPool) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.pool", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.pool", "objectid"), psql.Quote("fieldseeker.pool", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -823,6 +853,7 @@ func (o *FieldseekerPool) Delete(ctx context.Context, exec bob.Executor) error { func (o *FieldseekerPool) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerPools.Query( sm.Where(FieldseekerPools.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerPools.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -856,7 +887,7 @@ func (o FieldseekerPoolSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.pool", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.pool", "objectid"), psql.Quote("fieldseeker.pool", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -874,6 +905,9 @@ func (o FieldseekerPoolSlice) copyMatchingRows(from ...*FieldseekerPool) { if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1001,6 +1035,7 @@ type fieldseekerPoolWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerPoolWhere[Q]) AliasedAs(alias string) fieldseekerPoolWhere[Q] { @@ -1037,5 +1072,6 @@ func buildFieldseekerPoolWhere[Q psql.Filterable](cols fieldseekerPoolColumns) f Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.poolbuffer.bob.go b/db/models/fieldseeker.poolbuffer.bob.go deleted file mode 100644 index b6ba6236..00000000 --- a/db/models/fieldseeker.poolbuffer.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerPoolbuffer is an object representing the database table. -type FieldseekerPoolbuffer struct{} - -// FieldseekerPoolbufferSlice is an alias for a slice of pointers to FieldseekerPoolbuffer. -// This should almost always be used instead of []*FieldseekerPoolbuffer. -type FieldseekerPoolbufferSlice []*FieldseekerPoolbuffer - -// FieldseekerPoolbuffers contains methods to work with the poolbuffer view -var FieldseekerPoolbuffers = psql.NewViewx[*FieldseekerPoolbuffer, FieldseekerPoolbufferSlice]("fieldseeker", "poolbuffer", buildFieldseekerPoolbufferColumns("fieldseeker.poolbuffer")) - -// FieldseekerPoolbuffersQuery is a query on the poolbuffer view -type FieldseekerPoolbuffersQuery = *psql.ViewQuery[*FieldseekerPoolbuffer, FieldseekerPoolbufferSlice] - -func buildFieldseekerPoolbufferColumns(alias string) fieldseekerPoolbufferColumns { - return fieldseekerPoolbufferColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.poolbuffer"), - tableAlias: alias, - } -} - -type fieldseekerPoolbufferColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerPoolbufferColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerPoolbufferColumns) AliasedAs(alias string) fieldseekerPoolbufferColumns { - return buildFieldseekerPoolbufferColumns(alias) -} - -// AfterQueryHook is called after FieldseekerPoolbuffer is retrieved from the database -func (o *FieldseekerPoolbuffer) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerPoolbuffers.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerPoolbufferSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerPoolbufferSlice is retrieved from the database -func (o FieldseekerPoolbufferSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerPoolbuffers.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerPoolbufferWhere[Q psql.Filterable] struct{} - -func (fieldseekerPoolbufferWhere[Q]) AliasedAs(alias string) fieldseekerPoolbufferWhere[Q] { - return buildFieldseekerPoolbufferWhere[Q](buildFieldseekerPoolbufferColumns(alias)) -} - -func buildFieldseekerPoolbufferWhere[Q psql.Filterable](cols fieldseekerPoolbufferColumns) fieldseekerPoolbufferWhere[Q] { - return fieldseekerPoolbufferWhere[Q]{} -} diff --git a/db/models/fieldseeker.pooldetail.bob.go b/db/models/fieldseeker.pooldetail.bob.go index 6559c763..7b33fdaa 100644 --- a/db/models/fieldseeker.pooldetail.bob.go +++ b/db/models/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -41,6 +41,8 @@ type FieldseekerPooldetail struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerPooldetailSlice is an alias for a slice of pointers to FieldseekerPooldetail. @@ -56,7 +58,7 @@ type FieldseekerPooldetailsQuery = *psql.ViewQuery[*FieldseekerPooldetail, Field func buildFieldseekerPooldetailColumns(alias string) fieldseekerPooldetailColumns { return fieldseekerPooldetailColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "trapdata_id", "pool_id", "species", "females", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", + "objectid", "trapdata_id", "pool_id", "species", "females", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.pooldetail"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -73,6 +75,7 @@ func buildFieldseekerPooldetailColumns(alias string) fieldseekerPooldetailColumn Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -93,6 +96,7 @@ type fieldseekerPooldetailColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerPooldetailColumns) Alias() string { @@ -121,10 +125,11 @@ type FieldseekerPooldetailSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerPooldetailSetter) SetColumns() []string { - vals := make([]string, 0, 14) + vals := make([]string, 0, 15) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -167,6 +172,9 @@ func (s FieldseekerPooldetailSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -213,6 +221,9 @@ func (s FieldseekerPooldetailSetter) Overwrite(t *FieldseekerPooldetail) { if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerPooldetailSetter) Apply(q *dialect.InsertQuery) { @@ -221,7 +232,7 @@ func (s *FieldseekerPooldetailSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 14) + vals := make([]bob.Expression, 15) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -306,6 +317,12 @@ func (s *FieldseekerPooldetailSetter) Apply(q *dialect.InsertQuery) { vals[13] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[14] = psql.Arg(s.Version.MustGet()) + } else { + vals[14] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -315,7 +332,7 @@ func (s FieldseekerPooldetailSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerPooldetailSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 14) + exprs := make([]bob.Expression, 0, 15) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -415,28 +432,38 @@ func (s FieldseekerPooldetailSetter) Expressions(prefix ...string) []bob.Express }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerPooldetail retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerPooldetail(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerPooldetail, error) { +func FindFieldseekerPooldetail(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerPooldetail, error) { if len(cols) == 0 { return FieldseekerPooldetails.Query( sm.Where(FieldseekerPooldetails.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPooldetails.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerPooldetails.Query( sm.Where(FieldseekerPooldetails.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPooldetails.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerPooldetails.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerPooldetailExists checks the presence of a single record by primary key -func FieldseekerPooldetailExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerPooldetailExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerPooldetails.Query( sm.Where(FieldseekerPooldetails.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerPooldetails.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -460,11 +487,14 @@ func (o *FieldseekerPooldetail) AfterQueryHook(ctx context.Context, exec bob.Exe // primaryKeyVals returns the primary key values of the FieldseekerPooldetail func (o *FieldseekerPooldetail) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerPooldetail) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.pooldetail", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.pooldetail", "objectid"), psql.Quote("fieldseeker.pooldetail", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -491,6 +521,7 @@ func (o *FieldseekerPooldetail) Delete(ctx context.Context, exec bob.Executor) e func (o *FieldseekerPooldetail) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerPooldetails.Query( sm.Where(FieldseekerPooldetails.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerPooldetails.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -524,7 +555,7 @@ func (o FieldseekerPooldetailSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.pooldetail", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.pooldetail", "objectid"), psql.Quote("fieldseeker.pooldetail", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -542,6 +573,9 @@ func (o FieldseekerPooldetailSlice) copyMatchingRows(from ...*FieldseekerPooldet if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -655,6 +689,7 @@ type fieldseekerPooldetailWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerPooldetailWhere[Q]) AliasedAs(alias string) fieldseekerPooldetailWhere[Q] { @@ -677,5 +712,6 @@ func buildFieldseekerPooldetailWhere[Q psql.Filterable](cols fieldseekerPooldeta Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.proposedtreatmentarea.bob.go b/db/models/fieldseeker.proposedtreatmentarea.bob.go index 59dc8033..14eca843 100644 --- a/db/models/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/models/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -81,6 +81,8 @@ type FieldseekerProposedtreatmentarea struct { Targetspecies null.Val[string] `db:"targetspecies" ` ShapeArea null.Val[float64] `db:"shape__area" ` ShapeLength null.Val[float64] `db:"shape__length" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerProposedtreatmentareaSlice is an alias for a slice of pointers to FieldseekerProposedtreatmentarea. @@ -96,7 +98,7 @@ type FieldseekerProposedtreatmentareasQuery = *psql.ViewQuery[*FieldseekerPropos func buildFieldseekerProposedtreatmentareaColumns(alias string) fieldseekerProposedtreatmentareaColumns { return fieldseekerProposedtreatmentareaColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "method", "comments", "zone", "reviewed", "reviewedby", "revieweddate", "zone2", "completeddate", "completedby", "completed", "issprayroute", "name", "acres", "globalid", "exported", "targetproduct", "targetapprate", "hectares", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "priority", "duedate", "creationdate", "creator", "editdate", "editor", "targetspecies", "shape__area", "shape__length", + "objectid", "method", "comments", "zone", "reviewed", "reviewedby", "revieweddate", "zone2", "completeddate", "completedby", "completed", "issprayroute", "name", "acres", "globalid", "exported", "targetproduct", "targetapprate", "hectares", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "priority", "duedate", "creationdate", "creator", "editdate", "editor", "targetspecies", "shape__area", "shape__length", "version", ).WithParent("fieldseeker.proposedtreatmentarea"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -132,6 +134,7 @@ func buildFieldseekerProposedtreatmentareaColumns(alias string) fieldseekerPropo Targetspecies: psql.Quote(alias, "targetspecies"), ShapeArea: psql.Quote(alias, "shape__area"), ShapeLength: psql.Quote(alias, "shape__length"), + Version: psql.Quote(alias, "version"), } } @@ -171,6 +174,7 @@ type fieldseekerProposedtreatmentareaColumns struct { Targetspecies psql.Expression ShapeArea psql.Expression ShapeLength psql.Expression + Version psql.Expression } func (c fieldseekerProposedtreatmentareaColumns) Alias() string { @@ -218,10 +222,11 @@ type FieldseekerProposedtreatmentareaSetter struct { Targetspecies omitnull.Val[string] `db:"targetspecies" ` ShapeArea omitnull.Val[float64] `db:"shape__area" ` ShapeLength omitnull.Val[float64] `db:"shape__length" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerProposedtreatmentareaSetter) SetColumns() []string { - vals := make([]string, 0, 33) + vals := make([]string, 0, 34) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -321,6 +326,9 @@ func (s FieldseekerProposedtreatmentareaSetter) SetColumns() []string { if !s.ShapeLength.IsUnset() { vals = append(vals, "shape__length") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -424,6 +432,9 @@ func (s FieldseekerProposedtreatmentareaSetter) Overwrite(t *FieldseekerProposed if !s.ShapeLength.IsUnset() { t.ShapeLength = s.ShapeLength.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) { @@ -432,7 +443,7 @@ func (s *FieldseekerProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 33) + vals := make([]bob.Expression, 34) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -631,6 +642,12 @@ func (s *FieldseekerProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) { vals[32] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[33] = psql.Arg(s.Version.MustGet()) + } else { + vals[33] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -640,7 +657,7 @@ func (s FieldseekerProposedtreatmentareaSetter) UpdateMod() bob.Mod[*dialect.Upd } func (s FieldseekerProposedtreatmentareaSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 33) + exprs := make([]bob.Expression, 0, 34) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -873,28 +890,38 @@ func (s FieldseekerProposedtreatmentareaSetter) Expressions(prefix ...string) [] }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerProposedtreatmentarea retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerProposedtreatmentarea(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerProposedtreatmentarea, error) { +func FindFieldseekerProposedtreatmentarea(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerProposedtreatmentarea, error) { if len(cols) == 0 { return FieldseekerProposedtreatmentareas.Query( sm.Where(FieldseekerProposedtreatmentareas.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerProposedtreatmentareas.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerProposedtreatmentareas.Query( sm.Where(FieldseekerProposedtreatmentareas.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerProposedtreatmentareas.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerProposedtreatmentareas.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerProposedtreatmentareaExists checks the presence of a single record by primary key -func FieldseekerProposedtreatmentareaExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerProposedtreatmentareaExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerProposedtreatmentareas.Query( sm.Where(FieldseekerProposedtreatmentareas.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerProposedtreatmentareas.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -918,11 +945,14 @@ func (o *FieldseekerProposedtreatmentarea) AfterQueryHook(ctx context.Context, e // primaryKeyVals returns the primary key values of the FieldseekerProposedtreatmentarea func (o *FieldseekerProposedtreatmentarea) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerProposedtreatmentarea) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.proposedtreatmentarea", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.proposedtreatmentarea", "objectid"), psql.Quote("fieldseeker.proposedtreatmentarea", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -949,6 +979,7 @@ func (o *FieldseekerProposedtreatmentarea) Delete(ctx context.Context, exec bob. func (o *FieldseekerProposedtreatmentarea) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerProposedtreatmentareas.Query( sm.Where(FieldseekerProposedtreatmentareas.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerProposedtreatmentareas.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -982,7 +1013,7 @@ func (o FieldseekerProposedtreatmentareaSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.proposedtreatmentarea", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.proposedtreatmentarea", "objectid"), psql.Quote("fieldseeker.proposedtreatmentarea", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1000,6 +1031,9 @@ func (o FieldseekerProposedtreatmentareaSlice) copyMatchingRows(from ...*Fieldse if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1132,6 +1166,7 @@ type fieldseekerProposedtreatmentareaWhere[Q psql.Filterable] struct { Targetspecies psql.WhereNullMod[Q, string] ShapeArea psql.WhereNullMod[Q, float64] ShapeLength psql.WhereNullMod[Q, float64] + Version psql.WhereMod[Q, int32] } func (fieldseekerProposedtreatmentareaWhere[Q]) AliasedAs(alias string) fieldseekerProposedtreatmentareaWhere[Q] { @@ -1173,5 +1208,6 @@ func buildFieldseekerProposedtreatmentareaWhere[Q psql.Filterable](cols fieldsee Targetspecies: psql.WhereNull[Q, string](cols.Targetspecies), ShapeArea: psql.WhereNull[Q, float64](cols.ShapeArea), ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.qalarvcount.bob.go b/db/models/fieldseeker.qalarvcount.bob.go deleted file mode 100644 index 5e27b04b..00000000 --- a/db/models/fieldseeker.qalarvcount.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerQalarvcount is an object representing the database table. -type FieldseekerQalarvcount struct{} - -// FieldseekerQalarvcountSlice is an alias for a slice of pointers to FieldseekerQalarvcount. -// This should almost always be used instead of []*FieldseekerQalarvcount. -type FieldseekerQalarvcountSlice []*FieldseekerQalarvcount - -// FieldseekerQalarvcounts contains methods to work with the qalarvcount view -var FieldseekerQalarvcounts = psql.NewViewx[*FieldseekerQalarvcount, FieldseekerQalarvcountSlice]("fieldseeker", "qalarvcount", buildFieldseekerQalarvcountColumns("fieldseeker.qalarvcount")) - -// FieldseekerQalarvcountsQuery is a query on the qalarvcount view -type FieldseekerQalarvcountsQuery = *psql.ViewQuery[*FieldseekerQalarvcount, FieldseekerQalarvcountSlice] - -func buildFieldseekerQalarvcountColumns(alias string) fieldseekerQalarvcountColumns { - return fieldseekerQalarvcountColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.qalarvcount"), - tableAlias: alias, - } -} - -type fieldseekerQalarvcountColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerQalarvcountColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerQalarvcountColumns) AliasedAs(alias string) fieldseekerQalarvcountColumns { - return buildFieldseekerQalarvcountColumns(alias) -} - -// AfterQueryHook is called after FieldseekerQalarvcount is retrieved from the database -func (o *FieldseekerQalarvcount) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerQalarvcounts.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerQalarvcountSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerQalarvcountSlice is retrieved from the database -func (o FieldseekerQalarvcountSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerQalarvcounts.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerQalarvcountWhere[Q psql.Filterable] struct{} - -func (fieldseekerQalarvcountWhere[Q]) AliasedAs(alias string) fieldseekerQalarvcountWhere[Q] { - return buildFieldseekerQalarvcountWhere[Q](buildFieldseekerQalarvcountColumns(alias)) -} - -func buildFieldseekerQalarvcountWhere[Q psql.Filterable](cols fieldseekerQalarvcountColumns) fieldseekerQalarvcountWhere[Q] { - return fieldseekerQalarvcountWhere[Q]{} -} diff --git a/db/models/fieldseeker.qamosquitoinspection.bob.go b/db/models/fieldseeker.qamosquitoinspection.bob.go index a8b85c44..7d135f65 100644 --- a/db/models/fieldseeker.qamosquitoinspection.bob.go +++ b/db/models/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -128,6 +128,8 @@ type FieldseekerQamosquitoinspection struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerQamosquitoinspectionSlice is an alias for a slice of pointers to FieldseekerQamosquitoinspection. @@ -143,7 +145,7 @@ type FieldseekerQamosquitoinspectionsQuery = *psql.ViewQuery[*FieldseekerQamosqu func buildFieldseekerQamosquitoinspectionColumns(alias string) fieldseekerQamosquitoinspectionColumns { return fieldseekerQamosquitoinspectionColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "posdips", "actiontaken", "comments", "avetemp", "windspeed", "raingauge", "globalid", "startdatetime", "enddatetime", "winddir", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "lr", "negdips", "totalacres", "acresbreeding", "fish", "sitetype", "breedingpotential", "movingwater", "nowaterever", "mosquitohabitat", "habvalue1", "habvalue1percent", "habvalue2", "habvalue2percent", "potential", "larvaepresent", "larvaeinsidetreatedarea", "larvaeoutsidetreatedarea", "larvaereason", "aquaticorganisms", "vegetation", "sourcereduction", "waterpresent", "watermovement1", "watermovement1percent", "watermovement2", "watermovement2percent", "soilconditions", "waterduration", "watersource", "waterconditions", "adultactivity", "linelocid", "pointlocid", "polygonlocid", "created_user", "created_date", "last_edited_user", "last_edited_date", "fieldtech", "creationdate", "creator", "editdate", "editor", + "objectid", "posdips", "actiontaken", "comments", "avetemp", "windspeed", "raingauge", "globalid", "startdatetime", "enddatetime", "winddir", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "lr", "negdips", "totalacres", "acresbreeding", "fish", "sitetype", "breedingpotential", "movingwater", "nowaterever", "mosquitohabitat", "habvalue1", "habvalue1percent", "habvalue2", "habvalue2percent", "potential", "larvaepresent", "larvaeinsidetreatedarea", "larvaeoutsidetreatedarea", "larvaereason", "aquaticorganisms", "vegetation", "sourcereduction", "waterpresent", "watermovement1", "watermovement1percent", "watermovement2", "watermovement2percent", "soilconditions", "waterduration", "watersource", "waterconditions", "adultactivity", "linelocid", "pointlocid", "polygonlocid", "created_user", "created_date", "last_edited_user", "last_edited_date", "fieldtech", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.qamosquitoinspection"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -208,6 +210,7 @@ func buildFieldseekerQamosquitoinspectionColumns(alias string) fieldseekerQamosq Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -276,6 +279,7 @@ type fieldseekerQamosquitoinspectionColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerQamosquitoinspectionColumns) Alias() string { @@ -352,10 +356,11 @@ type FieldseekerQamosquitoinspectionSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerQamosquitoinspectionSetter) SetColumns() []string { - vals := make([]string, 0, 62) + vals := make([]string, 0, 63) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -542,6 +547,9 @@ func (s FieldseekerQamosquitoinspectionSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -732,6 +740,9 @@ func (s FieldseekerQamosquitoinspectionSetter) Overwrite(t *FieldseekerQamosquit if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerQamosquitoinspectionSetter) Apply(q *dialect.InsertQuery) { @@ -740,7 +751,7 @@ func (s *FieldseekerQamosquitoinspectionSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 62) + vals := make([]bob.Expression, 63) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -1113,6 +1124,12 @@ func (s *FieldseekerQamosquitoinspectionSetter) Apply(q *dialect.InsertQuery) { vals[61] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[62] = psql.Arg(s.Version.MustGet()) + } else { + vals[62] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -1122,7 +1139,7 @@ func (s FieldseekerQamosquitoinspectionSetter) UpdateMod() bob.Mod[*dialect.Upda } func (s FieldseekerQamosquitoinspectionSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 62) + exprs := make([]bob.Expression, 0, 63) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1558,28 +1575,38 @@ func (s FieldseekerQamosquitoinspectionSetter) Expressions(prefix ...string) []b }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerQamosquitoinspection retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerQamosquitoinspection(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerQamosquitoinspection, error) { +func FindFieldseekerQamosquitoinspection(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerQamosquitoinspection, error) { if len(cols) == 0 { return FieldseekerQamosquitoinspections.Query( sm.Where(FieldseekerQamosquitoinspections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerQamosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerQamosquitoinspections.Query( sm.Where(FieldseekerQamosquitoinspections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerQamosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerQamosquitoinspections.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerQamosquitoinspectionExists checks the presence of a single record by primary key -func FieldseekerQamosquitoinspectionExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerQamosquitoinspectionExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerQamosquitoinspections.Query( sm.Where(FieldseekerQamosquitoinspections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerQamosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1603,11 +1630,14 @@ func (o *FieldseekerQamosquitoinspection) AfterQueryHook(ctx context.Context, ex // primaryKeyVals returns the primary key values of the FieldseekerQamosquitoinspection func (o *FieldseekerQamosquitoinspection) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerQamosquitoinspection) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.qamosquitoinspection", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.qamosquitoinspection", "objectid"), psql.Quote("fieldseeker.qamosquitoinspection", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1634,6 +1664,7 @@ func (o *FieldseekerQamosquitoinspection) Delete(ctx context.Context, exec bob.E func (o *FieldseekerQamosquitoinspection) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerQamosquitoinspections.Query( sm.Where(FieldseekerQamosquitoinspections.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerQamosquitoinspections.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1667,7 +1698,7 @@ func (o FieldseekerQamosquitoinspectionSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.qamosquitoinspection", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.qamosquitoinspection", "objectid"), psql.Quote("fieldseeker.qamosquitoinspection", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1685,6 +1716,9 @@ func (o FieldseekerQamosquitoinspectionSlice) copyMatchingRows(from ...*Fieldsee if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1846,6 +1880,7 @@ type fieldseekerQamosquitoinspectionWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerQamosquitoinspectionWhere[Q]) AliasedAs(alias string) fieldseekerQamosquitoinspectionWhere[Q] { @@ -1916,5 +1951,6 @@ func buildFieldseekerQamosquitoinspectionWhere[Q psql.Filterable](cols fieldseek Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.qaproductobservation.bob.go b/db/models/fieldseeker.qaproductobservation.bob.go deleted file mode 100644 index f7efe679..00000000 --- a/db/models/fieldseeker.qaproductobservation.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerQaproductobservation is an object representing the database table. -type FieldseekerQaproductobservation struct{} - -// FieldseekerQaproductobservationSlice is an alias for a slice of pointers to FieldseekerQaproductobservation. -// This should almost always be used instead of []*FieldseekerQaproductobservation. -type FieldseekerQaproductobservationSlice []*FieldseekerQaproductobservation - -// FieldseekerQaproductobservations contains methods to work with the qaproductobservation view -var FieldseekerQaproductobservations = psql.NewViewx[*FieldseekerQaproductobservation, FieldseekerQaproductobservationSlice]("fieldseeker", "qaproductobservation", buildFieldseekerQaproductobservationColumns("fieldseeker.qaproductobservation")) - -// FieldseekerQaproductobservationsQuery is a query on the qaproductobservation view -type FieldseekerQaproductobservationsQuery = *psql.ViewQuery[*FieldseekerQaproductobservation, FieldseekerQaproductobservationSlice] - -func buildFieldseekerQaproductobservationColumns(alias string) fieldseekerQaproductobservationColumns { - return fieldseekerQaproductobservationColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.qaproductobservation"), - tableAlias: alias, - } -} - -type fieldseekerQaproductobservationColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerQaproductobservationColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerQaproductobservationColumns) AliasedAs(alias string) fieldseekerQaproductobservationColumns { - return buildFieldseekerQaproductobservationColumns(alias) -} - -// AfterQueryHook is called after FieldseekerQaproductobservation is retrieved from the database -func (o *FieldseekerQaproductobservation) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerQaproductobservations.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerQaproductobservationSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerQaproductobservationSlice is retrieved from the database -func (o FieldseekerQaproductobservationSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerQaproductobservations.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerQaproductobservationWhere[Q psql.Filterable] struct{} - -func (fieldseekerQaproductobservationWhere[Q]) AliasedAs(alias string) fieldseekerQaproductobservationWhere[Q] { - return buildFieldseekerQaproductobservationWhere[Q](buildFieldseekerQaproductobservationColumns(alias)) -} - -func buildFieldseekerQaproductobservationWhere[Q psql.Filterable](cols fieldseekerQaproductobservationColumns) fieldseekerQaproductobservationWhere[Q] { - return fieldseekerQaproductobservationWhere[Q]{} -} diff --git a/db/models/fieldseeker.restrictedarea.bob.go b/db/models/fieldseeker.restrictedarea.bob.go deleted file mode 100644 index 2a0e5d64..00000000 --- a/db/models/fieldseeker.restrictedarea.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerRestrictedarea is an object representing the database table. -type FieldseekerRestrictedarea struct{} - -// FieldseekerRestrictedareaSlice is an alias for a slice of pointers to FieldseekerRestrictedarea. -// This should almost always be used instead of []*FieldseekerRestrictedarea. -type FieldseekerRestrictedareaSlice []*FieldseekerRestrictedarea - -// FieldseekerRestrictedareas contains methods to work with the restrictedarea view -var FieldseekerRestrictedareas = psql.NewViewx[*FieldseekerRestrictedarea, FieldseekerRestrictedareaSlice]("fieldseeker", "restrictedarea", buildFieldseekerRestrictedareaColumns("fieldseeker.restrictedarea")) - -// FieldseekerRestrictedareasQuery is a query on the restrictedarea view -type FieldseekerRestrictedareasQuery = *psql.ViewQuery[*FieldseekerRestrictedarea, FieldseekerRestrictedareaSlice] - -func buildFieldseekerRestrictedareaColumns(alias string) fieldseekerRestrictedareaColumns { - return fieldseekerRestrictedareaColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.restrictedarea"), - tableAlias: alias, - } -} - -type fieldseekerRestrictedareaColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerRestrictedareaColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerRestrictedareaColumns) AliasedAs(alias string) fieldseekerRestrictedareaColumns { - return buildFieldseekerRestrictedareaColumns(alias) -} - -// AfterQueryHook is called after FieldseekerRestrictedarea is retrieved from the database -func (o *FieldseekerRestrictedarea) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerRestrictedareas.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerRestrictedareaSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerRestrictedareaSlice is retrieved from the database -func (o FieldseekerRestrictedareaSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerRestrictedareas.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerRestrictedareaWhere[Q psql.Filterable] struct{} - -func (fieldseekerRestrictedareaWhere[Q]) AliasedAs(alias string) fieldseekerRestrictedareaWhere[Q] { - return buildFieldseekerRestrictedareaWhere[Q](buildFieldseekerRestrictedareaColumns(alias)) -} - -func buildFieldseekerRestrictedareaWhere[Q psql.Filterable](cols fieldseekerRestrictedareaColumns) fieldseekerRestrictedareaWhere[Q] { - return fieldseekerRestrictedareaWhere[Q]{} -} diff --git a/db/models/fieldseeker.rodentinspection.bob.go b/db/models/fieldseeker.rodentinspection.bob.go deleted file mode 100644 index 7dc6e3b4..00000000 --- a/db/models/fieldseeker.rodentinspection.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerRodentinspection is an object representing the database table. -type FieldseekerRodentinspection struct{} - -// FieldseekerRodentinspectionSlice is an alias for a slice of pointers to FieldseekerRodentinspection. -// This should almost always be used instead of []*FieldseekerRodentinspection. -type FieldseekerRodentinspectionSlice []*FieldseekerRodentinspection - -// FieldseekerRodentinspections contains methods to work with the rodentinspection view -var FieldseekerRodentinspections = psql.NewViewx[*FieldseekerRodentinspection, FieldseekerRodentinspectionSlice]("fieldseeker", "rodentinspection", buildFieldseekerRodentinspectionColumns("fieldseeker.rodentinspection")) - -// FieldseekerRodentinspectionsQuery is a query on the rodentinspection view -type FieldseekerRodentinspectionsQuery = *psql.ViewQuery[*FieldseekerRodentinspection, FieldseekerRodentinspectionSlice] - -func buildFieldseekerRodentinspectionColumns(alias string) fieldseekerRodentinspectionColumns { - return fieldseekerRodentinspectionColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.rodentinspection"), - tableAlias: alias, - } -} - -type fieldseekerRodentinspectionColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerRodentinspectionColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerRodentinspectionColumns) AliasedAs(alias string) fieldseekerRodentinspectionColumns { - return buildFieldseekerRodentinspectionColumns(alias) -} - -// AfterQueryHook is called after FieldseekerRodentinspection is retrieved from the database -func (o *FieldseekerRodentinspection) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerRodentinspections.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerRodentinspectionSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerRodentinspectionSlice is retrieved from the database -func (o FieldseekerRodentinspectionSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerRodentinspections.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerRodentinspectionWhere[Q psql.Filterable] struct{} - -func (fieldseekerRodentinspectionWhere[Q]) AliasedAs(alias string) fieldseekerRodentinspectionWhere[Q] { - return buildFieldseekerRodentinspectionWhere[Q](buildFieldseekerRodentinspectionColumns(alias)) -} - -func buildFieldseekerRodentinspectionWhere[Q psql.Filterable](cols fieldseekerRodentinspectionColumns) fieldseekerRodentinspectionWhere[Q] { - return fieldseekerRodentinspectionWhere[Q]{} -} diff --git a/db/models/fieldseeker.rodentlocation.bob.go b/db/models/fieldseeker.rodentlocation.bob.go index 769b7761..ed156217 100644 --- a/db/models/fieldseeker.rodentlocation.bob.go +++ b/db/models/fieldseeker.rodentlocation.bob.go @@ -1,11 +1,10 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models import ( "context" - "fmt" "io" "time" @@ -21,15 +20,11 @@ import ( "github.com/stephenafamo/bob/dialect/psql/sm" "github.com/stephenafamo/bob/dialect/psql/um" "github.com/stephenafamo/bob/expr" - "github.com/stephenafamo/bob/mods" - "github.com/stephenafamo/bob/orm" - "github.com/stephenafamo/bob/types/pgtypes" ) // FieldseekerRodentlocation is an object representing the database table. type FieldseekerRodentlocation struct { - OrganizationID int32 `db:"organization_id" ` - Objectid int64 `db:"objectid,pk" ` + Objectid int64 `db:"objectid,pk" ` // Location Name Locationname null.Val[string] `db:"locationname" ` Zone null.Val[string] `db:"zone" ` @@ -67,8 +62,8 @@ type FieldseekerRodentlocation struct { Editor null.Val[string] `db:"editor" ` // Jurisdiction Jurisdiction null.Val[string] `db:"jurisdiction" ` - - R fieldseekerRodentlocationR `db:"-" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerRodentlocationSlice is an alias for a slice of pointers to FieldseekerRodentlocation. @@ -81,18 +76,12 @@ var FieldseekerRodentlocations = psql.NewTablex[*FieldseekerRodentlocation, Fiel // FieldseekerRodentlocationsQuery is a query on the rodentlocation table type FieldseekerRodentlocationsQuery = *psql.ViewQuery[*FieldseekerRodentlocation, FieldseekerRodentlocationSlice] -// fieldseekerRodentlocationR is where relationships are stored. -type fieldseekerRodentlocationR struct { - Organization *Organization // fieldseeker.rodentlocation.rodentlocation_organization_id_fkey -} - func buildFieldseekerRodentlocationColumns(alias string) fieldseekerRodentlocationColumns { return fieldseekerRodentlocationColumns{ ColumnsExpr: expr.NewColumnsExpr( - "organization_id", "objectid", "locationname", "zone", "zone2", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "nextactiondatescheduled", "locationnumber", "lastinspectdate", "lastinspectspecies", "lastinspectaction", "lastinspectconditions", "lastinspectrodentevidence", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", "jurisdiction", + "objectid", "locationname", "zone", "zone2", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "nextactiondatescheduled", "locationnumber", "lastinspectdate", "lastinspectspecies", "lastinspectaction", "lastinspectconditions", "lastinspectrodentevidence", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", "jurisdiction", "version", ).WithParent("fieldseeker.rodentlocation"), tableAlias: alias, - OrganizationID: psql.Quote(alias, "organization_id"), Objectid: psql.Quote(alias, "objectid"), Locationname: psql.Quote(alias, "locationname"), Zone: psql.Quote(alias, "zone"), @@ -123,13 +112,13 @@ func buildFieldseekerRodentlocationColumns(alias string) fieldseekerRodentlocati Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), Jurisdiction: psql.Quote(alias, "jurisdiction"), + Version: psql.Quote(alias, "version"), } } type fieldseekerRodentlocationColumns struct { expr.ColumnsExpr tableAlias string - OrganizationID psql.Expression Objectid psql.Expression Locationname psql.Expression Zone psql.Expression @@ -160,6 +149,7 @@ type fieldseekerRodentlocationColumns struct { Editdate psql.Expression Editor psql.Expression Jurisdiction psql.Expression + Version psql.Expression } func (c fieldseekerRodentlocationColumns) Alias() string { @@ -174,7 +164,6 @@ func (fieldseekerRodentlocationColumns) AliasedAs(alias string) fieldseekerRoden // All values are optional, and do not have to be set // Generated columns are not included type FieldseekerRodentlocationSetter struct { - OrganizationID omit.Val[int32] `db:"organization_id" ` Objectid omit.Val[int64] `db:"objectid,pk" ` Locationname omitnull.Val[string] `db:"locationname" ` Zone omitnull.Val[string] `db:"zone" ` @@ -205,13 +194,11 @@ type FieldseekerRodentlocationSetter struct { Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` Jurisdiction omitnull.Val[string] `db:"jurisdiction" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerRodentlocationSetter) SetColumns() []string { vals := make([]string, 0, 31) - if s.OrganizationID.IsValue() { - vals = append(vals, "organization_id") - } if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -302,13 +289,13 @@ func (s FieldseekerRodentlocationSetter) SetColumns() []string { if !s.Jurisdiction.IsUnset() { vals = append(vals, "jurisdiction") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } func (s FieldseekerRodentlocationSetter) Overwrite(t *FieldseekerRodentlocation) { - if s.OrganizationID.IsValue() { - t.OrganizationID = s.OrganizationID.MustGet() - } if s.Objectid.IsValue() { t.Objectid = s.Objectid.MustGet() } @@ -399,6 +386,9 @@ func (s FieldseekerRodentlocationSetter) Overwrite(t *FieldseekerRodentlocation) if !s.Jurisdiction.IsUnset() { t.Jurisdiction = s.Jurisdiction.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerRodentlocationSetter) Apply(q *dialect.InsertQuery) { @@ -408,188 +398,188 @@ func (s *FieldseekerRodentlocationSetter) Apply(q *dialect.InsertQuery) { q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { vals := make([]bob.Expression, 31) - if s.OrganizationID.IsValue() { - vals[0] = psql.Arg(s.OrganizationID.MustGet()) + if s.Objectid.IsValue() { + vals[0] = psql.Arg(s.Objectid.MustGet()) } else { vals[0] = psql.Raw("DEFAULT") } - if s.Objectid.IsValue() { - vals[1] = psql.Arg(s.Objectid.MustGet()) + if !s.Locationname.IsUnset() { + vals[1] = psql.Arg(s.Locationname.MustGetNull()) } else { vals[1] = psql.Raw("DEFAULT") } - if !s.Locationname.IsUnset() { - vals[2] = psql.Arg(s.Locationname.MustGetNull()) + if !s.Zone.IsUnset() { + vals[2] = psql.Arg(s.Zone.MustGetNull()) } else { vals[2] = psql.Raw("DEFAULT") } - if !s.Zone.IsUnset() { - vals[3] = psql.Arg(s.Zone.MustGetNull()) + if !s.Zone2.IsUnset() { + vals[3] = psql.Arg(s.Zone2.MustGetNull()) } else { vals[3] = psql.Raw("DEFAULT") } - if !s.Zone2.IsUnset() { - vals[4] = psql.Arg(s.Zone2.MustGetNull()) + if !s.Habitat.IsUnset() { + vals[4] = psql.Arg(s.Habitat.MustGetNull()) } else { vals[4] = psql.Raw("DEFAULT") } - if !s.Habitat.IsUnset() { - vals[5] = psql.Arg(s.Habitat.MustGetNull()) + if !s.Priority.IsUnset() { + vals[5] = psql.Arg(s.Priority.MustGetNull()) } else { vals[5] = psql.Raw("DEFAULT") } - if !s.Priority.IsUnset() { - vals[6] = psql.Arg(s.Priority.MustGetNull()) + if !s.Usetype.IsUnset() { + vals[6] = psql.Arg(s.Usetype.MustGetNull()) } else { vals[6] = psql.Raw("DEFAULT") } - if !s.Usetype.IsUnset() { - vals[7] = psql.Arg(s.Usetype.MustGetNull()) + if !s.Active.IsUnset() { + vals[7] = psql.Arg(s.Active.MustGetNull()) } else { vals[7] = psql.Raw("DEFAULT") } - if !s.Active.IsUnset() { - vals[8] = psql.Arg(s.Active.MustGetNull()) + if !s.Description.IsUnset() { + vals[8] = psql.Arg(s.Description.MustGetNull()) } else { vals[8] = psql.Raw("DEFAULT") } - if !s.Description.IsUnset() { - vals[9] = psql.Arg(s.Description.MustGetNull()) + if !s.Accessdesc.IsUnset() { + vals[9] = psql.Arg(s.Accessdesc.MustGetNull()) } else { vals[9] = psql.Raw("DEFAULT") } - if !s.Accessdesc.IsUnset() { - vals[10] = psql.Arg(s.Accessdesc.MustGetNull()) + if !s.Comments.IsUnset() { + vals[10] = psql.Arg(s.Comments.MustGetNull()) } else { vals[10] = psql.Raw("DEFAULT") } - if !s.Comments.IsUnset() { - vals[11] = psql.Arg(s.Comments.MustGetNull()) + if !s.Symbology.IsUnset() { + vals[11] = psql.Arg(s.Symbology.MustGetNull()) } else { vals[11] = psql.Raw("DEFAULT") } - if !s.Symbology.IsUnset() { - vals[12] = psql.Arg(s.Symbology.MustGetNull()) + if !s.Externalid.IsUnset() { + vals[12] = psql.Arg(s.Externalid.MustGetNull()) } else { vals[12] = psql.Raw("DEFAULT") } - if !s.Externalid.IsUnset() { - vals[13] = psql.Arg(s.Externalid.MustGetNull()) + if !s.Nextactiondatescheduled.IsUnset() { + vals[13] = psql.Arg(s.Nextactiondatescheduled.MustGetNull()) } else { vals[13] = psql.Raw("DEFAULT") } - if !s.Nextactiondatescheduled.IsUnset() { - vals[14] = psql.Arg(s.Nextactiondatescheduled.MustGetNull()) + if !s.Locationnumber.IsUnset() { + vals[14] = psql.Arg(s.Locationnumber.MustGetNull()) } else { vals[14] = psql.Raw("DEFAULT") } - if !s.Locationnumber.IsUnset() { - vals[15] = psql.Arg(s.Locationnumber.MustGetNull()) + if !s.Lastinspectdate.IsUnset() { + vals[15] = psql.Arg(s.Lastinspectdate.MustGetNull()) } else { vals[15] = psql.Raw("DEFAULT") } - if !s.Lastinspectdate.IsUnset() { - vals[16] = psql.Arg(s.Lastinspectdate.MustGetNull()) + if !s.Lastinspectspecies.IsUnset() { + vals[16] = psql.Arg(s.Lastinspectspecies.MustGetNull()) } else { vals[16] = psql.Raw("DEFAULT") } - if !s.Lastinspectspecies.IsUnset() { - vals[17] = psql.Arg(s.Lastinspectspecies.MustGetNull()) + if !s.Lastinspectaction.IsUnset() { + vals[17] = psql.Arg(s.Lastinspectaction.MustGetNull()) } else { vals[17] = psql.Raw("DEFAULT") } - if !s.Lastinspectaction.IsUnset() { - vals[18] = psql.Arg(s.Lastinspectaction.MustGetNull()) + if !s.Lastinspectconditions.IsUnset() { + vals[18] = psql.Arg(s.Lastinspectconditions.MustGetNull()) } else { vals[18] = psql.Raw("DEFAULT") } - if !s.Lastinspectconditions.IsUnset() { - vals[19] = psql.Arg(s.Lastinspectconditions.MustGetNull()) + if !s.Lastinspectrodentevidence.IsUnset() { + vals[19] = psql.Arg(s.Lastinspectrodentevidence.MustGetNull()) } else { vals[19] = psql.Raw("DEFAULT") } - if !s.Lastinspectrodentevidence.IsUnset() { - vals[20] = psql.Arg(s.Lastinspectrodentevidence.MustGetNull()) + if !s.Globalid.IsUnset() { + vals[20] = psql.Arg(s.Globalid.MustGetNull()) } else { vals[20] = psql.Raw("DEFAULT") } - if !s.Globalid.IsUnset() { - vals[21] = psql.Arg(s.Globalid.MustGetNull()) + if !s.CreatedUser.IsUnset() { + vals[21] = psql.Arg(s.CreatedUser.MustGetNull()) } else { vals[21] = psql.Raw("DEFAULT") } - if !s.CreatedUser.IsUnset() { - vals[22] = psql.Arg(s.CreatedUser.MustGetNull()) + if !s.CreatedDate.IsUnset() { + vals[22] = psql.Arg(s.CreatedDate.MustGetNull()) } else { vals[22] = psql.Raw("DEFAULT") } - if !s.CreatedDate.IsUnset() { - vals[23] = psql.Arg(s.CreatedDate.MustGetNull()) + if !s.LastEditedUser.IsUnset() { + vals[23] = psql.Arg(s.LastEditedUser.MustGetNull()) } else { vals[23] = psql.Raw("DEFAULT") } - if !s.LastEditedUser.IsUnset() { - vals[24] = psql.Arg(s.LastEditedUser.MustGetNull()) + if !s.LastEditedDate.IsUnset() { + vals[24] = psql.Arg(s.LastEditedDate.MustGetNull()) } else { vals[24] = psql.Raw("DEFAULT") } - if !s.LastEditedDate.IsUnset() { - vals[25] = psql.Arg(s.LastEditedDate.MustGetNull()) + if !s.Creationdate.IsUnset() { + vals[25] = psql.Arg(s.Creationdate.MustGetNull()) } else { vals[25] = psql.Raw("DEFAULT") } - if !s.Creationdate.IsUnset() { - vals[26] = psql.Arg(s.Creationdate.MustGetNull()) + if !s.Creator.IsUnset() { + vals[26] = psql.Arg(s.Creator.MustGetNull()) } else { vals[26] = psql.Raw("DEFAULT") } - if !s.Creator.IsUnset() { - vals[27] = psql.Arg(s.Creator.MustGetNull()) + if !s.Editdate.IsUnset() { + vals[27] = psql.Arg(s.Editdate.MustGetNull()) } else { vals[27] = psql.Raw("DEFAULT") } - if !s.Editdate.IsUnset() { - vals[28] = psql.Arg(s.Editdate.MustGetNull()) + if !s.Editor.IsUnset() { + vals[28] = psql.Arg(s.Editor.MustGetNull()) } else { vals[28] = psql.Raw("DEFAULT") } - if !s.Editor.IsUnset() { - vals[29] = psql.Arg(s.Editor.MustGetNull()) + if !s.Jurisdiction.IsUnset() { + vals[29] = psql.Arg(s.Jurisdiction.MustGetNull()) } else { vals[29] = psql.Raw("DEFAULT") } - if !s.Jurisdiction.IsUnset() { - vals[30] = psql.Arg(s.Jurisdiction.MustGetNull()) + if s.Version.IsValue() { + vals[30] = psql.Arg(s.Version.MustGet()) } else { vals[30] = psql.Raw("DEFAULT") } @@ -605,13 +595,6 @@ func (s FieldseekerRodentlocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuer func (s FieldseekerRodentlocationSetter) Expressions(prefix ...string) []bob.Expression { exprs := make([]bob.Expression, 0, 31) - if s.OrganizationID.IsValue() { - exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ - psql.Quote(append(prefix, "organization_id")...), - psql.Arg(s.OrganizationID), - }}) - } - if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "objectid")...), @@ -822,28 +805,38 @@ func (s FieldseekerRodentlocationSetter) Expressions(prefix ...string) []bob.Exp }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerRodentlocation retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerRodentlocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerRodentlocation, error) { +func FindFieldseekerRodentlocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerRodentlocation, error) { if len(cols) == 0 { return FieldseekerRodentlocations.Query( sm.Where(FieldseekerRodentlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerRodentlocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerRodentlocations.Query( sm.Where(FieldseekerRodentlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerRodentlocations.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerRodentlocations.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerRodentlocationExists checks the presence of a single record by primary key -func FieldseekerRodentlocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerRodentlocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerRodentlocations.Query( sm.Where(FieldseekerRodentlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerRodentlocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -867,11 +860,14 @@ func (o *FieldseekerRodentlocation) AfterQueryHook(ctx context.Context, exec bob // primaryKeyVals returns the primary key values of the FieldseekerRodentlocation func (o *FieldseekerRodentlocation) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerRodentlocation) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.rodentlocation", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.rodentlocation", "objectid"), psql.Quote("fieldseeker.rodentlocation", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -883,7 +879,6 @@ func (o *FieldseekerRodentlocation) Update(ctx context.Context, exec bob.Executo return err } - o.R = v.R *o = *v return nil @@ -899,11 +894,12 @@ func (o *FieldseekerRodentlocation) Delete(ctx context.Context, exec bob.Executo func (o *FieldseekerRodentlocation) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerRodentlocations.Query( sm.Where(FieldseekerRodentlocations.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerRodentlocations.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err } - o2.R = o.R + *o = *o2 return nil @@ -932,7 +928,7 @@ func (o FieldseekerRodentlocationSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.rodentlocation", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.rodentlocation", "objectid"), psql.Quote("fieldseeker.rodentlocation", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -950,7 +946,10 @@ func (o FieldseekerRodentlocationSlice) copyMatchingRows(from ...*FieldseekerRod if new.Objectid != old.Objectid { continue } - new.R = old.R + if new.Version != old.Version { + continue + } + o[i] = new break } @@ -1048,80 +1047,7 @@ func (o FieldseekerRodentlocationSlice) ReloadAll(ctx context.Context, exec bob. return nil } -// Organization starts a query for related objects on organization -func (o *FieldseekerRodentlocation) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery { - return Organizations.Query(append(mods, - sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))), - )...) -} - -func (os FieldseekerRodentlocationSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery { - pkOrganizationID := make(pgtypes.Array[int32], 0, len(os)) - for _, o := range os { - if o == nil { - continue - } - pkOrganizationID = append(pkOrganizationID, o.OrganizationID) - } - PKArgExpr := psql.Select(sm.Columns( - psql.F("unnest", psql.Cast(psql.Arg(pkOrganizationID), "integer[]")), - )) - - return Organizations.Query(append(mods, - sm.Where(psql.Group(Organizations.Columns.ID).OP("IN", PKArgExpr)), - )...) -} - -func attachFieldseekerRodentlocationOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerRodentlocation0 *FieldseekerRodentlocation, organization1 *Organization) (*FieldseekerRodentlocation, error) { - setter := &FieldseekerRodentlocationSetter{ - OrganizationID: omit.From(organization1.ID), - } - - err := fieldseekerRodentlocation0.Update(ctx, exec, setter) - if err != nil { - return nil, fmt.Errorf("attachFieldseekerRodentlocationOrganization0: %w", err) - } - - return fieldseekerRodentlocation0, nil -} - -func (fieldseekerRodentlocation0 *FieldseekerRodentlocation) InsertOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error { - var err error - - organization1, err := Organizations.Insert(related).One(ctx, exec) - if err != nil { - return fmt.Errorf("inserting related objects: %w", err) - } - - _, err = attachFieldseekerRodentlocationOrganization0(ctx, exec, 1, fieldseekerRodentlocation0, organization1) - if err != nil { - return err - } - - fieldseekerRodentlocation0.R.Organization = organization1 - - organization1.R.Rodentlocations = append(organization1.R.Rodentlocations, fieldseekerRodentlocation0) - - return nil -} - -func (fieldseekerRodentlocation0 *FieldseekerRodentlocation) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error { - var err error - - _, err = attachFieldseekerRodentlocationOrganization0(ctx, exec, 1, fieldseekerRodentlocation0, organization1) - if err != nil { - return err - } - - fieldseekerRodentlocation0.R.Organization = organization1 - - organization1.R.Rodentlocations = append(organization1.R.Rodentlocations, fieldseekerRodentlocation0) - - return nil -} - type fieldseekerRodentlocationWhere[Q psql.Filterable] struct { - OrganizationID psql.WhereMod[Q, int32] Objectid psql.WhereMod[Q, int64] Locationname psql.WhereNullMod[Q, string] Zone psql.WhereNullMod[Q, string] @@ -1152,6 +1078,7 @@ type fieldseekerRodentlocationWhere[Q psql.Filterable] struct { Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] Jurisdiction psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerRodentlocationWhere[Q]) AliasedAs(alias string) fieldseekerRodentlocationWhere[Q] { @@ -1160,7 +1087,6 @@ func (fieldseekerRodentlocationWhere[Q]) AliasedAs(alias string) fieldseekerRode func buildFieldseekerRodentlocationWhere[Q psql.Filterable](cols fieldseekerRodentlocationColumns) fieldseekerRodentlocationWhere[Q] { return fieldseekerRodentlocationWhere[Q]{ - OrganizationID: psql.Where[Q, int32](cols.OrganizationID), Objectid: psql.Where[Q, int64](cols.Objectid), Locationname: psql.WhereNull[Q, string](cols.Locationname), Zone: psql.WhereNull[Q, string](cols.Zone), @@ -1191,150 +1117,6 @@ func buildFieldseekerRodentlocationWhere[Q psql.Filterable](cols fieldseekerRode Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), Jurisdiction: psql.WhereNull[Q, string](cols.Jurisdiction), - } -} - -func (o *FieldseekerRodentlocation) Preload(name string, retrieved any) error { - if o == nil { - return nil - } - - switch name { - case "Organization": - rel, ok := retrieved.(*Organization) - if !ok { - return fmt.Errorf("fieldseekerRodentlocation cannot load %T as %q", retrieved, name) - } - - o.R.Organization = rel - - if rel != nil { - rel.R.Rodentlocations = FieldseekerRodentlocationSlice{o} - } - return nil - default: - return fmt.Errorf("fieldseekerRodentlocation has no relationship %q", name) - } -} - -type fieldseekerRodentlocationPreloader struct { - Organization func(...psql.PreloadOption) psql.Preloader -} - -func buildFieldseekerRodentlocationPreloader() fieldseekerRodentlocationPreloader { - return fieldseekerRodentlocationPreloader{ - Organization: func(opts ...psql.PreloadOption) psql.Preloader { - return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{ - Name: "Organization", - Sides: []psql.PreloadSide{ - { - From: FieldseekerRodentlocations, - To: Organizations, - FromColumns: []string{"organization_id"}, - ToColumns: []string{"id"}, - }, - }, - }, Organizations.Columns.Names(), opts...) - }, - } -} - -type fieldseekerRodentlocationThenLoader[Q orm.Loadable] struct { - Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] -} - -func buildFieldseekerRodentlocationThenLoader[Q orm.Loadable]() fieldseekerRodentlocationThenLoader[Q] { - type OrganizationLoadInterface interface { - LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error - } - - return fieldseekerRodentlocationThenLoader[Q]{ - Organization: thenLoadBuilder[Q]( - "Organization", - func(ctx context.Context, exec bob.Executor, retrieved OrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { - return retrieved.LoadOrganization(ctx, exec, mods...) - }, - ), - } -} - -// LoadOrganization loads the fieldseekerRodentlocation's Organization into the .R struct -func (o *FieldseekerRodentlocation) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if o == nil { - return nil - } - - // Reset the relationship - o.R.Organization = nil - - related, err := o.Organization(mods...).One(ctx, exec) - if err != nil { - return err - } - - related.R.Rodentlocations = FieldseekerRodentlocationSlice{o} - - o.R.Organization = related - return nil -} - -// LoadOrganization loads the fieldseekerRodentlocation's Organization into the .R struct -func (os FieldseekerRodentlocationSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if len(os) == 0 { - return nil - } - - organizations, err := os.Organization(mods...).All(ctx, exec) - if err != nil { - return err - } - - for _, o := range os { - if o == nil { - continue - } - - for _, rel := range organizations { - - if !(o.OrganizationID == rel.ID) { - continue - } - - rel.R.Rodentlocations = append(rel.R.Rodentlocations, o) - - o.R.Organization = rel - break - } - } - - return nil -} - -type fieldseekerRodentlocationJoins[Q dialect.Joinable] struct { - typ string - Organization modAs[Q, organizationColumns] -} - -func (j fieldseekerRodentlocationJoins[Q]) aliasedAs(alias string) fieldseekerRodentlocationJoins[Q] { - return buildFieldseekerRodentlocationJoins[Q](buildFieldseekerRodentlocationColumns(alias), j.typ) -} - -func buildFieldseekerRodentlocationJoins[Q dialect.Joinable](cols fieldseekerRodentlocationColumns, typ string) fieldseekerRodentlocationJoins[Q] { - return fieldseekerRodentlocationJoins[Q]{ - typ: typ, - Organization: modAs[Q, organizationColumns]{ - c: Organizations.Columns, - f: func(to organizationColumns) bob.Mod[Q] { - mods := make(mods.QueryMods[Q], 0, 1) - - { - mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On( - to.ID.EQ(cols.OrganizationID), - )) - } - - return mods - }, - }, + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.samplecollection.bob.go b/db/models/fieldseeker.samplecollection.bob.go index 1a53f2aa..878c496d 100644 --- a/db/models/fieldseeker.samplecollection.bob.go +++ b/db/models/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -104,6 +104,8 @@ type FieldseekerSamplecollection struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerSamplecollectionSlice is an alias for a slice of pointers to FieldseekerSamplecollection. @@ -119,7 +121,7 @@ type FieldseekerSamplecollectionsQuery = *psql.ViewQuery[*FieldseekerSamplecolle func buildFieldseekerSamplecollectionColumns(alias string) fieldseekerSamplecollectionColumns { return fieldseekerSamplecollectionColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "loc_id", "startdatetime", "enddatetime", "sitecond", "sampleid", "survtech", "datesent", "datetested", "testtech", "comments", "processed", "sampletype", "samplecond", "species", "sex", "avetemp", "windspeed", "winddir", "raingauge", "activity", "testmethod", "diseasetested", "diseasepos", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "lab", "fieldtech", "flockid", "samplecount", "chickenid", "gatewaysync", "creationdate", "creator", "editdate", "editor", + "objectid", "loc_id", "startdatetime", "enddatetime", "sitecond", "sampleid", "survtech", "datesent", "datetested", "testtech", "comments", "processed", "sampletype", "samplecond", "species", "sex", "avetemp", "windspeed", "winddir", "raingauge", "activity", "testmethod", "diseasetested", "diseasepos", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "lab", "fieldtech", "flockid", "samplecount", "chickenid", "gatewaysync", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.samplecollection"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -168,6 +170,7 @@ func buildFieldseekerSamplecollectionColumns(alias string) fieldseekerSamplecoll Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -220,6 +223,7 @@ type fieldseekerSamplecollectionColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerSamplecollectionColumns) Alias() string { @@ -280,10 +284,11 @@ type FieldseekerSamplecollectionSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerSamplecollectionSetter) SetColumns() []string { - vals := make([]string, 0, 46) + vals := make([]string, 0, 47) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -422,6 +427,9 @@ func (s FieldseekerSamplecollectionSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -564,6 +572,9 @@ func (s FieldseekerSamplecollectionSetter) Overwrite(t *FieldseekerSamplecollect if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerSamplecollectionSetter) Apply(q *dialect.InsertQuery) { @@ -572,7 +583,7 @@ func (s *FieldseekerSamplecollectionSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 46) + vals := make([]bob.Expression, 47) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -849,6 +860,12 @@ func (s *FieldseekerSamplecollectionSetter) Apply(q *dialect.InsertQuery) { vals[45] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[46] = psql.Arg(s.Version.MustGet()) + } else { + vals[46] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -858,7 +875,7 @@ func (s FieldseekerSamplecollectionSetter) UpdateMod() bob.Mod[*dialect.UpdateQu } func (s FieldseekerSamplecollectionSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 46) + exprs := make([]bob.Expression, 0, 47) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1182,28 +1199,38 @@ func (s FieldseekerSamplecollectionSetter) Expressions(prefix ...string) []bob.E }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerSamplecollection retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerSamplecollection(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerSamplecollection, error) { +func FindFieldseekerSamplecollection(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerSamplecollection, error) { if len(cols) == 0 { return FieldseekerSamplecollections.Query( sm.Where(FieldseekerSamplecollections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSamplecollections.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerSamplecollections.Query( sm.Where(FieldseekerSamplecollections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSamplecollections.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerSamplecollections.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerSamplecollectionExists checks the presence of a single record by primary key -func FieldseekerSamplecollectionExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerSamplecollectionExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerSamplecollections.Query( sm.Where(FieldseekerSamplecollections.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSamplecollections.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1227,11 +1254,14 @@ func (o *FieldseekerSamplecollection) AfterQueryHook(ctx context.Context, exec b // primaryKeyVals returns the primary key values of the FieldseekerSamplecollection func (o *FieldseekerSamplecollection) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerSamplecollection) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.samplecollection", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.samplecollection", "objectid"), psql.Quote("fieldseeker.samplecollection", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1258,6 +1288,7 @@ func (o *FieldseekerSamplecollection) Delete(ctx context.Context, exec bob.Execu func (o *FieldseekerSamplecollection) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerSamplecollections.Query( sm.Where(FieldseekerSamplecollections.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerSamplecollections.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1291,7 +1322,7 @@ func (o FieldseekerSamplecollectionSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.samplecollection", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.samplecollection", "objectid"), psql.Quote("fieldseeker.samplecollection", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1309,6 +1340,9 @@ func (o FieldseekerSamplecollectionSlice) copyMatchingRows(from ...*FieldseekerS if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1454,6 +1488,7 @@ type fieldseekerSamplecollectionWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerSamplecollectionWhere[Q]) AliasedAs(alias string) fieldseekerSamplecollectionWhere[Q] { @@ -1508,5 +1543,6 @@ func buildFieldseekerSamplecollectionWhere[Q psql.Filterable](cols fieldseekerSa Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.samplelocation.bob.go b/db/models/fieldseeker.samplelocation.bob.go index 2f28627b..951093a9 100644 --- a/db/models/fieldseeker.samplelocation.bob.go +++ b/db/models/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -61,6 +61,8 @@ type FieldseekerSamplelocation struct { Creator null.Val[string] `db:"creator" ` Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerSamplelocationSlice is an alias for a slice of pointers to FieldseekerSamplelocation. @@ -76,7 +78,7 @@ type FieldseekerSamplelocationsQuery = *psql.ViewQuery[*FieldseekerSamplelocatio func buildFieldseekerSamplelocationColumns(alias string) fieldseekerSamplelocationColumns { return fieldseekerSamplelocationColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "externalid", "nextactiondatescheduled", "zone2", "locationnumber", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "gatewaysync", "creationdate", "creator", "editdate", "editor", + "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "externalid", "nextactiondatescheduled", "zone2", "locationnumber", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "gatewaysync", "creationdate", "creator", "editdate", "editor", "version", ).WithParent("fieldseeker.samplelocation"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -103,6 +105,7 @@ func buildFieldseekerSamplelocationColumns(alias string) fieldseekerSamplelocati Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), + Version: psql.Quote(alias, "version"), } } @@ -133,6 +136,7 @@ type fieldseekerSamplelocationColumns struct { Creator psql.Expression Editdate psql.Expression Editor psql.Expression + Version psql.Expression } func (c fieldseekerSamplelocationColumns) Alias() string { @@ -171,10 +175,11 @@ type FieldseekerSamplelocationSetter struct { Creator omitnull.Val[string] `db:"creator" ` Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerSamplelocationSetter) SetColumns() []string { - vals := make([]string, 0, 24) + vals := make([]string, 0, 25) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -247,6 +252,9 @@ func (s FieldseekerSamplelocationSetter) SetColumns() []string { if !s.Editor.IsUnset() { vals = append(vals, "editor") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -323,6 +331,9 @@ func (s FieldseekerSamplelocationSetter) Overwrite(t *FieldseekerSamplelocation) if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerSamplelocationSetter) Apply(q *dialect.InsertQuery) { @@ -331,7 +342,7 @@ func (s *FieldseekerSamplelocationSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 24) + vals := make([]bob.Expression, 25) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -476,6 +487,12 @@ func (s *FieldseekerSamplelocationSetter) Apply(q *dialect.InsertQuery) { vals[23] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[24] = psql.Arg(s.Version.MustGet()) + } else { + vals[24] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -485,7 +502,7 @@ func (s FieldseekerSamplelocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuer } func (s FieldseekerSamplelocationSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 24) + exprs := make([]bob.Expression, 0, 25) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -655,28 +672,38 @@ func (s FieldseekerSamplelocationSetter) Expressions(prefix ...string) []bob.Exp }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerSamplelocation retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerSamplelocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerSamplelocation, error) { +func FindFieldseekerSamplelocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerSamplelocation, error) { if len(cols) == 0 { return FieldseekerSamplelocations.Query( sm.Where(FieldseekerSamplelocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSamplelocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerSamplelocations.Query( sm.Where(FieldseekerSamplelocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSamplelocations.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerSamplelocations.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerSamplelocationExists checks the presence of a single record by primary key -func FieldseekerSamplelocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerSamplelocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerSamplelocations.Query( sm.Where(FieldseekerSamplelocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSamplelocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -700,11 +727,14 @@ func (o *FieldseekerSamplelocation) AfterQueryHook(ctx context.Context, exec bob // primaryKeyVals returns the primary key values of the FieldseekerSamplelocation func (o *FieldseekerSamplelocation) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerSamplelocation) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.samplelocation", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.samplelocation", "objectid"), psql.Quote("fieldseeker.samplelocation", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -731,6 +761,7 @@ func (o *FieldseekerSamplelocation) Delete(ctx context.Context, exec bob.Executo func (o *FieldseekerSamplelocation) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerSamplelocations.Query( sm.Where(FieldseekerSamplelocations.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerSamplelocations.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -764,7 +795,7 @@ func (o FieldseekerSamplelocationSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.samplelocation", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.samplelocation", "objectid"), psql.Quote("fieldseeker.samplelocation", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -782,6 +813,9 @@ func (o FieldseekerSamplelocationSlice) copyMatchingRows(from ...*FieldseekerSam if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -905,6 +939,7 @@ type fieldseekerSamplelocationWhere[Q psql.Filterable] struct { Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerSamplelocationWhere[Q]) AliasedAs(alias string) fieldseekerSamplelocationWhere[Q] { @@ -937,5 +972,6 @@ func buildFieldseekerSamplelocationWhere[Q psql.Filterable](cols fieldseekerSamp Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.servicerequest.bob.go b/db/models/fieldseeker.servicerequest.bob.go index 15e0b1cf..36121c91 100644 --- a/db/models/fieldseeker.servicerequest.bob.go +++ b/db/models/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -185,6 +185,8 @@ type FieldseekerServicerequest struct { Zone null.Val[string] `db:"zone" ` // Zone2 Zone2 null.Val[string] `db:"zone2" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerServicerequestSlice is an alias for a slice of pointers to FieldseekerServicerequest. @@ -200,7 +202,7 @@ type FieldseekerServicerequestsQuery = *psql.ViewQuery[*FieldseekerServicereques func buildFieldseekerServicerequestColumns(alias string) fieldseekerServicerequestColumns { return fieldseekerServicerequestColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "recdatetime", "source", "entrytech", "priority", "supervisor", "assignedtech", "status", "clranon", "clrfname", "clrphone1", "clrphone2", "clremail", "clrcompany", "clraddr1", "clraddr2", "clrcity", "clrstate", "clrzip", "clrother", "clrcontpref", "reqcompany", "reqaddr1", "reqaddr2", "reqcity", "reqstate", "reqzip", "reqcrossst", "reqsubdiv", "reqmapgrid", "reqpermission", "reqtarget", "reqdescr", "reqnotesfortech", "reqnotesforcust", "reqfldnotes", "reqprogramactions", "datetimeclosed", "techclosed", "sr_number", "reviewed", "reviewedby", "revieweddate", "accepted", "accepteddate", "rejectedby", "rejecteddate", "rejectedreason", "duedate", "acceptedby", "comments", "estcompletedate", "nextaction", "recordstatus", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "firstresponsedate", "responsedaycount", "allowed", "xvalue", "yvalue", "validx", "validy", "externalid", "externalerror", "pointlocid", "notified", "notifieddate", "scheduled", "scheduleddate", "dog", "schedule_period", "schedule_notes", "spanish", "creationdate", "creator", "editdate", "editor", "issuesreported", "jurisdiction", "notificationtimestamp", "zone", "zone2", + "objectid", "recdatetime", "source", "entrytech", "priority", "supervisor", "assignedtech", "status", "clranon", "clrfname", "clrphone1", "clrphone2", "clremail", "clrcompany", "clraddr1", "clraddr2", "clrcity", "clrstate", "clrzip", "clrother", "clrcontpref", "reqcompany", "reqaddr1", "reqaddr2", "reqcity", "reqstate", "reqzip", "reqcrossst", "reqsubdiv", "reqmapgrid", "reqpermission", "reqtarget", "reqdescr", "reqnotesfortech", "reqnotesforcust", "reqfldnotes", "reqprogramactions", "datetimeclosed", "techclosed", "sr_number", "reviewed", "reviewedby", "revieweddate", "accepted", "accepteddate", "rejectedby", "rejecteddate", "rejectedreason", "duedate", "acceptedby", "comments", "estcompletedate", "nextaction", "recordstatus", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "firstresponsedate", "responsedaycount", "allowed", "xvalue", "yvalue", "validx", "validy", "externalid", "externalerror", "pointlocid", "notified", "notifieddate", "scheduled", "scheduleddate", "dog", "schedule_period", "schedule_notes", "spanish", "creationdate", "creator", "editdate", "editor", "issuesreported", "jurisdiction", "notificationtimestamp", "zone", "zone2", "version", ).WithParent("fieldseeker.servicerequest"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -289,6 +291,7 @@ func buildFieldseekerServicerequestColumns(alias string) fieldseekerServicereque Notificationtimestamp: psql.Quote(alias, "notificationtimestamp"), Zone: psql.Quote(alias, "zone"), Zone2: psql.Quote(alias, "zone2"), + Version: psql.Quote(alias, "version"), } } @@ -381,6 +384,7 @@ type fieldseekerServicerequestColumns struct { Notificationtimestamp psql.Expression Zone psql.Expression Zone2 psql.Expression + Version psql.Expression } func (c fieldseekerServicerequestColumns) Alias() string { @@ -481,10 +485,11 @@ type FieldseekerServicerequestSetter struct { Notificationtimestamp omitnull.Val[string] `db:"notificationtimestamp" ` Zone omitnull.Val[string] `db:"zone" ` Zone2 omitnull.Val[string] `db:"zone2" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerServicerequestSetter) SetColumns() []string { - vals := make([]string, 0, 86) + vals := make([]string, 0, 87) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -743,6 +748,9 @@ func (s FieldseekerServicerequestSetter) SetColumns() []string { if !s.Zone2.IsUnset() { vals = append(vals, "zone2") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -1005,6 +1013,9 @@ func (s FieldseekerServicerequestSetter) Overwrite(t *FieldseekerServicerequest) if !s.Zone2.IsUnset() { t.Zone2 = s.Zone2.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerServicerequestSetter) Apply(q *dialect.InsertQuery) { @@ -1013,7 +1024,7 @@ func (s *FieldseekerServicerequestSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 86) + vals := make([]bob.Expression, 87) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -1530,6 +1541,12 @@ func (s *FieldseekerServicerequestSetter) Apply(q *dialect.InsertQuery) { vals[85] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[86] = psql.Arg(s.Version.MustGet()) + } else { + vals[86] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -1539,7 +1556,7 @@ func (s FieldseekerServicerequestSetter) UpdateMod() bob.Mod[*dialect.UpdateQuer } func (s FieldseekerServicerequestSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 86) + exprs := make([]bob.Expression, 0, 87) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -2143,28 +2160,38 @@ func (s FieldseekerServicerequestSetter) Expressions(prefix ...string) []bob.Exp }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerServicerequest retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerServicerequest(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerServicerequest, error) { +func FindFieldseekerServicerequest(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerServicerequest, error) { if len(cols) == 0 { return FieldseekerServicerequests.Query( sm.Where(FieldseekerServicerequests.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerServicerequests.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerServicerequests.Query( sm.Where(FieldseekerServicerequests.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerServicerequests.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerServicerequests.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerServicerequestExists checks the presence of a single record by primary key -func FieldseekerServicerequestExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerServicerequestExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerServicerequests.Query( sm.Where(FieldseekerServicerequests.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerServicerequests.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -2188,11 +2215,14 @@ func (o *FieldseekerServicerequest) AfterQueryHook(ctx context.Context, exec bob // primaryKeyVals returns the primary key values of the FieldseekerServicerequest func (o *FieldseekerServicerequest) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerServicerequest) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.servicerequest", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.servicerequest", "objectid"), psql.Quote("fieldseeker.servicerequest", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -2219,6 +2249,7 @@ func (o *FieldseekerServicerequest) Delete(ctx context.Context, exec bob.Executo func (o *FieldseekerServicerequest) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerServicerequests.Query( sm.Where(FieldseekerServicerequests.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerServicerequests.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -2252,7 +2283,7 @@ func (o FieldseekerServicerequestSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.servicerequest", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.servicerequest", "objectid"), psql.Quote("fieldseeker.servicerequest", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -2270,6 +2301,9 @@ func (o FieldseekerServicerequestSlice) copyMatchingRows(from ...*FieldseekerSer if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -2455,6 +2489,7 @@ type fieldseekerServicerequestWhere[Q psql.Filterable] struct { Notificationtimestamp psql.WhereNullMod[Q, string] Zone psql.WhereNullMod[Q, string] Zone2 psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerServicerequestWhere[Q]) AliasedAs(alias string) fieldseekerServicerequestWhere[Q] { @@ -2549,5 +2584,6 @@ func buildFieldseekerServicerequestWhere[Q psql.Filterable](cols fieldseekerServ Notificationtimestamp: psql.WhereNull[Q, string](cols.Notificationtimestamp), Zone: psql.WhereNull[Q, string](cols.Zone), Zone2: psql.WhereNull[Q, string](cols.Zone2), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.speciesabundance.bob.go b/db/models/fieldseeker.speciesabundance.bob.go index fa1ef0d5..9b661af1 100644 --- a/db/models/fieldseeker.speciesabundance.bob.go +++ b/db/models/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -66,6 +66,8 @@ type FieldseekerSpeciesabundance struct { R8score null.Val[float64] `db:"r8score" ` H3R7 null.Val[string] `db:"h3r7" ` H3R8 null.Val[string] `db:"h3r8" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerSpeciesabundanceSlice is an alias for a slice of pointers to FieldseekerSpeciesabundance. @@ -81,7 +83,7 @@ type FieldseekerSpeciesabundancesQuery = *psql.ViewQuery[*FieldseekerSpeciesabun func buildFieldseekerSpeciesabundanceColumns(alias string) fieldseekerSpeciesabundanceColumns { return fieldseekerSpeciesabundanceColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "trapdata_id", "species", "males", "unknown", "bloodedfem", "gravidfem", "larvae", "poolstogen", "processed", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "pupae", "eggs", "females", "total", "creationdate", "creator", "editdate", "editor", "yearweek", "globalzscore", "r7score", "r8score", "h3r7", "h3r8", + "objectid", "trapdata_id", "species", "males", "unknown", "bloodedfem", "gravidfem", "larvae", "poolstogen", "processed", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "pupae", "eggs", "females", "total", "creationdate", "creator", "editdate", "editor", "yearweek", "globalzscore", "r7score", "r8score", "h3r7", "h3r8", "version", ).WithParent("fieldseeker.speciesabundance"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -113,6 +115,7 @@ func buildFieldseekerSpeciesabundanceColumns(alias string) fieldseekerSpeciesabu R8score: psql.Quote(alias, "r8score"), H3R7: psql.Quote(alias, "h3r7"), H3R8: psql.Quote(alias, "h3r8"), + Version: psql.Quote(alias, "version"), } } @@ -148,6 +151,7 @@ type fieldseekerSpeciesabundanceColumns struct { R8score psql.Expression H3R7 psql.Expression H3R8 psql.Expression + Version psql.Expression } func (c fieldseekerSpeciesabundanceColumns) Alias() string { @@ -191,10 +195,11 @@ type FieldseekerSpeciesabundanceSetter struct { R8score omitnull.Val[float64] `db:"r8score" ` H3R7 omitnull.Val[string] `db:"h3r7" ` H3R8 omitnull.Val[string] `db:"h3r8" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerSpeciesabundanceSetter) SetColumns() []string { - vals := make([]string, 0, 29) + vals := make([]string, 0, 30) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -282,6 +287,9 @@ func (s FieldseekerSpeciesabundanceSetter) SetColumns() []string { if !s.H3R8.IsUnset() { vals = append(vals, "h3r8") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -373,6 +381,9 @@ func (s FieldseekerSpeciesabundanceSetter) Overwrite(t *FieldseekerSpeciesabunda if !s.H3R8.IsUnset() { t.H3R8 = s.H3R8.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerSpeciesabundanceSetter) Apply(q *dialect.InsertQuery) { @@ -381,7 +392,7 @@ func (s *FieldseekerSpeciesabundanceSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 29) + vals := make([]bob.Expression, 30) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -556,6 +567,12 @@ func (s *FieldseekerSpeciesabundanceSetter) Apply(q *dialect.InsertQuery) { vals[28] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[29] = psql.Arg(s.Version.MustGet()) + } else { + vals[29] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -565,7 +582,7 @@ func (s FieldseekerSpeciesabundanceSetter) UpdateMod() bob.Mod[*dialect.UpdateQu } func (s FieldseekerSpeciesabundanceSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 29) + exprs := make([]bob.Expression, 0, 30) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -770,28 +787,38 @@ func (s FieldseekerSpeciesabundanceSetter) Expressions(prefix ...string) []bob.E }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerSpeciesabundance retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerSpeciesabundance(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerSpeciesabundance, error) { +func FindFieldseekerSpeciesabundance(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerSpeciesabundance, error) { if len(cols) == 0 { return FieldseekerSpeciesabundances.Query( sm.Where(FieldseekerSpeciesabundances.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSpeciesabundances.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerSpeciesabundances.Query( sm.Where(FieldseekerSpeciesabundances.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSpeciesabundances.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerSpeciesabundances.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerSpeciesabundanceExists checks the presence of a single record by primary key -func FieldseekerSpeciesabundanceExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerSpeciesabundanceExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerSpeciesabundances.Query( sm.Where(FieldseekerSpeciesabundances.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerSpeciesabundances.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -815,11 +842,14 @@ func (o *FieldseekerSpeciesabundance) AfterQueryHook(ctx context.Context, exec b // primaryKeyVals returns the primary key values of the FieldseekerSpeciesabundance func (o *FieldseekerSpeciesabundance) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerSpeciesabundance) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.speciesabundance", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.speciesabundance", "objectid"), psql.Quote("fieldseeker.speciesabundance", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -846,6 +876,7 @@ func (o *FieldseekerSpeciesabundance) Delete(ctx context.Context, exec bob.Execu func (o *FieldseekerSpeciesabundance) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerSpeciesabundances.Query( sm.Where(FieldseekerSpeciesabundances.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerSpeciesabundances.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -879,7 +910,7 @@ func (o FieldseekerSpeciesabundanceSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.speciesabundance", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.speciesabundance", "objectid"), psql.Quote("fieldseeker.speciesabundance", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -897,6 +928,9 @@ func (o FieldseekerSpeciesabundanceSlice) copyMatchingRows(from ...*FieldseekerS if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1025,6 +1059,7 @@ type fieldseekerSpeciesabundanceWhere[Q psql.Filterable] struct { R8score psql.WhereNullMod[Q, float64] H3R7 psql.WhereNullMod[Q, string] H3R8 psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerSpeciesabundanceWhere[Q]) AliasedAs(alias string) fieldseekerSpeciesabundanceWhere[Q] { @@ -1062,5 +1097,6 @@ func buildFieldseekerSpeciesabundanceWhere[Q psql.Filterable](cols fieldseekerSp R8score: psql.WhereNull[Q, float64](cols.R8score), H3R7: psql.WhereNull[Q, string](cols.H3R7), H3R8: psql.WhereNull[Q, string](cols.H3R8), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.stormdrain.bob.go b/db/models/fieldseeker.stormdrain.bob.go index 651e97c7..c99f8b5b 100644 --- a/db/models/fieldseeker.stormdrain.bob.go +++ b/db/models/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -47,6 +47,8 @@ type FieldseekerStormdrain struct { Type null.Val[string] `db:"type" ` // Jurisdiction Jurisdiction null.Val[string] `db:"jurisdiction" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerStormdrainSlice is an alias for a slice of pointers to FieldseekerStormdrain. @@ -62,7 +64,7 @@ type FieldseekerStormdrainsQuery = *psql.ViewQuery[*FieldseekerStormdrain, Field func buildFieldseekerStormdrainColumns(alias string) fieldseekerStormdrainColumns { return fieldseekerStormdrainColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "nexttreatmentdate", "lasttreatdate", "lastaction", "symbology", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "laststatus", "zone", "zone2", "creationdate", "creator", "editdate", "editor", "type", "jurisdiction", + "objectid", "nexttreatmentdate", "lasttreatdate", "lastaction", "symbology", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "laststatus", "zone", "zone2", "creationdate", "creator", "editdate", "editor", "type", "jurisdiction", "version", ).WithParent("fieldseeker.stormdrain"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -84,6 +86,7 @@ func buildFieldseekerStormdrainColumns(alias string) fieldseekerStormdrainColumn Editor: psql.Quote(alias, "editor"), Type: psql.Quote(alias, "type"), Jurisdiction: psql.Quote(alias, "jurisdiction"), + Version: psql.Quote(alias, "version"), } } @@ -109,6 +112,7 @@ type fieldseekerStormdrainColumns struct { Editor psql.Expression Type psql.Expression Jurisdiction psql.Expression + Version psql.Expression } func (c fieldseekerStormdrainColumns) Alias() string { @@ -142,10 +146,11 @@ type FieldseekerStormdrainSetter struct { Editor omitnull.Val[string] `db:"editor" ` Type omitnull.Val[string] `db:"type" ` Jurisdiction omitnull.Val[string] `db:"jurisdiction" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerStormdrainSetter) SetColumns() []string { - vals := make([]string, 0, 19) + vals := make([]string, 0, 20) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -203,6 +208,9 @@ func (s FieldseekerStormdrainSetter) SetColumns() []string { if !s.Jurisdiction.IsUnset() { vals = append(vals, "jurisdiction") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -264,6 +272,9 @@ func (s FieldseekerStormdrainSetter) Overwrite(t *FieldseekerStormdrain) { if !s.Jurisdiction.IsUnset() { t.Jurisdiction = s.Jurisdiction.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerStormdrainSetter) Apply(q *dialect.InsertQuery) { @@ -272,7 +283,7 @@ func (s *FieldseekerStormdrainSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 19) + vals := make([]bob.Expression, 20) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -387,6 +398,12 @@ func (s *FieldseekerStormdrainSetter) Apply(q *dialect.InsertQuery) { vals[18] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[19] = psql.Arg(s.Version.MustGet()) + } else { + vals[19] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -396,7 +413,7 @@ func (s FieldseekerStormdrainSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerStormdrainSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 19) + exprs := make([]bob.Expression, 0, 20) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -531,28 +548,38 @@ func (s FieldseekerStormdrainSetter) Expressions(prefix ...string) []bob.Express }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerStormdrain retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerStormdrain(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerStormdrain, error) { +func FindFieldseekerStormdrain(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerStormdrain, error) { if len(cols) == 0 { return FieldseekerStormdrains.Query( sm.Where(FieldseekerStormdrains.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerStormdrains.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerStormdrains.Query( sm.Where(FieldseekerStormdrains.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerStormdrains.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerStormdrains.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerStormdrainExists checks the presence of a single record by primary key -func FieldseekerStormdrainExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerStormdrainExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerStormdrains.Query( sm.Where(FieldseekerStormdrains.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerStormdrains.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -576,11 +603,14 @@ func (o *FieldseekerStormdrain) AfterQueryHook(ctx context.Context, exec bob.Exe // primaryKeyVals returns the primary key values of the FieldseekerStormdrain func (o *FieldseekerStormdrain) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerStormdrain) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.stormdrain", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.stormdrain", "objectid"), psql.Quote("fieldseeker.stormdrain", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -607,6 +637,7 @@ func (o *FieldseekerStormdrain) Delete(ctx context.Context, exec bob.Executor) e func (o *FieldseekerStormdrain) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerStormdrains.Query( sm.Where(FieldseekerStormdrains.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerStormdrains.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -640,7 +671,7 @@ func (o FieldseekerStormdrainSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.stormdrain", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.stormdrain", "objectid"), psql.Quote("fieldseeker.stormdrain", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -658,6 +689,9 @@ func (o FieldseekerStormdrainSlice) copyMatchingRows(from ...*FieldseekerStormdr if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -776,6 +810,7 @@ type fieldseekerStormdrainWhere[Q psql.Filterable] struct { Editor psql.WhereNullMod[Q, string] Type psql.WhereNullMod[Q, string] Jurisdiction psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerStormdrainWhere[Q]) AliasedAs(alias string) fieldseekerStormdrainWhere[Q] { @@ -803,5 +838,6 @@ func buildFieldseekerStormdrainWhere[Q psql.Filterable](cols fieldseekerStormdra Editor: psql.WhereNull[Q, string](cols.Editor), Type: psql.WhereNull[Q, string](cols.Type), Jurisdiction: psql.WhereNull[Q, string](cols.Jurisdiction), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.timecard.bob.go b/db/models/fieldseeker.timecard.bob.go index c197088c..d05ca8e0 100644 --- a/db/models/fieldseeker.timecard.bob.go +++ b/db/models/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -61,6 +61,8 @@ type FieldseekerTimecard struct { Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` Rodentlocid null.Val[uuid.UUID] `db:"rodentlocid" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerTimecardSlice is an alias for a slice of pointers to FieldseekerTimecard. @@ -76,7 +78,7 @@ type FieldseekerTimecardsQuery = *psql.ViewQuery[*FieldseekerTimecard, Fieldseek func buildFieldseekerTimecardColumns(alias string) fieldseekerTimecardColumns { return fieldseekerTimecardColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "activity", "startdatetime", "enddatetime", "comments", "externalid", "equiptype", "locationname", "zone", "zone2", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "linelocid", "pointlocid", "polygonlocid", "lclocid", "samplelocid", "srid", "traplocid", "fieldtech", "creationdate", "creator", "editdate", "editor", "rodentlocid", + "objectid", "activity", "startdatetime", "enddatetime", "comments", "externalid", "equiptype", "locationname", "zone", "zone2", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "linelocid", "pointlocid", "polygonlocid", "lclocid", "samplelocid", "srid", "traplocid", "fieldtech", "creationdate", "creator", "editdate", "editor", "rodentlocid", "version", ).WithParent("fieldseeker.timecard"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -107,6 +109,7 @@ func buildFieldseekerTimecardColumns(alias string) fieldseekerTimecardColumns { Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), Rodentlocid: psql.Quote(alias, "rodentlocid"), + Version: psql.Quote(alias, "version"), } } @@ -141,6 +144,7 @@ type fieldseekerTimecardColumns struct { Editdate psql.Expression Editor psql.Expression Rodentlocid psql.Expression + Version psql.Expression } func (c fieldseekerTimecardColumns) Alias() string { @@ -183,10 +187,11 @@ type FieldseekerTimecardSetter struct { Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` Rodentlocid omitnull.Val[uuid.UUID] `db:"rodentlocid" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerTimecardSetter) SetColumns() []string { - vals := make([]string, 0, 28) + vals := make([]string, 0, 29) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -271,6 +276,9 @@ func (s FieldseekerTimecardSetter) SetColumns() []string { if !s.Rodentlocid.IsUnset() { vals = append(vals, "rodentlocid") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -359,6 +367,9 @@ func (s FieldseekerTimecardSetter) Overwrite(t *FieldseekerTimecard) { if !s.Rodentlocid.IsUnset() { t.Rodentlocid = s.Rodentlocid.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerTimecardSetter) Apply(q *dialect.InsertQuery) { @@ -367,7 +378,7 @@ func (s *FieldseekerTimecardSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 28) + vals := make([]bob.Expression, 29) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -536,6 +547,12 @@ func (s *FieldseekerTimecardSetter) Apply(q *dialect.InsertQuery) { vals[27] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[28] = psql.Arg(s.Version.MustGet()) + } else { + vals[28] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -545,7 +562,7 @@ func (s FieldseekerTimecardSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerTimecardSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 28) + exprs := make([]bob.Expression, 0, 29) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -743,28 +760,38 @@ func (s FieldseekerTimecardSetter) Expressions(prefix ...string) []bob.Expressio }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerTimecard retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerTimecard(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerTimecard, error) { +func FindFieldseekerTimecard(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerTimecard, error) { if len(cols) == 0 { return FieldseekerTimecards.Query( sm.Where(FieldseekerTimecards.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTimecards.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerTimecards.Query( sm.Where(FieldseekerTimecards.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTimecards.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerTimecards.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerTimecardExists checks the presence of a single record by primary key -func FieldseekerTimecardExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerTimecardExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerTimecards.Query( sm.Where(FieldseekerTimecards.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTimecards.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -788,11 +815,14 @@ func (o *FieldseekerTimecard) AfterQueryHook(ctx context.Context, exec bob.Execu // primaryKeyVals returns the primary key values of the FieldseekerTimecard func (o *FieldseekerTimecard) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerTimecard) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.timecard", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.timecard", "objectid"), psql.Quote("fieldseeker.timecard", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -819,6 +849,7 @@ func (o *FieldseekerTimecard) Delete(ctx context.Context, exec bob.Executor) err func (o *FieldseekerTimecard) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerTimecards.Query( sm.Where(FieldseekerTimecards.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerTimecards.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -852,7 +883,7 @@ func (o FieldseekerTimecardSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.timecard", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.timecard", "objectid"), psql.Quote("fieldseeker.timecard", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -870,6 +901,9 @@ func (o FieldseekerTimecardSlice) copyMatchingRows(from ...*FieldseekerTimecard) if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -997,6 +1031,7 @@ type fieldseekerTimecardWhere[Q psql.Filterable] struct { Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] Rodentlocid psql.WhereNullMod[Q, uuid.UUID] + Version psql.WhereMod[Q, int32] } func (fieldseekerTimecardWhere[Q]) AliasedAs(alias string) fieldseekerTimecardWhere[Q] { @@ -1033,5 +1068,6 @@ func buildFieldseekerTimecardWhere[Q psql.Filterable](cols fieldseekerTimecardCo Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), Rodentlocid: psql.WhereNull[Q, uuid.UUID](cols.Rodentlocid), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.tracklog.bob.go b/db/models/fieldseeker.tracklog.bob.go deleted file mode 100644 index 53854e99..00000000 --- a/db/models/fieldseeker.tracklog.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerTracklog is an object representing the database table. -type FieldseekerTracklog struct{} - -// FieldseekerTracklogSlice is an alias for a slice of pointers to FieldseekerTracklog. -// This should almost always be used instead of []*FieldseekerTracklog. -type FieldseekerTracklogSlice []*FieldseekerTracklog - -// FieldseekerTracklogs contains methods to work with the tracklog view -var FieldseekerTracklogs = psql.NewViewx[*FieldseekerTracklog, FieldseekerTracklogSlice]("fieldseeker", "tracklog", buildFieldseekerTracklogColumns("fieldseeker.tracklog")) - -// FieldseekerTracklogsQuery is a query on the tracklog view -type FieldseekerTracklogsQuery = *psql.ViewQuery[*FieldseekerTracklog, FieldseekerTracklogSlice] - -func buildFieldseekerTracklogColumns(alias string) fieldseekerTracklogColumns { - return fieldseekerTracklogColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.tracklog"), - tableAlias: alias, - } -} - -type fieldseekerTracklogColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerTracklogColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerTracklogColumns) AliasedAs(alias string) fieldseekerTracklogColumns { - return buildFieldseekerTracklogColumns(alias) -} - -// AfterQueryHook is called after FieldseekerTracklog is retrieved from the database -func (o *FieldseekerTracklog) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerTracklogs.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerTracklogSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerTracklogSlice is retrieved from the database -func (o FieldseekerTracklogSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerTracklogs.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerTracklogWhere[Q psql.Filterable] struct{} - -func (fieldseekerTracklogWhere[Q]) AliasedAs(alias string) fieldseekerTracklogWhere[Q] { - return buildFieldseekerTracklogWhere[Q](buildFieldseekerTracklogColumns(alias)) -} - -func buildFieldseekerTracklogWhere[Q psql.Filterable](cols fieldseekerTracklogColumns) fieldseekerTracklogWhere[Q] { - return fieldseekerTracklogWhere[Q]{} -} diff --git a/db/models/fieldseeker.trapdata.bob.go b/db/models/fieldseeker.trapdata.bob.go index a7e1fd8d..7c36a2f7 100644 --- a/db/models/fieldseeker.trapdata.bob.go +++ b/db/models/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -88,6 +88,8 @@ type FieldseekerTrapdatum struct { Editdate null.Val[time.Time] `db:"editdate" ` Editor null.Val[string] `db:"editor" ` Lure null.Val[enums.FieldseekerTrapdataTrapdataLure25fe542f077F4254868176e8f436354bEnu] `db:"lure" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerTrapdatumSlice is an alias for a slice of pointers to FieldseekerTrapdatum. @@ -103,7 +105,7 @@ type FieldseekerTrapdataQuery = *psql.ViewQuery[*FieldseekerTrapdatum, Fieldseek func buildFieldseekerTrapdatumColumns(alias string) fieldseekerTrapdatumColumns { return fieldseekerTrapdatumColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "traptype", "trapactivitytype", "startdatetime", "enddatetime", "comments", "idbytech", "sortbytech", "processed", "sitecond", "locationname", "recordstatus", "reviewed", "reviewedby", "revieweddate", "trapcondition", "trapnights", "zone", "zone2", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "srid", "fieldtech", "gatewaysync", "loc_id", "voltage", "winddir", "windspeed", "avetemp", "raingauge", "lr", "field", "vectorsurvtrapdataid", "vectorsurvtraplocationid", "creationdate", "creator", "editdate", "editor", "lure", + "objectid", "traptype", "trapactivitytype", "startdatetime", "enddatetime", "comments", "idbytech", "sortbytech", "processed", "sitecond", "locationname", "recordstatus", "reviewed", "reviewedby", "revieweddate", "trapcondition", "trapnights", "zone", "zone2", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "srid", "fieldtech", "gatewaysync", "loc_id", "voltage", "winddir", "windspeed", "avetemp", "raingauge", "lr", "field", "vectorsurvtrapdataid", "vectorsurvtraplocationid", "creationdate", "creator", "editdate", "editor", "lure", "version", ).WithParent("fieldseeker.trapdata"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -148,6 +150,7 @@ func buildFieldseekerTrapdatumColumns(alias string) fieldseekerTrapdatumColumns Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), Lure: psql.Quote(alias, "lure"), + Version: psql.Quote(alias, "version"), } } @@ -196,6 +199,7 @@ type fieldseekerTrapdatumColumns struct { Editdate psql.Expression Editor psql.Expression Lure psql.Expression + Version psql.Expression } func (c fieldseekerTrapdatumColumns) Alias() string { @@ -252,10 +256,11 @@ type FieldseekerTrapdatumSetter struct { Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` Lure omitnull.Val[enums.FieldseekerTrapdataTrapdataLure25fe542f077F4254868176e8f436354bEnu] `db:"lure" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerTrapdatumSetter) SetColumns() []string { - vals := make([]string, 0, 42) + vals := make([]string, 0, 43) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -382,6 +387,9 @@ func (s FieldseekerTrapdatumSetter) SetColumns() []string { if !s.Lure.IsUnset() { vals = append(vals, "lure") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -512,6 +520,9 @@ func (s FieldseekerTrapdatumSetter) Overwrite(t *FieldseekerTrapdatum) { if !s.Lure.IsUnset() { t.Lure = s.Lure.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerTrapdatumSetter) Apply(q *dialect.InsertQuery) { @@ -520,7 +531,7 @@ func (s *FieldseekerTrapdatumSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 42) + vals := make([]bob.Expression, 43) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -773,6 +784,12 @@ func (s *FieldseekerTrapdatumSetter) Apply(q *dialect.InsertQuery) { vals[41] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[42] = psql.Arg(s.Version.MustGet()) + } else { + vals[42] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -782,7 +799,7 @@ func (s FieldseekerTrapdatumSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerTrapdatumSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 42) + exprs := make([]bob.Expression, 0, 43) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1078,28 +1095,38 @@ func (s FieldseekerTrapdatumSetter) Expressions(prefix ...string) []bob.Expressi }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerTrapdatum retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerTrapdatum(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerTrapdatum, error) { +func FindFieldseekerTrapdatum(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerTrapdatum, error) { if len(cols) == 0 { return FieldseekerTrapdata.Query( sm.Where(FieldseekerTrapdata.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTrapdata.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerTrapdata.Query( sm.Where(FieldseekerTrapdata.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTrapdata.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerTrapdata.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerTrapdatumExists checks the presence of a single record by primary key -func FieldseekerTrapdatumExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerTrapdatumExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerTrapdata.Query( sm.Where(FieldseekerTrapdata.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTrapdata.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1123,11 +1150,14 @@ func (o *FieldseekerTrapdatum) AfterQueryHook(ctx context.Context, exec bob.Exec // primaryKeyVals returns the primary key values of the FieldseekerTrapdatum func (o *FieldseekerTrapdatum) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerTrapdatum) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.trapdata", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.trapdata", "objectid"), psql.Quote("fieldseeker.trapdata", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1154,6 +1184,7 @@ func (o *FieldseekerTrapdatum) Delete(ctx context.Context, exec bob.Executor) er func (o *FieldseekerTrapdatum) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerTrapdata.Query( sm.Where(FieldseekerTrapdata.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerTrapdata.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1187,7 +1218,7 @@ func (o FieldseekerTrapdatumSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.trapdata", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.trapdata", "objectid"), psql.Quote("fieldseeker.trapdata", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1205,6 +1236,9 @@ func (o FieldseekerTrapdatumSlice) copyMatchingRows(from ...*FieldseekerTrapdatu if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1346,6 +1380,7 @@ type fieldseekerTrapdatumWhere[Q psql.Filterable] struct { Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] Lure psql.WhereNullMod[Q, enums.FieldseekerTrapdataTrapdataLure25fe542f077F4254868176e8f436354bEnu] + Version psql.WhereMod[Q, int32] } func (fieldseekerTrapdatumWhere[Q]) AliasedAs(alias string) fieldseekerTrapdatumWhere[Q] { @@ -1396,5 +1431,6 @@ func buildFieldseekerTrapdatumWhere[Q psql.Filterable](cols fieldseekerTrapdatum Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), Lure: psql.WhereNull[Q, enums.FieldseekerTrapdataTrapdataLure25fe542f077F4254868176e8f436354bEnu](cols.Lure), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.traplocation.bob.go b/db/models/fieldseeker.traplocation.bob.go index d6830f38..ff5a3198 100644 --- a/db/models/fieldseeker.traplocation.bob.go +++ b/db/models/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -70,6 +70,8 @@ type FieldseekerTraplocation struct { Editor null.Val[string] `db:"editor" ` H3R7 null.Val[string] `db:"h3r7" ` H3R8 null.Val[string] `db:"h3r8" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerTraplocationSlice is an alias for a slice of pointers to FieldseekerTraplocation. @@ -85,7 +87,7 @@ type FieldseekerTraplocationsQuery = *psql.ViewQuery[*FieldseekerTraplocation, F func buildFieldseekerTraplocationColumns(alias string) fieldseekerTraplocationColumns { return fieldseekerTraplocationColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "externalid", "nextactiondatescheduled", "zone2", "locationnumber", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "gatewaysync", "route", "set_dow", "route_order", "vectorsurvsiteid", "creationdate", "creator", "editdate", "editor", "h3r7", "h3r8", + "objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "externalid", "nextactiondatescheduled", "zone2", "locationnumber", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "gatewaysync", "route", "set_dow", "route_order", "vectorsurvsiteid", "creationdate", "creator", "editdate", "editor", "h3r7", "h3r8", "version", ).WithParent("fieldseeker.traplocation"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -118,6 +120,7 @@ func buildFieldseekerTraplocationColumns(alias string) fieldseekerTraplocationCo Editor: psql.Quote(alias, "editor"), H3R7: psql.Quote(alias, "h3r7"), H3R8: psql.Quote(alias, "h3r8"), + Version: psql.Quote(alias, "version"), } } @@ -154,6 +157,7 @@ type fieldseekerTraplocationColumns struct { Editor psql.Expression H3R7 psql.Expression H3R8 psql.Expression + Version psql.Expression } func (c fieldseekerTraplocationColumns) Alias() string { @@ -198,10 +202,11 @@ type FieldseekerTraplocationSetter struct { Editor omitnull.Val[string] `db:"editor" ` H3R7 omitnull.Val[string] `db:"h3r7" ` H3R8 omitnull.Val[string] `db:"h3r8" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerTraplocationSetter) SetColumns() []string { - vals := make([]string, 0, 30) + vals := make([]string, 0, 31) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -292,6 +297,9 @@ func (s FieldseekerTraplocationSetter) SetColumns() []string { if !s.H3R8.IsUnset() { vals = append(vals, "h3r8") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -386,6 +394,9 @@ func (s FieldseekerTraplocationSetter) Overwrite(t *FieldseekerTraplocation) { if !s.H3R8.IsUnset() { t.H3R8 = s.H3R8.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerTraplocationSetter) Apply(q *dialect.InsertQuery) { @@ -394,7 +405,7 @@ func (s *FieldseekerTraplocationSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 30) + vals := make([]bob.Expression, 31) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -575,6 +586,12 @@ func (s *FieldseekerTraplocationSetter) Apply(q *dialect.InsertQuery) { vals[29] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[30] = psql.Arg(s.Version.MustGet()) + } else { + vals[30] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -584,7 +601,7 @@ func (s FieldseekerTraplocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] } func (s FieldseekerTraplocationSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 30) + exprs := make([]bob.Expression, 0, 31) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -796,28 +813,38 @@ func (s FieldseekerTraplocationSetter) Expressions(prefix ...string) []bob.Expre }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerTraplocation retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerTraplocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerTraplocation, error) { +func FindFieldseekerTraplocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerTraplocation, error) { if len(cols) == 0 { return FieldseekerTraplocations.Query( sm.Where(FieldseekerTraplocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTraplocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerTraplocations.Query( sm.Where(FieldseekerTraplocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTraplocations.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerTraplocations.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerTraplocationExists checks the presence of a single record by primary key -func FieldseekerTraplocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerTraplocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerTraplocations.Query( sm.Where(FieldseekerTraplocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTraplocations.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -841,11 +868,14 @@ func (o *FieldseekerTraplocation) AfterQueryHook(ctx context.Context, exec bob.E // primaryKeyVals returns the primary key values of the FieldseekerTraplocation func (o *FieldseekerTraplocation) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerTraplocation) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.traplocation", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.traplocation", "objectid"), psql.Quote("fieldseeker.traplocation", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -872,6 +902,7 @@ func (o *FieldseekerTraplocation) Delete(ctx context.Context, exec bob.Executor) func (o *FieldseekerTraplocation) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerTraplocations.Query( sm.Where(FieldseekerTraplocations.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerTraplocations.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -905,7 +936,7 @@ func (o FieldseekerTraplocationSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.traplocation", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.traplocation", "objectid"), psql.Quote("fieldseeker.traplocation", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -923,6 +954,9 @@ func (o FieldseekerTraplocationSlice) copyMatchingRows(from ...*FieldseekerTrapl if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1052,6 +1086,7 @@ type fieldseekerTraplocationWhere[Q psql.Filterable] struct { Editor psql.WhereNullMod[Q, string] H3R7 psql.WhereNullMod[Q, string] H3R8 psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerTraplocationWhere[Q]) AliasedAs(alias string) fieldseekerTraplocationWhere[Q] { @@ -1090,5 +1125,6 @@ func buildFieldseekerTraplocationWhere[Q psql.Filterable](cols fieldseekerTraplo Editor: psql.WhereNull[Q, string](cols.Editor), H3R7: psql.WhereNull[Q, string](cols.H3R7), H3R8: psql.WhereNull[Q, string](cols.H3R8), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.treatment.bob.go b/db/models/fieldseeker.treatment.bob.go index b5ef655d..b4df3ba8 100644 --- a/db/models/fieldseeker.treatment.bob.go +++ b/db/models/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -116,6 +116,8 @@ type FieldseekerTreatment struct { Editor null.Val[string] `db:"editor" ` // Target Species Targetspecies null.Val[string] `db:"targetspecies" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerTreatmentSlice is an alias for a slice of pointers to FieldseekerTreatment. @@ -131,7 +133,7 @@ type FieldseekerTreatmentsQuery = *psql.ViewQuery[*FieldseekerTreatment, Fieldse func buildFieldseekerTreatmentColumns(alias string) fieldseekerTreatmentColumns { return fieldseekerTreatmentColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "activity", "treatarea", "areaunit", "product", "qty", "qtyunit", "method", "equiptype", "comments", "avetemp", "windspeed", "winddir", "raingauge", "startdatetime", "enddatetime", "insp_id", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "warningoverride", "recordstatus", "zone2", "treatacres", "tirecount", "cbcount", "containercount", "globalid", "treatmentlength", "treatmenthours", "treatmentlengthunits", "linelocid", "pointlocid", "polygonlocid", "srid", "sdid", "barrierrouteid", "ulvrouteid", "fieldtech", "ptaid", "flowrate", "habitat", "treathectares", "invloc", "temp_sitecond", "sitecond", "totalcostprodcut", "creationdate", "creator", "editdate", "editor", "targetspecies", + "objectid", "activity", "treatarea", "areaunit", "product", "qty", "qtyunit", "method", "equiptype", "comments", "avetemp", "windspeed", "winddir", "raingauge", "startdatetime", "enddatetime", "insp_id", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "warningoverride", "recordstatus", "zone2", "treatacres", "tirecount", "cbcount", "containercount", "globalid", "treatmentlength", "treatmenthours", "treatmentlengthunits", "linelocid", "pointlocid", "polygonlocid", "srid", "sdid", "barrierrouteid", "ulvrouteid", "fieldtech", "ptaid", "flowrate", "habitat", "treathectares", "invloc", "temp_sitecond", "sitecond", "totalcostprodcut", "creationdate", "creator", "editdate", "editor", "targetspecies", "version", ).WithParent("fieldseeker.treatment"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -188,6 +190,7 @@ func buildFieldseekerTreatmentColumns(alias string) fieldseekerTreatmentColumns Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), Targetspecies: psql.Quote(alias, "targetspecies"), + Version: psql.Quote(alias, "version"), } } @@ -248,6 +251,7 @@ type fieldseekerTreatmentColumns struct { Editdate psql.Expression Editor psql.Expression Targetspecies psql.Expression + Version psql.Expression } func (c fieldseekerTreatmentColumns) Alias() string { @@ -316,10 +320,11 @@ type FieldseekerTreatmentSetter struct { Editdate omitnull.Val[time.Time] `db:"editdate" ` Editor omitnull.Val[string] `db:"editor" ` Targetspecies omitnull.Val[string] `db:"targetspecies" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerTreatmentSetter) SetColumns() []string { - vals := make([]string, 0, 54) + vals := make([]string, 0, 55) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -482,6 +487,9 @@ func (s FieldseekerTreatmentSetter) SetColumns() []string { if !s.Targetspecies.IsUnset() { vals = append(vals, "targetspecies") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -648,6 +656,9 @@ func (s FieldseekerTreatmentSetter) Overwrite(t *FieldseekerTreatment) { if !s.Targetspecies.IsUnset() { t.Targetspecies = s.Targetspecies.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerTreatmentSetter) Apply(q *dialect.InsertQuery) { @@ -656,7 +667,7 @@ func (s *FieldseekerTreatmentSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 54) + vals := make([]bob.Expression, 55) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -981,6 +992,12 @@ func (s *FieldseekerTreatmentSetter) Apply(q *dialect.InsertQuery) { vals[53] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[54] = psql.Arg(s.Version.MustGet()) + } else { + vals[54] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -990,7 +1007,7 @@ func (s FieldseekerTreatmentSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerTreatmentSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 54) + exprs := make([]bob.Expression, 0, 55) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -1370,28 +1387,38 @@ func (s FieldseekerTreatmentSetter) Expressions(prefix ...string) []bob.Expressi }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerTreatment retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerTreatment(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerTreatment, error) { +func FindFieldseekerTreatment(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerTreatment, error) { if len(cols) == 0 { return FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerTreatments.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerTreatmentExists checks the presence of a single record by primary key -func FieldseekerTreatmentExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerTreatmentExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -1415,11 +1442,14 @@ func (o *FieldseekerTreatment) AfterQueryHook(ctx context.Context, exec bob.Exec // primaryKeyVals returns the primary key values of the FieldseekerTreatment func (o *FieldseekerTreatment) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerTreatment) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.treatment", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.treatment", "objectid"), psql.Quote("fieldseeker.treatment", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -1446,6 +1476,7 @@ func (o *FieldseekerTreatment) Delete(ctx context.Context, exec bob.Executor) er func (o *FieldseekerTreatment) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -1479,7 +1510,7 @@ func (o FieldseekerTreatmentSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.treatment", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.treatment", "objectid"), psql.Quote("fieldseeker.treatment", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -1497,6 +1528,9 @@ func (o FieldseekerTreatmentSlice) copyMatchingRows(from ...*FieldseekerTreatmen if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -1650,6 +1684,7 @@ type fieldseekerTreatmentWhere[Q psql.Filterable] struct { Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] Targetspecies psql.WhereNullMod[Q, string] + Version psql.WhereMod[Q, int32] } func (fieldseekerTreatmentWhere[Q]) AliasedAs(alias string) fieldseekerTreatmentWhere[Q] { @@ -1712,5 +1747,6 @@ func buildFieldseekerTreatmentWhere[Q psql.Filterable](cols fieldseekerTreatment Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), Targetspecies: psql.WhereNull[Q, string](cols.Targetspecies), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.treatmentarea.bob.go b/db/models/fieldseeker.treatmentarea.bob.go index c7734024..23155680 100644 --- a/db/models/fieldseeker.treatmentarea.bob.go +++ b/db/models/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -42,6 +42,8 @@ type FieldseekerTreatmentarea struct { Editor null.Val[string] `db:"editor" ` ShapeArea null.Val[float64] `db:"shape__area" ` ShapeLength null.Val[float64] `db:"shape__length" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerTreatmentareaSlice is an alias for a slice of pointers to FieldseekerTreatmentarea. @@ -57,7 +59,7 @@ type FieldseekerTreatmentareasQuery = *psql.ViewQuery[*FieldseekerTreatmentarea, func buildFieldseekerTreatmentareaColumns(alias string) fieldseekerTreatmentareaColumns { return fieldseekerTreatmentareaColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "treat_id", "session_id", "treatdate", "comments", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "notified", "type", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length", + "objectid", "treat_id", "session_id", "treatdate", "comments", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "notified", "type", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length", "version", ).WithParent("fieldseeker.treatmentarea"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -78,6 +80,7 @@ func buildFieldseekerTreatmentareaColumns(alias string) fieldseekerTreatmentarea Editor: psql.Quote(alias, "editor"), ShapeArea: psql.Quote(alias, "shape__area"), ShapeLength: psql.Quote(alias, "shape__length"), + Version: psql.Quote(alias, "version"), } } @@ -102,6 +105,7 @@ type fieldseekerTreatmentareaColumns struct { Editor psql.Expression ShapeArea psql.Expression ShapeLength psql.Expression + Version psql.Expression } func (c fieldseekerTreatmentareaColumns) Alias() string { @@ -134,10 +138,11 @@ type FieldseekerTreatmentareaSetter struct { Editor omitnull.Val[string] `db:"editor" ` ShapeArea omitnull.Val[float64] `db:"shape__area" ` ShapeLength omitnull.Val[float64] `db:"shape__length" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerTreatmentareaSetter) SetColumns() []string { - vals := make([]string, 0, 18) + vals := make([]string, 0, 19) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -192,6 +197,9 @@ func (s FieldseekerTreatmentareaSetter) SetColumns() []string { if !s.ShapeLength.IsUnset() { vals = append(vals, "shape__length") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -250,6 +258,9 @@ func (s FieldseekerTreatmentareaSetter) Overwrite(t *FieldseekerTreatmentarea) { if !s.ShapeLength.IsUnset() { t.ShapeLength = s.ShapeLength.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerTreatmentareaSetter) Apply(q *dialect.InsertQuery) { @@ -258,7 +269,7 @@ func (s *FieldseekerTreatmentareaSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 18) + vals := make([]bob.Expression, 19) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -367,6 +378,12 @@ func (s *FieldseekerTreatmentareaSetter) Apply(q *dialect.InsertQuery) { vals[17] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[18] = psql.Arg(s.Version.MustGet()) + } else { + vals[18] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -376,7 +393,7 @@ func (s FieldseekerTreatmentareaSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery } func (s FieldseekerTreatmentareaSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 18) + exprs := make([]bob.Expression, 0, 19) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -504,28 +521,38 @@ func (s FieldseekerTreatmentareaSetter) Expressions(prefix ...string) []bob.Expr }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerTreatmentarea retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerTreatmentarea(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerTreatmentarea, error) { +func FindFieldseekerTreatmentarea(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerTreatmentarea, error) { if len(cols) == 0 { return FieldseekerTreatmentareas.Query( sm.Where(FieldseekerTreatmentareas.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTreatmentareas.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerTreatmentareas.Query( sm.Where(FieldseekerTreatmentareas.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTreatmentareas.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerTreatmentareas.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerTreatmentareaExists checks the presence of a single record by primary key -func FieldseekerTreatmentareaExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerTreatmentareaExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerTreatmentareas.Query( sm.Where(FieldseekerTreatmentareas.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerTreatmentareas.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -549,11 +576,14 @@ func (o *FieldseekerTreatmentarea) AfterQueryHook(ctx context.Context, exec bob. // primaryKeyVals returns the primary key values of the FieldseekerTreatmentarea func (o *FieldseekerTreatmentarea) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerTreatmentarea) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.treatmentarea", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.treatmentarea", "objectid"), psql.Quote("fieldseeker.treatmentarea", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -580,6 +610,7 @@ func (o *FieldseekerTreatmentarea) Delete(ctx context.Context, exec bob.Executor func (o *FieldseekerTreatmentarea) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerTreatmentareas.Query( sm.Where(FieldseekerTreatmentareas.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerTreatmentareas.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -613,7 +644,7 @@ func (o FieldseekerTreatmentareaSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.treatmentarea", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.treatmentarea", "objectid"), psql.Quote("fieldseeker.treatmentarea", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -631,6 +662,9 @@ func (o FieldseekerTreatmentareaSlice) copyMatchingRows(from ...*FieldseekerTrea if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -748,6 +782,7 @@ type fieldseekerTreatmentareaWhere[Q psql.Filterable] struct { Editor psql.WhereNullMod[Q, string] ShapeArea psql.WhereNullMod[Q, float64] ShapeLength psql.WhereNullMod[Q, float64] + Version psql.WhereMod[Q, int32] } func (fieldseekerTreatmentareaWhere[Q]) AliasedAs(alias string) fieldseekerTreatmentareaWhere[Q] { @@ -774,5 +809,6 @@ func buildFieldseekerTreatmentareaWhere[Q psql.Filterable](cols fieldseekerTreat Editor: psql.WhereNull[Q, string](cols.Editor), ShapeArea: psql.WhereNull[Q, float64](cols.ShapeArea), ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.ulvsprayroute.bob.go b/db/models/fieldseeker.ulvsprayroute.bob.go deleted file mode 100644 index 9dc64a19..00000000 --- a/db/models/fieldseeker.ulvsprayroute.bob.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/expr" -) - -// FieldseekerUlvsprayroute is an object representing the database table. -type FieldseekerUlvsprayroute struct{} - -// FieldseekerUlvsprayrouteSlice is an alias for a slice of pointers to FieldseekerUlvsprayroute. -// This should almost always be used instead of []*FieldseekerUlvsprayroute. -type FieldseekerUlvsprayrouteSlice []*FieldseekerUlvsprayroute - -// FieldseekerUlvsprayroutes contains methods to work with the ulvsprayroute view -var FieldseekerUlvsprayroutes = psql.NewViewx[*FieldseekerUlvsprayroute, FieldseekerUlvsprayrouteSlice]("fieldseeker", "ulvsprayroute", buildFieldseekerUlvsprayrouteColumns("fieldseeker.ulvsprayroute")) - -// FieldseekerUlvsprayroutesQuery is a query on the ulvsprayroute view -type FieldseekerUlvsprayroutesQuery = *psql.ViewQuery[*FieldseekerUlvsprayroute, FieldseekerUlvsprayrouteSlice] - -func buildFieldseekerUlvsprayrouteColumns(alias string) fieldseekerUlvsprayrouteColumns { - return fieldseekerUlvsprayrouteColumns{ - ColumnsExpr: expr.NewColumnsExpr().WithParent("fieldseeker.ulvsprayroute"), - tableAlias: alias, - } -} - -type fieldseekerUlvsprayrouteColumns struct { - expr.ColumnsExpr - tableAlias string -} - -func (c fieldseekerUlvsprayrouteColumns) Alias() string { - return c.tableAlias -} - -func (fieldseekerUlvsprayrouteColumns) AliasedAs(alias string) fieldseekerUlvsprayrouteColumns { - return buildFieldseekerUlvsprayrouteColumns(alias) -} - -// AfterQueryHook is called after FieldseekerUlvsprayroute is retrieved from the database -func (o *FieldseekerUlvsprayroute) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerUlvsprayroutes.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerUlvsprayrouteSlice{o}) - } - - return err -} - -// AfterQueryHook is called after FieldseekerUlvsprayrouteSlice is retrieved from the database -func (o FieldseekerUlvsprayrouteSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = FieldseekerUlvsprayroutes.AfterSelectHooks.RunHooks(ctx, exec, o) - } - - return err -} - -type fieldseekerUlvsprayrouteWhere[Q psql.Filterable] struct{} - -func (fieldseekerUlvsprayrouteWhere[Q]) AliasedAs(alias string) fieldseekerUlvsprayrouteWhere[Q] { - return buildFieldseekerUlvsprayrouteWhere[Q](buildFieldseekerUlvsprayrouteColumns(alias)) -} - -func buildFieldseekerUlvsprayrouteWhere[Q psql.Filterable](cols fieldseekerUlvsprayrouteColumns) fieldseekerUlvsprayrouteWhere[Q] { - return fieldseekerUlvsprayrouteWhere[Q]{} -} diff --git a/db/models/fieldseeker.zones.bob.go b/db/models/fieldseeker.zones.bob.go index ead86336..f586dee3 100644 --- a/db/models/fieldseeker.zones.bob.go +++ b/db/models/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -38,6 +38,8 @@ type FieldseekerZone struct { Editor null.Val[string] `db:"editor" ` ShapeArea null.Val[float64] `db:"shape__area" ` ShapeLength null.Val[float64] `db:"shape__length" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerZoneSlice is an alias for a slice of pointers to FieldseekerZone. @@ -53,7 +55,7 @@ type FieldseekerZonesQuery = *psql.ViewQuery[*FieldseekerZone, FieldseekerZoneSl func buildFieldseekerZoneColumns(alias string) fieldseekerZoneColumns { return fieldseekerZoneColumns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "name", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "active", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length", + "objectid", "name", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "active", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length", "version", ).WithParent("fieldseeker.zones"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -70,6 +72,7 @@ func buildFieldseekerZoneColumns(alias string) fieldseekerZoneColumns { Editor: psql.Quote(alias, "editor"), ShapeArea: psql.Quote(alias, "shape__area"), ShapeLength: psql.Quote(alias, "shape__length"), + Version: psql.Quote(alias, "version"), } } @@ -90,6 +93,7 @@ type fieldseekerZoneColumns struct { Editor psql.Expression ShapeArea psql.Expression ShapeLength psql.Expression + Version psql.Expression } func (c fieldseekerZoneColumns) Alias() string { @@ -118,10 +122,11 @@ type FieldseekerZoneSetter struct { Editor omitnull.Val[string] `db:"editor" ` ShapeArea omitnull.Val[float64] `db:"shape__area" ` ShapeLength omitnull.Val[float64] `db:"shape__length" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerZoneSetter) SetColumns() []string { - vals := make([]string, 0, 14) + vals := make([]string, 0, 15) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -164,6 +169,9 @@ func (s FieldseekerZoneSetter) SetColumns() []string { if !s.ShapeLength.IsUnset() { vals = append(vals, "shape__length") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -210,6 +218,9 @@ func (s FieldseekerZoneSetter) Overwrite(t *FieldseekerZone) { if !s.ShapeLength.IsUnset() { t.ShapeLength = s.ShapeLength.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerZoneSetter) Apply(q *dialect.InsertQuery) { @@ -218,7 +229,7 @@ func (s *FieldseekerZoneSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 14) + vals := make([]bob.Expression, 15) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -303,6 +314,12 @@ func (s *FieldseekerZoneSetter) Apply(q *dialect.InsertQuery) { vals[13] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[14] = psql.Arg(s.Version.MustGet()) + } else { + vals[14] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -312,7 +329,7 @@ func (s FieldseekerZoneSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerZoneSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 14) + exprs := make([]bob.Expression, 0, 15) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -412,28 +429,38 @@ func (s FieldseekerZoneSetter) Expressions(prefix ...string) []bob.Expression { }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerZone retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerZone(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerZone, error) { +func FindFieldseekerZone(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerZone, error) { if len(cols) == 0 { return FieldseekerZones.Query( sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerZones.Query( sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerZones.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerZoneExists checks the presence of a single record by primary key -func FieldseekerZoneExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerZoneExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerZones.Query( sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -457,11 +484,14 @@ func (o *FieldseekerZone) AfterQueryHook(ctx context.Context, exec bob.Executor, // primaryKeyVals returns the primary key values of the FieldseekerZone func (o *FieldseekerZone) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerZone) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.zones", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.zones", "objectid"), psql.Quote("fieldseeker.zones", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -488,6 +518,7 @@ func (o *FieldseekerZone) Delete(ctx context.Context, exec bob.Executor) error { func (o *FieldseekerZone) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerZones.Query( sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -521,7 +552,7 @@ func (o FieldseekerZoneSlice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.zones", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.zones", "objectid"), psql.Quote("fieldseeker.zones", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -539,6 +570,9 @@ func (o FieldseekerZoneSlice) copyMatchingRows(from ...*FieldseekerZone) { if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -652,6 +686,7 @@ type fieldseekerZoneWhere[Q psql.Filterable] struct { Editor psql.WhereNullMod[Q, string] ShapeArea psql.WhereNullMod[Q, float64] ShapeLength psql.WhereNullMod[Q, float64] + Version psql.WhereMod[Q, int32] } func (fieldseekerZoneWhere[Q]) AliasedAs(alias string) fieldseekerZoneWhere[Q] { @@ -674,5 +709,6 @@ func buildFieldseekerZoneWhere[Q psql.Filterable](cols fieldseekerZoneColumns) f Editor: psql.WhereNull[Q, string](cols.Editor), ShapeArea: psql.WhereNull[Q, float64](cols.ShapeArea), ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker.zones2.bob.go b/db/models/fieldseeker.zones2.bob.go index 33e958d5..a36ccb87 100644 --- a/db/models/fieldseeker.zones2.bob.go +++ b/db/models/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -37,6 +37,8 @@ type FieldseekerZones2 struct { Editor null.Val[string] `db:"editor" ` ShapeArea null.Val[float64] `db:"shape__area" ` ShapeLength null.Val[float64] `db:"shape__length" ` + // Tracks version changes to the row. Increases when data is modified. + Version int32 `db:"version,pk" ` } // FieldseekerZones2Slice is an alias for a slice of pointers to FieldseekerZones2. @@ -52,7 +54,7 @@ type FieldseekerZones2sQuery = *psql.ViewQuery[*FieldseekerZones2, FieldseekerZo func buildFieldseekerZones2Columns(alias string) fieldseekerZones2Columns { return fieldseekerZones2Columns{ ColumnsExpr: expr.NewColumnsExpr( - "objectid", "name", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length", + "objectid", "name", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length", "version", ).WithParent("fieldseeker.zones2"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), @@ -68,6 +70,7 @@ func buildFieldseekerZones2Columns(alias string) fieldseekerZones2Columns { Editor: psql.Quote(alias, "editor"), ShapeArea: psql.Quote(alias, "shape__area"), ShapeLength: psql.Quote(alias, "shape__length"), + Version: psql.Quote(alias, "version"), } } @@ -87,6 +90,7 @@ type fieldseekerZones2Columns struct { Editor psql.Expression ShapeArea psql.Expression ShapeLength psql.Expression + Version psql.Expression } func (c fieldseekerZones2Columns) Alias() string { @@ -114,10 +118,11 @@ type FieldseekerZones2Setter struct { Editor omitnull.Val[string] `db:"editor" ` ShapeArea omitnull.Val[float64] `db:"shape__area" ` ShapeLength omitnull.Val[float64] `db:"shape__length" ` + Version omit.Val[int32] `db:"version,pk" ` } func (s FieldseekerZones2Setter) SetColumns() []string { - vals := make([]string, 0, 13) + vals := make([]string, 0, 14) if s.Objectid.IsValue() { vals = append(vals, "objectid") } @@ -157,6 +162,9 @@ func (s FieldseekerZones2Setter) SetColumns() []string { if !s.ShapeLength.IsUnset() { vals = append(vals, "shape__length") } + if s.Version.IsValue() { + vals = append(vals, "version") + } return vals } @@ -200,6 +208,9 @@ func (s FieldseekerZones2Setter) Overwrite(t *FieldseekerZones2) { if !s.ShapeLength.IsUnset() { t.ShapeLength = s.ShapeLength.MustGetNull() } + if s.Version.IsValue() { + t.Version = s.Version.MustGet() + } } func (s *FieldseekerZones2Setter) Apply(q *dialect.InsertQuery) { @@ -208,7 +219,7 @@ func (s *FieldseekerZones2Setter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 13) + vals := make([]bob.Expression, 14) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { @@ -287,6 +298,12 @@ func (s *FieldseekerZones2Setter) Apply(q *dialect.InsertQuery) { vals[12] = psql.Raw("DEFAULT") } + if s.Version.IsValue() { + vals[13] = psql.Arg(s.Version.MustGet()) + } else { + vals[13] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -296,7 +313,7 @@ func (s FieldseekerZones2Setter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s FieldseekerZones2Setter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 13) + exprs := make([]bob.Expression, 0, 14) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -389,28 +406,38 @@ func (s FieldseekerZones2Setter) Expressions(prefix ...string) []bob.Expression }}) } + if s.Version.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "version")...), + psql.Arg(s.Version), + }}) + } + return exprs } // FindFieldseekerZones2 retrieves a single record by primary key // If cols is empty Find will return all columns. -func FindFieldseekerZones2(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerZones2, error) { +func FindFieldseekerZones2(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerZones2, error) { if len(cols) == 0 { return FieldseekerZones2s.Query( sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerZones2s.Query( sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerZones2s.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerZones2Exists checks the presence of a single record by primary key -func FieldseekerZones2Exists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) { +func FieldseekerZones2Exists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerZones2s.Query( sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), + sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } @@ -434,11 +461,14 @@ func (o *FieldseekerZones2) AfterQueryHook(ctx context.Context, exec bob.Executo // primaryKeyVals returns the primary key values of the FieldseekerZones2 func (o *FieldseekerZones2) primaryKeyVals() bob.Expression { - return psql.Arg(o.Objectid) + return psql.ArgGroup( + o.Objectid, + o.Version, + ) } func (o *FieldseekerZones2) pkEQ() dialect.Expression { - return psql.Quote("fieldseeker.zones2", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.zones2", "objectid"), psql.Quote("fieldseeker.zones2", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } @@ -465,6 +495,7 @@ func (o *FieldseekerZones2) Delete(ctx context.Context, exec bob.Executor) error func (o *FieldseekerZones2) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerZones2s.Query( sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(o.Objectid))), + sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err @@ -498,7 +529,7 @@ func (o FieldseekerZones2Slice) pkIN() dialect.Expression { return psql.Raw("NULL") } - return psql.Quote("fieldseeker.zones2", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return psql.Group(psql.Quote("fieldseeker.zones2", "objectid"), psql.Quote("fieldseeker.zones2", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() @@ -516,6 +547,9 @@ func (o FieldseekerZones2Slice) copyMatchingRows(from ...*FieldseekerZones2) { if new.Objectid != old.Objectid { continue } + if new.Version != old.Version { + continue + } o[i] = new break @@ -628,6 +662,7 @@ type fieldseekerZones2Where[Q psql.Filterable] struct { Editor psql.WhereNullMod[Q, string] ShapeArea psql.WhereNullMod[Q, float64] ShapeLength psql.WhereNullMod[Q, float64] + Version psql.WhereMod[Q, int32] } func (fieldseekerZones2Where[Q]) AliasedAs(alias string) fieldseekerZones2Where[Q] { @@ -649,5 +684,6 @@ func buildFieldseekerZones2Where[Q psql.Filterable](cols fieldseekerZones2Column Editor: psql.WhereNull[Q, string](cols.Editor), ShapeArea: psql.WhereNull[Q, float64](cols.ShapeArea), ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength), + Version: psql.Where[Q, int32](cols.Version), } } diff --git a/db/models/fieldseeker_sync.bob.go b/db/models/fieldseeker_sync.bob.go index 0cdf120c..2063ab7d 100644 --- a/db/models/fieldseeker_sync.bob.go +++ b/db/models/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_containerrelate.bob.go b/db/models/fs_containerrelate.bob.go index f1daebe0..ab23d1a2 100644 --- a/db/models/fs_containerrelate.bob.go +++ b/db/models/fs_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_fieldscoutinglog.bob.go b/db/models/fs_fieldscoutinglog.bob.go index d42322e8..437d98ff 100644 --- a/db/models/fs_fieldscoutinglog.bob.go +++ b/db/models/fs_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_habitatrelate.bob.go b/db/models/fs_habitatrelate.bob.go index e628ab8f..c123cf0b 100644 --- a/db/models/fs_habitatrelate.bob.go +++ b/db/models/fs_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_inspectionsample.bob.go b/db/models/fs_inspectionsample.bob.go index fd918686..3fb5b008 100644 --- a/db/models/fs_inspectionsample.bob.go +++ b/db/models/fs_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_inspectionsampledetail.bob.go b/db/models/fs_inspectionsampledetail.bob.go index d7498766..fadd942d 100644 --- a/db/models/fs_inspectionsampledetail.bob.go +++ b/db/models/fs_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_linelocation.bob.go b/db/models/fs_linelocation.bob.go index 42b99c5d..c3dff36f 100644 --- a/db/models/fs_linelocation.bob.go +++ b/db/models/fs_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_locationtracking.bob.go b/db/models/fs_locationtracking.bob.go index 8c1fc886..d5f72a45 100644 --- a/db/models/fs_locationtracking.bob.go +++ b/db/models/fs_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_mosquitoinspection.bob.go b/db/models/fs_mosquitoinspection.bob.go index ed5830af..ee5edd1f 100644 --- a/db/models/fs_mosquitoinspection.bob.go +++ b/db/models/fs_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_pointlocation.bob.go b/db/models/fs_pointlocation.bob.go index 2e811f85..85166e2a 100644 --- a/db/models/fs_pointlocation.bob.go +++ b/db/models/fs_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_polygonlocation.bob.go b/db/models/fs_polygonlocation.bob.go index 459701d0..75971afe 100644 --- a/db/models/fs_polygonlocation.bob.go +++ b/db/models/fs_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_pool.bob.go b/db/models/fs_pool.bob.go index 9c43587d..a633cf4d 100644 --- a/db/models/fs_pool.bob.go +++ b/db/models/fs_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_pooldetail.bob.go b/db/models/fs_pooldetail.bob.go index e2f27615..7a23d1da 100644 --- a/db/models/fs_pooldetail.bob.go +++ b/db/models/fs_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_proposedtreatmentarea.bob.go b/db/models/fs_proposedtreatmentarea.bob.go index 793c406d..0a7da9a9 100644 --- a/db/models/fs_proposedtreatmentarea.bob.go +++ b/db/models/fs_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_qamosquitoinspection.bob.go b/db/models/fs_qamosquitoinspection.bob.go index bb4ea43f..5e9ab024 100644 --- a/db/models/fs_qamosquitoinspection.bob.go +++ b/db/models/fs_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_rodentlocation.bob.go b/db/models/fs_rodentlocation.bob.go index 0173520f..c60f1b50 100644 --- a/db/models/fs_rodentlocation.bob.go +++ b/db/models/fs_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_samplecollection.bob.go b/db/models/fs_samplecollection.bob.go index df590e93..e7a5bcf8 100644 --- a/db/models/fs_samplecollection.bob.go +++ b/db/models/fs_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_samplelocation.bob.go b/db/models/fs_samplelocation.bob.go index 6a37a170..ab6d7acc 100644 --- a/db/models/fs_samplelocation.bob.go +++ b/db/models/fs_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_servicerequest.bob.go b/db/models/fs_servicerequest.bob.go index 48cbc026..95ae51cf 100644 --- a/db/models/fs_servicerequest.bob.go +++ b/db/models/fs_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_speciesabundance.bob.go b/db/models/fs_speciesabundance.bob.go index a8d29eb5..b8ce2c74 100644 --- a/db/models/fs_speciesabundance.bob.go +++ b/db/models/fs_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_stormdrain.bob.go b/db/models/fs_stormdrain.bob.go index dfa2a8ec..f1e37b84 100644 --- a/db/models/fs_stormdrain.bob.go +++ b/db/models/fs_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_timecard.bob.go b/db/models/fs_timecard.bob.go index 2d375344..4230a2fc 100644 --- a/db/models/fs_timecard.bob.go +++ b/db/models/fs_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_trapdata.bob.go b/db/models/fs_trapdata.bob.go index d7922f2c..e2783c28 100644 --- a/db/models/fs_trapdata.bob.go +++ b/db/models/fs_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_traplocation.bob.go b/db/models/fs_traplocation.bob.go index 908e2fef..0fb678f1 100644 --- a/db/models/fs_traplocation.bob.go +++ b/db/models/fs_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_treatment.bob.go b/db/models/fs_treatment.bob.go index de73f5ab..5dbd0600 100644 --- a/db/models/fs_treatment.bob.go +++ b/db/models/fs_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_treatmentarea.bob.go b/db/models/fs_treatmentarea.bob.go index 6a8c5b10..a5dd1fa7 100644 --- a/db/models/fs_treatmentarea.bob.go +++ b/db/models/fs_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_zones.bob.go b/db/models/fs_zones.bob.go index 0a49e938..287808a0 100644 --- a/db/models/fs_zones.bob.go +++ b/db/models/fs_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fs_zones2.bob.go b/db/models/fs_zones2.bob.go index 01df8527..23f8aea1 100644 --- a/db/models/fs_zones2.bob.go +++ b/db/models/fs_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/geography_columns.bob.go b/db/models/geography_columns.bob.go index 61ec66dc..c0009226 100644 --- a/db/models/geography_columns.bob.go +++ b/db/models/geography_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/geometry_columns.bob.go b/db/models/geometry_columns.bob.go index 6afc4e69..fde74e5f 100644 --- a/db/models/geometry_columns.bob.go +++ b/db/models/geometry_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/goose_db_version.bob.go b/db/models/goose_db_version.bob.go index 73a6c23e..93afc44a 100644 --- a/db/models/goose_db_version.bob.go +++ b/db/models/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/h3_aggregation.bob.go b/db/models/h3_aggregation.bob.go index 1713a702..9ec7ed30 100644 --- a/db/models/h3_aggregation.bob.go +++ b/db/models/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_containerrelate.bob.go b/db/models/history_containerrelate.bob.go index 6d891923..eb136bd9 100644 --- a/db/models/history_containerrelate.bob.go +++ b/db/models/history_containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_fieldscoutinglog.bob.go b/db/models/history_fieldscoutinglog.bob.go index 8bde1bba..bc026f06 100644 --- a/db/models/history_fieldscoutinglog.bob.go +++ b/db/models/history_fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_habitatrelate.bob.go b/db/models/history_habitatrelate.bob.go index d7266704..7895dc87 100644 --- a/db/models/history_habitatrelate.bob.go +++ b/db/models/history_habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_inspectionsample.bob.go b/db/models/history_inspectionsample.bob.go index 02c9a0f0..3cf7b1f2 100644 --- a/db/models/history_inspectionsample.bob.go +++ b/db/models/history_inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_inspectionsampledetail.bob.go b/db/models/history_inspectionsampledetail.bob.go index 7208c49a..bf648d50 100644 --- a/db/models/history_inspectionsampledetail.bob.go +++ b/db/models/history_inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_linelocation.bob.go b/db/models/history_linelocation.bob.go index 2eee03c0..b8badb43 100644 --- a/db/models/history_linelocation.bob.go +++ b/db/models/history_linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_locationtracking.bob.go b/db/models/history_locationtracking.bob.go index 49c73fc5..5422e79a 100644 --- a/db/models/history_locationtracking.bob.go +++ b/db/models/history_locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_mosquitoinspection.bob.go b/db/models/history_mosquitoinspection.bob.go index 4c7d78ec..ba8c4b0f 100644 --- a/db/models/history_mosquitoinspection.bob.go +++ b/db/models/history_mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_pointlocation.bob.go b/db/models/history_pointlocation.bob.go index 84db5ad3..95c9a2ae 100644 --- a/db/models/history_pointlocation.bob.go +++ b/db/models/history_pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_polygonlocation.bob.go b/db/models/history_polygonlocation.bob.go index 7b1cc594..e9dcdc82 100644 --- a/db/models/history_polygonlocation.bob.go +++ b/db/models/history_polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_pool.bob.go b/db/models/history_pool.bob.go index 8183709f..1505f086 100644 --- a/db/models/history_pool.bob.go +++ b/db/models/history_pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_pooldetail.bob.go b/db/models/history_pooldetail.bob.go index 93cdb161..e3666f95 100644 --- a/db/models/history_pooldetail.bob.go +++ b/db/models/history_pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_proposedtreatmentarea.bob.go b/db/models/history_proposedtreatmentarea.bob.go index d4be578a..c0ea8aed 100644 --- a/db/models/history_proposedtreatmentarea.bob.go +++ b/db/models/history_proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_qamosquitoinspection.bob.go b/db/models/history_qamosquitoinspection.bob.go index 4042a1d0..255fe4f4 100644 --- a/db/models/history_qamosquitoinspection.bob.go +++ b/db/models/history_qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_rodentlocation.bob.go b/db/models/history_rodentlocation.bob.go index e4716ce7..8b03f1fb 100644 --- a/db/models/history_rodentlocation.bob.go +++ b/db/models/history_rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_samplecollection.bob.go b/db/models/history_samplecollection.bob.go index 85ea4394..3749b6cc 100644 --- a/db/models/history_samplecollection.bob.go +++ b/db/models/history_samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_samplelocation.bob.go b/db/models/history_samplelocation.bob.go index 154f7ee6..eadf96d7 100644 --- a/db/models/history_samplelocation.bob.go +++ b/db/models/history_samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_servicerequest.bob.go b/db/models/history_servicerequest.bob.go index 11c84daf..23f20d47 100644 --- a/db/models/history_servicerequest.bob.go +++ b/db/models/history_servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_speciesabundance.bob.go b/db/models/history_speciesabundance.bob.go index c6f952d3..0937f32a 100644 --- a/db/models/history_speciesabundance.bob.go +++ b/db/models/history_speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_stormdrain.bob.go b/db/models/history_stormdrain.bob.go index 84d5b54e..4129d578 100644 --- a/db/models/history_stormdrain.bob.go +++ b/db/models/history_stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_timecard.bob.go b/db/models/history_timecard.bob.go index 2c7c12f6..769943a0 100644 --- a/db/models/history_timecard.bob.go +++ b/db/models/history_timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_trapdata.bob.go b/db/models/history_trapdata.bob.go index 1e3b539f..d29cb6b8 100644 --- a/db/models/history_trapdata.bob.go +++ b/db/models/history_trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_traplocation.bob.go b/db/models/history_traplocation.bob.go index 3e911683..61269a79 100644 --- a/db/models/history_traplocation.bob.go +++ b/db/models/history_traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_treatment.bob.go b/db/models/history_treatment.bob.go index ae1379e9..18f845de 100644 --- a/db/models/history_treatment.bob.go +++ b/db/models/history_treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_treatmentarea.bob.go b/db/models/history_treatmentarea.bob.go index 391b991a..349cb0af 100644 --- a/db/models/history_treatmentarea.bob.go +++ b/db/models/history_treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_zones.bob.go b/db/models/history_zones.bob.go index 23cb18c3..3f407719 100644 --- a/db/models/history_zones.bob.go +++ b/db/models/history_zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/history_zones2.bob.go b/db/models/history_zones2.bob.go index be659e9f..fad9595a 100644 --- a/db/models/history_zones2.bob.go +++ b/db/models/history_zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/notification.bob.go b/db/models/notification.bob.go index d0ca6d6c..1c2defd8 100644 --- a/db/models/notification.bob.go +++ b/db/models/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/oauth_token.bob.go b/db/models/oauth_token.bob.go index 9c195a09..680f3b56 100644 --- a/db/models/oauth_token.bob.go +++ b/db/models/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/organization.bob.go b/db/models/organization.bob.go index 434665bc..dc367b30 100644 --- a/db/models/organization.bob.go +++ b/db/models/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -46,7 +46,6 @@ type OrganizationsQuery = *psql.ViewQuery[*Organization, OrganizationSlice] // organizationR is where relationships are stored. type organizationR struct { - Rodentlocations FieldseekerRodentlocationSlice // fieldseeker.rodentlocation.rodentlocation_organization_id_fkey FieldseekerSyncs FieldseekerSyncSlice // fieldseeker_sync.fieldseeker_sync_organization_id_fkey FSContainerrelates FSContainerrelateSlice // fs_containerrelate.fs_containerrelate_organization_id_fkey FSFieldscoutinglogs FSFieldscoutinglogSlice // fs_fieldscoutinglog.fs_fieldscoutinglog_organization_id_fkey @@ -496,30 +495,6 @@ func (o OrganizationSlice) ReloadAll(ctx context.Context, exec bob.Executor) err return nil } -// Rodentlocations starts a query for related objects on fieldseeker.rodentlocation -func (o *Organization) Rodentlocations(mods ...bob.Mod[*dialect.SelectQuery]) FieldseekerRodentlocationsQuery { - return FieldseekerRodentlocations.Query(append(mods, - sm.Where(FieldseekerRodentlocations.Columns.OrganizationID.EQ(psql.Arg(o.ID))), - )...) -} - -func (os OrganizationSlice) Rodentlocations(mods ...bob.Mod[*dialect.SelectQuery]) FieldseekerRodentlocationsQuery { - pkID := make(pgtypes.Array[int32], 0, len(os)) - for _, o := range os { - if o == nil { - continue - } - pkID = append(pkID, o.ID) - } - PKArgExpr := psql.Select(sm.Columns( - psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")), - )) - - return FieldseekerRodentlocations.Query(append(mods, - sm.Where(psql.Group(FieldseekerRodentlocations.Columns.OrganizationID).OP("IN", PKArgExpr)), - )...) -} - // FieldseekerSyncs starts a query for related objects on fieldseeker_sync func (o *Organization) FieldseekerSyncs(mods ...bob.Mod[*dialect.SelectQuery]) FieldseekerSyncsQuery { return FieldseekerSyncs.Query(append(mods, @@ -1888,74 +1863,6 @@ func (os OrganizationSlice) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQue )...) } -func insertOrganizationRodentlocations0(ctx context.Context, exec bob.Executor, fieldseekerRodentlocations1 []*FieldseekerRodentlocationSetter, organization0 *Organization) (FieldseekerRodentlocationSlice, error) { - for i := range fieldseekerRodentlocations1 { - fieldseekerRodentlocations1[i].OrganizationID = omit.From(organization0.ID) - } - - ret, err := FieldseekerRodentlocations.Insert(bob.ToMods(fieldseekerRodentlocations1...)).All(ctx, exec) - if err != nil { - return ret, fmt.Errorf("insertOrganizationRodentlocations0: %w", err) - } - - return ret, nil -} - -func attachOrganizationRodentlocations0(ctx context.Context, exec bob.Executor, count int, fieldseekerRodentlocations1 FieldseekerRodentlocationSlice, organization0 *Organization) (FieldseekerRodentlocationSlice, error) { - setter := &FieldseekerRodentlocationSetter{ - OrganizationID: omit.From(organization0.ID), - } - - err := fieldseekerRodentlocations1.UpdateAll(ctx, exec, *setter) - if err != nil { - return nil, fmt.Errorf("attachOrganizationRodentlocations0: %w", err) - } - - return fieldseekerRodentlocations1, nil -} - -func (organization0 *Organization) InsertRodentlocations(ctx context.Context, exec bob.Executor, related ...*FieldseekerRodentlocationSetter) error { - if len(related) == 0 { - return nil - } - - var err error - - fieldseekerRodentlocations1, err := insertOrganizationRodentlocations0(ctx, exec, related, organization0) - if err != nil { - return err - } - - organization0.R.Rodentlocations = append(organization0.R.Rodentlocations, fieldseekerRodentlocations1...) - - for _, rel := range fieldseekerRodentlocations1 { - rel.R.Organization = organization0 - } - return nil -} - -func (organization0 *Organization) AttachRodentlocations(ctx context.Context, exec bob.Executor, related ...*FieldseekerRodentlocation) error { - if len(related) == 0 { - return nil - } - - var err error - fieldseekerRodentlocations1 := FieldseekerRodentlocationSlice(related) - - _, err = attachOrganizationRodentlocations0(ctx, exec, len(related), fieldseekerRodentlocations1, organization0) - if err != nil { - return err - } - - organization0.R.Rodentlocations = append(organization0.R.Rodentlocations, fieldseekerRodentlocations1...) - - for _, rel := range related { - rel.R.Organization = organization0 - } - - return nil -} - func insertOrganizationFieldseekerSyncs0(ctx context.Context, exec bob.Executor, fieldseekerSyncs1 []*FieldseekerSyncSetter, organization0 *Organization) (FieldseekerSyncSlice, error) { for i := range fieldseekerSyncs1 { fieldseekerSyncs1[i].OrganizationID = omit.From(organization0.ID) @@ -5860,20 +5767,6 @@ func (o *Organization) Preload(name string, retrieved any) error { } switch name { - case "Rodentlocations": - rels, ok := retrieved.(FieldseekerRodentlocationSlice) - if !ok { - return fmt.Errorf("organization cannot load %T as %q", retrieved, name) - } - - o.R.Rodentlocations = rels - - for _, rel := range rels { - if rel != nil { - rel.R.Organization = o - } - } - return nil case "FieldseekerSyncs": rels, ok := retrieved.(FieldseekerSyncSlice) if !ok { @@ -6684,7 +6577,6 @@ func buildOrganizationPreloader() organizationPreloader { } type organizationThenLoader[Q orm.Loadable] struct { - Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] FSContainerrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] FSFieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] @@ -6745,9 +6637,6 @@ type organizationThenLoader[Q orm.Loadable] struct { } func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] { - type RodentlocationsLoadInterface interface { - LoadRodentlocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error - } type FieldseekerSyncsLoadInterface interface { LoadFieldseekerSyncs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error } @@ -6921,12 +6810,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] { } return organizationThenLoader[Q]{ - Rodentlocations: thenLoadBuilder[Q]( - "Rodentlocations", - func(ctx context.Context, exec bob.Executor, retrieved RodentlocationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { - return retrieved.LoadRodentlocations(ctx, exec, mods...) - }, - ), FieldseekerSyncs: thenLoadBuilder[Q]( "FieldseekerSyncs", func(ctx context.Context, exec bob.Executor, retrieved FieldseekerSyncsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { @@ -7272,67 +7155,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] { } } -// LoadRodentlocations loads the organization's Rodentlocations into the .R struct -func (o *Organization) LoadRodentlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if o == nil { - return nil - } - - // Reset the relationship - o.R.Rodentlocations = nil - - related, err := o.Rodentlocations(mods...).All(ctx, exec) - if err != nil { - return err - } - - for _, rel := range related { - rel.R.Organization = o - } - - o.R.Rodentlocations = related - return nil -} - -// LoadRodentlocations loads the organization's Rodentlocations into the .R struct -func (os OrganizationSlice) LoadRodentlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if len(os) == 0 { - return nil - } - - fieldseekerRodentlocations, err := os.Rodentlocations(mods...).All(ctx, exec) - if err != nil { - return err - } - - for _, o := range os { - if o == nil { - continue - } - - o.R.Rodentlocations = nil - } - - for _, o := range os { - if o == nil { - continue - } - - for _, rel := range fieldseekerRodentlocations { - - if !(o.ID == rel.OrganizationID) { - continue - } - - rel.R.Organization = o - - o.R.Rodentlocations = append(o.R.Rodentlocations, rel) - } - } - - return nil -} - // LoadFieldseekerSyncs loads the organization's FieldseekerSyncs into the .R struct func (o *Organization) LoadFieldseekerSyncs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { if o == nil { @@ -10815,7 +10637,6 @@ func (os OrganizationSlice) LoadUser(ctx context.Context, exec bob.Executor, mod type organizationJoins[Q dialect.Joinable] struct { typ string - Rodentlocations modAs[Q, fieldseekerRodentlocationColumns] FieldseekerSyncs modAs[Q, fieldseekerSyncColumns] FSContainerrelates modAs[Q, fsContainerrelateColumns] FSFieldscoutinglogs modAs[Q, fsFieldscoutinglogColumns] @@ -10882,20 +10703,6 @@ func (j organizationJoins[Q]) aliasedAs(alias string) organizationJoins[Q] { func buildOrganizationJoins[Q dialect.Joinable](cols organizationColumns, typ string) organizationJoins[Q] { return organizationJoins[Q]{ typ: typ, - Rodentlocations: modAs[Q, fieldseekerRodentlocationColumns]{ - c: FieldseekerRodentlocations.Columns, - f: func(to fieldseekerRodentlocationColumns) bob.Mod[Q] { - mods := make(mods.QueryMods[Q], 0, 1) - - { - mods = append(mods, dialect.Join[Q](typ, FieldseekerRodentlocations.Name().As(to.Alias())).On( - to.OrganizationID.EQ(cols.ID), - )) - } - - return mods - }, - }, FieldseekerSyncs: modAs[Q, fieldseekerSyncColumns]{ c: FieldseekerSyncs.Columns, f: func(to fieldseekerSyncColumns) bob.Mod[Q] { diff --git a/db/models/raster_columns.bob.go b/db/models/raster_columns.bob.go index 53a891f7..49e61ded 100644 --- a/db/models/raster_columns.bob.go +++ b/db/models/raster_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/raster_overviews.bob.go b/db/models/raster_overviews.bob.go index cbe0d219..61325aa1 100644 --- a/db/models/raster_overviews.bob.go +++ b/db/models/raster_overviews.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/sessions.bob.go b/db/models/sessions.bob.go index 891888f9..0133e1b9 100644 --- a/db/models/sessions.bob.go +++ b/db/models/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/spatial_ref_sys.bob.go b/db/models/spatial_ref_sys.bob.go index cbeb7f3a..30bc74b2 100644 --- a/db/models/spatial_ref_sys.bob.go +++ b/db/models/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/user_.bob.go b/db/models/user_.bob.go index 873dcc18..007f951b 100644 --- a/db/models/user_.bob.go +++ b/db/models/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/prepared.go b/db/prepared.go index 4b4f8e63..29d97c1b 100644 --- a/db/prepared.go +++ b/db/prepared.go @@ -3,6 +3,7 @@ package db import ( "context" "embed" + "encoding/json" "fmt" "path/filepath" "strings" @@ -132,6 +133,104 @@ type SqlParam interface { ToSql() string } +type JsonBParam struct { + Name string + Value json.RawMessage +} + +func (p JsonBParam) ToSql() string { + if len(p.Value) == 0 { + return fmt.Sprintf("%s => '{}'::jsonb", p.Name) + } + return fmt.Sprintf("%s => '%s'::jsonb", p.Name, p.Value) +} + +type GeometryLine struct { + Paths [][][]float64 `json:"paths"` +} +type GISLineParam struct { + Name string + Value GeometryLine + WKID int +} + +func (p GISLineParam) ToSql() string { + pairs := make([]string, 0) + if len(p.Value.Paths) > 1 { + log.Warn().Msg("Looks like we need to implement multi-path lines") + } + for _, path := range p.Value.Paths { + for _, pair := range path { + if len(pair) != 2 { + log.Warn().Int("len", len(pair)).Msg("Too many coords in line point") + continue + } + pairs = append(pairs, fmt.Sprintf("%f %f", pair[0], pair[1])) + } + } + var b strings.Builder + for i, p := range pairs { + b.WriteString(p) + if i < len(pairs)-1 { + b.WriteString(", ") + } + } + // Not sure why this isn't working, postgres is complaining that "function x is not uinque" and that + // I may want to add explicit casts... + //return fmt.Sprintf("%s => ST_SetSRID('LINESTRING(%s)', %d)::geometry(LineString,%d)", p.Name, b.String(), p.WKID, p.WKID) + return fmt.Sprintf("%s => 'LINESTRING(%s)'::geometry", p.Name, b.String()) +} + +type GeometryPoint struct { + X float64 `json:"x"` + Y float64 `json:"y"` +} +type GISPointParam struct { + Name string + Value GeometryPoint + WKID int +} + +func (p GISPointParam) ToSql() string { + return fmt.Sprintf("%s => ST_SetSRID(ST_MakePoint(%f, %f), %d)", p.Name, p.Value.X, p.Value.Y, p.WKID) +} + +type GeometryPolygon struct { + Rings [][][]float64 `json:"rings"` +} +type GISPolygonParam struct { + Name string + Value GeometryPolygon + WKID int +} + +func (p GISPolygonParam) ToSql() string { + pairs := make([]string, 0) + if len(p.Value.Rings) > 1 { + log.Warn().Msg("Looks like we need to implement multi-path lines") + } + for _, path := range p.Value.Rings { + for _, pair := range path { + if len(pair) != 2 { + log.Warn().Int("len", len(pair)).Msg("Too many coords in line point") + continue + } + pairs = append(pairs, fmt.Sprintf("%f %f", pair[0], pair[1])) + } + } + var b strings.Builder + for i, p := range pairs { + b.WriteString(p) + if i < len(pairs)-1 { + b.WriteString(", ") + } + } + // Not sure why this isn't working, postgres is complaining that "function x is not uinque" and that + // I may want to add explicit casts... + //return fmt.Sprintf("%s => ST_SetSRID('LINESTRING(%s)', %d)::geometry(LineString,%d)", p.Name, b.String(), p.WKID, p.WKID) + return fmt.Sprintf("%s => ST_MakePolygon('LINESTRING(%s)')::geometry", p.Name, b.String()) +} + // StringParam wraps a string parameter type StringParam struct { Name string @@ -243,10 +342,12 @@ func (p EnumParam) ToSql() string { } // NullParam represents a NULL value -type NullParam struct{} +type NullParam struct { + Name string +} -func (NullParam) ToSql() string { - return "NULL" +func (p NullParam) ToSql() string { + return fmt.Sprintf("%s => NULL", p.Name) } // Convenience functions to create typed parameters @@ -267,6 +368,15 @@ func Enum(n string, e Stringable) EnumParam { func Float64(n string, f float64) Float64Param { return Float64Param{n, f} } +func GISLine(n string, v GeometryLine, wkid int) GISLineParam { + return GISLineParam{n, v, wkid} +} +func GISPoint(n string, v GeometryPoint, wkid int) GISPointParam { + return GISPointParam{n, v, wkid} +} +func GISPolygon(n string, v GeometryPolygon, wkid int) GISPolygonParam { + return GISPolygonParam{n, v, wkid} +} func Int16(n string, i int16) Int16Param { return Int16Param{n, i} } @@ -276,6 +386,9 @@ func Int32(n string, i int32) Int32Param { func Int64(n string, i int64) Int64Param { return Int64Param{n, i} } +func JsonB(n string, v json.RawMessage) JsonBParam { + return JsonBParam{n, v} +} // Timestamp creates a PostgreSQL TIMESTAMP WITHOUT TIME ZONE parameter func Timestamp(name string, t time.Time) TimestampParam { @@ -363,3 +476,63 @@ func executeFunction(functionName string, params ...SqlParam) string { // Join parameters and return the execute statement return fmt.Sprintf("EXECUTE %s(%s)", functionName, strings.Join(paramStrings, ", ")) } + +func parseLine(msg json.RawMessage) (result GeometryLine, err error) { + err = json.Unmarshal(msg, &result) + if err != nil { + return result, fmt.Errorf("Failed to parse line from '%s': %w", string(msg), err) + } + return result, nil +} + +func parsePoint(msg json.RawMessage) (result GeometryPoint, err error) { + err = json.Unmarshal(msg, &result) + if err != nil { + return result, fmt.Errorf("Failed to parse point from '%s': %w", string(msg), err) + } + return result, nil +} + +func parsePolygon(msg json.RawMessage) (result GeometryPolygon, err error) { + err = json.Unmarshal(msg, &result) + if err != nil { + return result, fmt.Errorf("Failed to parse polygon from '%s': %w", string(msg), err) + } + return result, nil +} + +func lineOrNull(msg json.RawMessage) (SqlParam, error) { + // Surprisingly some geos are actually empty + if len(msg) == 0 { + return NullParam{"p_geospatial"}, nil + } + geo, err := parseLine(msg) + if err != nil { + return NullParam{"p_geospatial"}, fmt.Errorf("Failed to pepare GISLine: %w", err) + } + return GISLine("p_geospatial", geo, 3857), nil +} + +func pointOrNull(msg json.RawMessage) (SqlParam, error) { + // Surprisingly some geos are actually empty + if len(msg) == 0 { + return NullParam{"p_geospatial"}, nil + } + geo, err := parsePoint(msg) + if err != nil { + return NullParam{"p_geospatial"}, fmt.Errorf("Failed to pepare GISPoint: %w", err) + } + return GISPoint("p_geospatial", geo, 3857), nil +} + +func polygonOrNull(msg json.RawMessage) (SqlParam, error) { + // Surprisingly some geos are actually empty + if len(msg) == 0 { + return NullParam{"p_geospatial"}, nil + } + geo, err := parsePolygon(msg) + if err != nil { + return NullParam{"p_geospatial"}, fmt.Errorf("Failed to pepare GISPolygon: %w", err) + } + return GISPolygon("p_geospatial", geo, 3857), nil +} diff --git a/db/sql/oauth_by_user_id.bob.go b/db/sql/oauth_by_user_id.bob.go index cf574424..619ba4c7 100644 --- a/db/sql/oauth_by_user_id.bob.go +++ b/db/sql/oauth_by_user_id.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -21,7 +21,7 @@ import ( //go:embed oauth_by_user_id.bob.sql var formattedQueries_oauth_by_user_id string -var oauthTokenByUserIdSQL = formattedQueries_oauth_by_user_id[156:694] +var oauthTokenByUserIdSQL = formattedQueries_oauth_by_user_id[191:729] type OauthTokenByUserIdQuery = orm.ModQuery[*dialect.SelectQuery, oauthTokenByUserId, OauthTokenByUserIdRow, []OauthTokenByUserIdRow, oauthTokenByUserIdTransformer] diff --git a/db/sql/oauth_by_user_id.bob.sql b/db/sql/oauth_by_user_id.bob.sql index d11b0598..76f94998 100644 --- a/db/sql/oauth_by_user_id.bob.sql +++ b/db/sql/oauth_by_user_id.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.42.0. DO NOT EDIT. +-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- OauthTokenByUserId diff --git a/db/sql/oauth_by_user_id.bob_test.go b/db/sql/oauth_by_user_id.bob_test.go index 7791ade1..e21fdddf 100644 --- a/db/sql/oauth_by_user_id.bob_test.go +++ b/db/sql/oauth_by_user_id.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/db/sql/org_by_oauth_id.bob.go b/db/sql/org_by_oauth_id.bob.go index 9644aca5..99af84da 100644 --- a/db/sql/org_by_oauth_id.bob.go +++ b/db/sql/org_by_oauth_id.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -20,7 +20,7 @@ import ( //go:embed org_by_oauth_id.bob.sql var formattedQueries_org_by_oauth_id string -var orgByOauthIdSQL = formattedQueries_org_by_oauth_id[150:363] +var orgByOauthIdSQL = formattedQueries_org_by_oauth_id[185:398] type OrgByOauthIdQuery = orm.ModQuery[*dialect.SelectQuery, orgByOauthId, OrgByOauthIdRow, []OrgByOauthIdRow, orgByOauthIdTransformer] diff --git a/db/sql/org_by_oauth_id.bob.sql b/db/sql/org_by_oauth_id.bob.sql index 8b79cd87..c0ce798f 100644 --- a/db/sql/org_by_oauth_id.bob.sql +++ b/db/sql/org_by_oauth_id.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.42.0. DO NOT EDIT. +-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- OrgByOauthId diff --git a/db/sql/org_by_oauth_id.bob_test.go b/db/sql/org_by_oauth_id.bob_test.go index 4bc87d96..949f4581 100644 --- a/db/sql/org_by_oauth_id.bob_test.go +++ b/db/sql/org_by_oauth_id.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/db/sql/test_utils.bob_test.go b/db/sql/test_utils.bob_test.go index 4efbfff6..f3f01caf 100644 --- a/db/sql/test_utils.bob_test.go +++ b/db/sql/test_utils.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/db/sql/trapcount_by_location_id.bob.go b/db/sql/trapcount_by_location_id.bob.go index 787e6354..74a4c868 100644 --- a/db/sql/trapcount_by_location_id.bob.go +++ b/db/sql/trapcount_by_location_id.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -22,7 +22,7 @@ import ( //go:embed trapcount_by_location_id.bob.sql var formattedQueries_trapcount_by_location_id string -var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[159:591] +var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[194:626] type TrapCountByLocationIDQuery = orm.ModQuery[*dialect.SelectQuery, trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer] diff --git a/db/sql/trapcount_by_location_id.bob.sql b/db/sql/trapcount_by_location_id.bob.sql index a7146e63..9536108f 100644 --- a/db/sql/trapcount_by_location_id.bob.sql +++ b/db/sql/trapcount_by_location_id.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.42.0. DO NOT EDIT. +-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- TrapCountByLocationID diff --git a/db/sql/trapcount_by_location_id.bob_test.go b/db/sql/trapcount_by_location_id.bob_test.go index 4c2dba81..3d57050d 100644 --- a/db/sql/trapcount_by_location_id.bob_test.go +++ b/db/sql/trapcount_by_location_id.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/db/sql/trapdata_by_location_id_recent.bob.go b/db/sql/trapdata_by_location_id_recent.bob.go index c075adbf..81d4136e 100644 --- a/db/sql/trapdata_by_location_id_recent.bob.go +++ b/db/sql/trapdata_by_location_id_recent.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -20,7 +20,7 @@ import ( //go:embed trapdata_by_location_id_recent.bob.sql var formattedQueries_trapdata_by_location_id_recent string -var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[164:454] +var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[199:489] type TrapDataByLocationIDRecentQuery = orm.ModQuery[*dialect.SelectQuery, trapDataByLocationIDRecent, TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow, trapDataByLocationIDRecentTransformer] diff --git a/db/sql/trapdata_by_location_id_recent.bob.sql b/db/sql/trapdata_by_location_id_recent.bob.sql index 13a4e4b6..a4e4eadf 100644 --- a/db/sql/trapdata_by_location_id_recent.bob.sql +++ b/db/sql/trapdata_by_location_id_recent.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.42.0. DO NOT EDIT. +-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- TrapDataByLocationIDRecent diff --git a/db/sql/trapdata_by_location_id_recent.bob_test.go b/db/sql/trapdata_by_location_id_recent.bob_test.go index eabf5f20..281cea2a 100644 --- a/db/sql/trapdata_by_location_id_recent.bob_test.go +++ b/db/sql/trapdata_by_location_id_recent.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/db/sql/traplocation_by_source_id.bob.go b/db/sql/traplocation_by_source_id.bob.go index ab83f7d8..45863018 100644 --- a/db/sql/traplocation_by_source_id.bob.go +++ b/db/sql/traplocation_by_source_id.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -19,7 +19,7 @@ import ( //go:embed traplocation_by_source_id.bob.sql var formattedQueries_traplocation_by_source_id string -var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[160:411] +var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[195:446] type TrapLocationBySourceIDQuery = orm.ModQuery[*dialect.SelectQuery, trapLocationBySourceID, TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow, trapLocationBySourceIDTransformer] diff --git a/db/sql/traplocation_by_source_id.bob.sql b/db/sql/traplocation_by_source_id.bob.sql index 6378bbfa..779c9e2a 100644 --- a/db/sql/traplocation_by_source_id.bob.sql +++ b/db/sql/traplocation_by_source_id.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.42.0. DO NOT EDIT. +-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- TrapLocationBySourceID diff --git a/db/sql/traplocation_by_source_id.bob_test.go b/db/sql/traplocation_by_source_id.bob_test.go index 9972836d..73451247 100644 --- a/db/sql/traplocation_by_source_id.bob_test.go +++ b/db/sql/traplocation_by_source_id.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/db/sql/update_oauth_org.bob.go b/db/sql/update_oauth_org.bob.go index d2ae7c5d..f8c582b2 100644 --- a/db/sql/update_oauth_org.bob.go +++ b/db/sql/update_oauth_org.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -18,7 +18,7 @@ import ( //go:embed update_oauth_org.bob.sql var formattedQueries_update_oauth_org string -var updateOauthTokenOrgSQL = formattedQueries_update_oauth_org[157:249] +var updateOauthTokenOrgSQL = formattedQueries_update_oauth_org[192:284] type UpdateOauthTokenOrgQuery = orm.ModExecQuery[*dialect.UpdateQuery, updateOauthTokenOrg] diff --git a/db/sql/update_oauth_org.bob.sql b/db/sql/update_oauth_org.bob.sql index 5f2a3d0d..1a2687ce 100644 --- a/db/sql/update_oauth_org.bob.sql +++ b/db/sql/update_oauth_org.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.42.0. DO NOT EDIT. +-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- UpdateOauthTokenOrg diff --git a/db/sql/update_oauth_org.bob_test.go b/db/sql/update_oauth_org.bob_test.go index 7c004f41..805dd051 100644 --- a/db/sql/update_oauth_org.bob_test.go +++ b/db/sql/update_oauth_org.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/db/sql/user_by_username.bob.go b/db/sql/user_by_username.bob.go index 5582c154..86ad70f3 100644 --- a/db/sql/user_by_username.bob.go +++ b/db/sql/user_by_username.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -22,7 +22,7 @@ import ( //go:embed user_by_username.bob.sql var formattedQueries_user_by_username string -var userByUsernameSQL = formattedQueries_user_by_username[152:773] +var userByUsernameSQL = formattedQueries_user_by_username[187:808] type UserByUsernameQuery = orm.ModQuery[*dialect.SelectQuery, userByUsername, UserByUsernameRow, []UserByUsernameRow, userByUsernameTransformer] diff --git a/db/sql/user_by_username.bob.sql b/db/sql/user_by_username.bob.sql index fd47488e..7bb4c579 100644 --- a/db/sql/user_by_username.bob.sql +++ b/db/sql/user_by_username.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.42.0. DO NOT EDIT. +-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- UserByUsername diff --git a/db/sql/user_by_username.bob_test.go b/db/sql/user_by_username.bob_test.go index f95d6729..38ebd58f 100644 --- a/db/sql/user_by_username.bob_test.go +++ b/db/sql/user_by_username.bob_test.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.42.0. DO NOT EDIT. +// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql diff --git a/main.go b/main.go index ae38c383..0bdf4f36 100644 --- a/main.go +++ b/main.go @@ -204,14 +204,14 @@ func LoggerMiddleware(logger *zerolog.Logger) func(next http.Handler) http.Handl } // log end request log.Info(). - Str("type", "access"). + //Str("type", "access"). Timestamp(). Fields(map[string]interface{}{ - "remote_ip": remote_addr, - "url": r.URL.Path, - "proto": r.Proto, - "method": r.Method, - "user_agent": r.Header.Get("User-Agent"), + "remote_ip": remote_addr, + "url": r.URL.Path, + //"proto": r.Proto, + "method": r.Method, + //"user_agent": r.Header.Get("User-Agent"), "status": ww.Status(), "latency_ms": float64(t2.Sub(t1).Nanoseconds()) / 1000000.0, "bytes_in": r.Header.Get("Content-Length"),