agile-france/propile — pull request #8 by oelmekki (2013-11-07 19:20:06+00:00)
Title: REFACTOR switch to postgres

Database has been changed to use postgres rather than sqlite.

Database credentials has to be provided as environment variables :

* `PROPILE_DEV_DB_NAME`
* `PROPILE_DEV_DB_USER`
* `PROPILE_DEV_DB_PASS`
* `PROPILE_TEST_DB_NAME`
* `PROPILE_TEST_DB_USER`
* `PROPILE_TEST_DB_PASS`
* `PROPILE_PROD_DB_NAME`
* `PROPILE_PROD_DB_USER`
* `PROPILE_PROD_DB_PASS`

Only the first six are needed for a typical development box.

Using environment variables is a good thing because :

* each developer may use configuration she wants on her box
* credentials are not committed in repos (especially important here
since it's a public repos)

Instructions has been added in readme to explain installation.

Migration was quite straightforward, with those few problems :

* database reset was ensured by loading schemas, which doesn't work with
postgres
* id were hardcoded in specs, counting of schemas load to reset id
counter
* an UPPER function was used against a datetime field (created_at),
which does not work in postgres without a type cast.

Please not that database configuration here are for local use, because
(unless it has changed since last year) heroku override
config/database.yml with its own configuration (but this should have no
negative impact).

Close #1

Details :

* ADD pg gem
* CHANGE database configuration
* ADD installation instructions in readme
* FIX UPPER typecast for postgres (and fix sql injection btw)
* REFACTOR remove attempt to recreate db from spec_helper (thefuck?)
* ADD database_cleaner
* FIX hardcoded id in in programs controller spec
* FIX implicit id in program entries controller spec