diff --git a/README.md b/README.md index f187489..676ec5d 100644 --- a/README.md +++ b/README.md @@ -72,16 +72,26 @@ or, from Python #### Migrating to v1.0.0 -v1.0.0 introduced some changes to the database schema and the datums data model. To upgrade your existing datums database to a v1.0.0-compatible schema, a series of alembic mirations have been provided. To migrate your database +v1.0.0 introduces some changes to the database schema and the datums data model. To upgrade your existing datums database to a v1.0.0-compatible schema, a series of alembic mirations have been provided. To migrate your database, clone (or pull) this repository and run the setup script, then `cd` into the repository and run the migrations ```bash +/path/to/datums/ $ alembic upgrade head +/path/to/datums/ $ datums --update "/path/to/reporter/folder/*.json" +/path/to/datums/ $ datums --add "/path/to/reporter/folder/*.json" +``` + +After migrating, it's important to `--update` all reports to add the `pressure_in` and `pressure_mb` attributes on weather reports as well as the `inland_water` attribute to placemark reports. You can safely ignore the `UserWarning` that no `uniqueIdentifier` can be found for altitude reports; those altitude reports will be added when you `--add` in the next step. + +v1.0.0 adds support for altitude reports. After updating, you'll need to `--add` all your reports to capture altitude reports from before May, 2015. They must be added instead of updated because altitude reports have not always had `uniqueIdentifiers`. Adding will allow datums to create UUIDs for these earlier altitude reports. If no UUID is found for an altitude report, datums canot update or delete it. See [issue 29](https://github.com/thejunglejane/datums/issues/29) for more information. + +Alternatively, you could just teardown your existing datums database and setup a new one. +```bash +$ datums --teardown $ pip install --upgrade datums -$ alembic upgrade head +$ datums --setup $ datums --add "/path/to/reporter/folder/*.json" ``` -v1.0.0 adds support for altitude reports. After `--migrate`ing, it's important to `--add` all your reports to capture these altitude reports. They must be added instead of updated because altitude reports have not always had `uniqueIdentifiers`. Adding will allow datums to create UUIDs for these altitude reports. If no UUID is found for an altitude report, datums canot update or delete it. See [issue 29](https://github.com/thejunglejane/datums/issues/29) for more information. - # Adding, Updating, and Deleting The `pipeline` module allows you to add, update, and delete reports and questions. diff --git a/alembic/env.py b/alembic/env.py index 4cb59ad..77e624d 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -3,6 +3,8 @@ from alembic import context from sqlalchemy import engine_from_config, pool from logging.config import fileConfig +import os + # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -51,8 +53,11 @@ def run_migrations_online(): and associate a connection with the context. """ + alembic_config = config.get_section(config.config_ini_section) + alembic_config['sqlalchemy.url'] = os.environ['DATABASE_URI'] + connectable = engine_from_config( - config.get_section(config.config_ini_section), + alembic_config, prefix='sqlalchemy.', poolclass=pool.NullPool) diff --git a/datums/pipeline/__init__.py b/datums/pipeline/__init__.py index 0952b5f..91e015a 100644 --- a/datums/pipeline/__init__.py +++ b/datums/pipeline/__init__.py @@ -70,6 +70,7 @@ def _report(self, action, key_mapper=mappers._report_key_mapper): nested_levels_dict = {} for key in _top_level: try: +<<<<<<< HEAD if key == 'date': item = mappers._key_type_mapper[key]( str(self.report[key]), **{'ignoretz': True}) @@ -77,6 +78,14 @@ def _report(self, action, key_mapper=mappers._report_key_mapper): item = mappers._key_type_mapper[key](self.report[key]) else: item = mappers._key_type_mapper[key](str(self.report[key])) +======= + if key == 'date' or key == 'timestamp': + item = mappers._key_type_mapper[key]( + str(self.report[key]), **{'ignoretz': True}) + else: + item = mappers._key_type_mapper[key](str( + self.report[key]) if key != 'draft' else self.report[key]) +>>>>>>> 5db6c596e670f6f9d15720871ccc0ddba1edc58d except KeyError: item = self.report[key] finally: diff --git a/setup.py b/setup.py index 1777b47..ae36eb5 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,9 @@ def readme(): packages = ['datums', 'datums.pipeline', 'datums.models'], version = __version__, scripts = ['bin/datums'], - install_requires = ['sqlalchemy', 'sqlalchemy-utils', 'python-dateutil'], + install_requires = [ + 'alembic', 'sqlalchemy', 'sqlalchemy-utils', 'python-dateutil'], + tests_require = ['mock'], description = 'A PostgreSQL pipeline for Reporter.', author = 'Jane Stewart Adams', author_email = 'jane@thejunglejane.com',