codefordurham/Durham-Restaurants — pull request #82 by copelco (2014-04-14 23:40:22+00:00)
Title: Simplify schema

This PR simplifies and generalizes the restaurant data schema. Due to the large nature of this change and the fact that migration history isn't important, I didn't think it was worth the time trying to migrate the existing data when it's easily re-imported from the data.dconc.gov API. I'll provided upgrade steps below.

I also added ``eatsmart.locations``. Thinking ahead to incorporating data from the surrounding area, I moved all Durham-specific logic into the ``eatsmart.locations.durham`` package. This keeps the Durham stuff contained and opens up the possibility of importing data from Wake and other nearby counties. As part of this change, I attempted to normalize the import process and started to create a base/child class setup that works with Durham. It'll probably need some changes to support Wake, but it's a start.

Remaining items (potentially new GitHub issues):

* [ ] Create periodic celery task to run the Durham import on a nightly basis (should be easy now)
* [ ] Use ``update_date`` to filter down API import to new rows only (faster)
* [ ] Add labels for establishment and inspection types
* [ ] Restore tax record image values (not sure how these were originally scraped)

So you'll need to drop the necessary tables:
```
DROP TABLE inspections_violation CASCADE;
DROP TABLE inspections_inspection CASCADE;
DROP TABLE inspections_establishment CASCADE;
```
Then run the migrations:
```
python manage.py migrate --delete-ghost-migrations
```
And then import the Durham data:
```
python manage.py import_durham
```

I'll post a full DB dump here later tonight.