openplans / openblock

OpenBlock is a web application and RESTful service that allows users to browse and search their local area for "hyper-local news
61 stars 26 forks source link

Can't safely update blocks #250

Closed slinkp closed 11 years ago

slinkp commented 11 years ago

The import_blocks script can now be safely run on the same shapefiles it was initially run with, and you can do several runs with different shapefiles to cover a wider area. But you can't safely load a newer version of the shapefile, eg. upgrading from 2000 census data to 2010 census data.

The reason is because there's no way to detect blocks that have changed significantly but are in some nominal sense the same. Think of: address range changes (a building with a higher or lower number was built), or street name changes, or block splitting (a new intersection was built in the middle of the old block)... etc. In all these cases, the script would leave you with both the old blocks and the new blocks.

Proposal: Remove foreign keys pointing to the blocks table (this impacts at least the NewsItem.block foreign key, which we can probably get rid of, see #93). Then we can at least safely wipe the blocks database and redo it from scratch.

slinkp commented 11 years ago

Ugh, here's a few problematic foreign keys:

ebpub.alerts: EmailAlert.block

ebpub.geocoder: GeocoderCache.block

ebpub.savedplaces: SavedPlace.block

And of course ebpub.streets: BlockIntersection.block, but we'd be regenerating that anyway.

slinkp commented 11 years ago

Okay, removed NewsItem.block, so now it's at least possible to do a cascading truncate if you don't care about EmailAlert or SavedPlace.

slinkp commented 11 years ago

Ticket imported from Trac: http://developer.openblockproject.org/ticket/257 Reported by: slinkp