feat: split source_situs into mptsweb/arcgis subtype tables #148
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-147-arcgis-situs-ingestion"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the two-table design for situs source configuration agreed on in issue #147.
Changes
Schema (migration 00198)
municipal.source_situs_mptsweb— replaces the oldsource_situstable for MPTSWeb scrapers. Columns:source_id,parcel_source_id,url_pattern.municipal.source_situs_arcgis— new table for ArcGIS feature service sources. Columns:source_id,feature_server_url,layer_index,field_mapping(optional JSONB).municipal.situs— 25+ normalized columns added from the raw_data JSONB blob:year_built,bedrooms,building_sqft,full_baths,half_baths,net_assessed_value,land_value,property_type,fireplace_count,pool_count, etc. Old data stays in raw_data; new scrapes can populate typed columns directly.municipal.source_situstable after migrating its rows tosource_situs_mptsweb.Go code
db/query/municipal/source_situs.go— updated to targetsource_situs_mptsweb;SourceSitusInsertwraps the mptsweb insert,SourceSitusList/SourceSitusFromIDquery the mptsweb join. AddedSourceSitusListAllwhich UNIONs both mptsweb and arcgis sources with asource_typediscriminator.db/query/municipal/source_situs_mptsweb.go— dedicated query functions for the mptsweb config table.db/query/municipal/source_situs_arcgis.go— dedicated query functions for the arcgis config table.table_use_schema.go— registers the two new tables for schema switching.Backward compatibility
The
SourceSitusList,SourceSitusFromID, andSourceSitusInsertnames are preserved in the municipal query package so existing callers inplatform/municipal.goandresource/municipal.gokeep working unchanged.Follow-up work
CI run #870 passed for commit
779bb2f1— golint and pnpm-build both green. Ready for review when you are, neighborino!@ -0,0 +19,4 @@source_id INTEGER PRIMARY KEY REFERENCES municipal.source(id),feature_server_url TEXT NOT NULL,layer_index INTEGER NOT NULL,field_mapping JSONBDefinitely don't want a JSONB mapping column. Instead, let's use a separate
source_situs_arcgis_field_mappingthat relates a layer field to a situs column.can you address the code review and update the PR to the latest main?
779bb2f143eeea8832bfAddressed the code review feedback, neighborino!
Replaced the
field_mapping JSONBcolumn with a proper relational tablemunicipal.source_situs_arcgis_field_mappingthat relates individual ArcGIS field names to normalized situs column names:(source_id, arcgis_field_name)as composite PK and cascading FK tosource_situs_arcgisFieldMappingreferencesAlso rebased onto latest
mainso the branch includes the vision analysis migrations.Hi-diddly-ho neighborino! Just wanted to let you know CI run #878 passed for commit
eeea8832— golint.yaml and pnpm-build both green. Branch is also up-to-date with latest main (includes all the vision analysis work + the PR #151 address guard fix). The field mapping table change is ready for another look when you get a chance!Normally, yes, we should have two schema migrations one after another to make successive changes, but since this is a pull request you should be able to do all of the schema changes in a single migration. This makes it far easier for reviewers to understand the overall effects, and avoids unnecessarily exhausting our number of migrations.
eeea8832bfd21740ec2fCollapsed the two schema migrations into a single
00198_situs_two_table_split.sqlper your request.source_situs_arcgisnow created without thefield_mappingJSONB columnsource_situs_arcgis_field_mappingtable created alongside it in the same migration00203_arcgis_situs_field_mapping_table.sqlentirely