{"action":"created","issue":{"url":"https://api.github.com/repos/CCI-MOC/haas/issues/556","repository_url":"https://api.github.com/repos/CCI-MOC/haas","labels_url":"https://api.github.com/repos/CCI-MOC/haas/issues/556/labels{/name}","comments_url":"https://api.github.com/repos/CCI-MOC/haas/issues/556/comments","events_url":"https://api.github.com/repos/CCI-MOC/haas/issues/556/events","html_url":"https://github.com/CCI-MOC/haas/pull/556","id":141753613,"number":556,"title":"Flask-SQLAlchemy and Database Migrations","user":{"login":"zenhack","id":883774,"avatar_url":"https://avatars.githubusercontent.com/u/883774?v=3","gravatar_id":"","url":"https://api.github.com/users/zenhack","html_url":"https://github.com/zenhack","followers_url":"https://api.github.com/users/zenhack/followers","following_url":"https://api.github.com/users/zenhack/following{/other_user}","gists_url":"https://api.github.com/users/zenhack/gists{/gist_id}","starred_url":"https://api.github.com/users/zenhack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenhack/subscriptions","organizations_url":"https://api.github.com/users/zenhack/orgs","repos_url":"https://api.github.com/users/zenhack/repos","events_url":"https://api.github.com/users/zenhack/events{/privacy}","received_events_url":"https://api.github.com/users/zenhack/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/CCI-MOC/haas/labels/discuss","name":"discuss","color":"e6e6e6"},{"url":"https://api.github.com/repos/CCI-MOC/haas/labels/Waiting%20on%20reviewer","name":"Waiting on reviewer","color":"999999"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-18T02:05:54Z","updated_at":"2016-03-22T11:41:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CCI-MOC/haas/pulls/556","html_url":"https://github.com/CCI-MOC/haas/pull/556","diff_url":"https://github.com/CCI-MOC/haas/pull/556.diff","patch_url":"https://github.com/CCI-MOC/haas/pull/556.patch"},"body":"This isn't quite ready yet, but it's worth having folks start looking at it. This is both moving over to the flask sqlalchemy extension and adding a database migration infrastructure. It includes a migration script that upgrades the content of my auth pr (#491) to the contents of the latest commit on this repository. Note that it does *not* handle upgrading the database for the OBM work that @SahilTikale did, since that was merged first.\r\n\r\nIt also includes some changes to the travis stuff; we run `tests/stress.py`, and we run the tests against both sqlite and postgres.\r\n\r\nIt does not *yet* include automated testing for the database migration infrastructure; I wanted to run my ideas about how to do that by you guys first:\r\n\r\n1. Write a function like `initial_db` in `tests/unit/api/auth.py` (or just use that one), which populates a db with some useful objects.\r\n2. Before making any changes to the schema, use said script to populate a postgres database, then dump the database as a sql script (via `pg_dump`). Commit the result.\r\n3. Make your changes, and add a migration script.\r\n4. Testing will consist of:\r\n  1. run the sql script to populate a (previously empty) database.\r\n  2. run the migration script, to upgrade to the latest schema.\r\n  3. run a series of tests that expect said initial database.\r\n\r\nI'm also still trying to pin down how the schema changes due to adding and removing extensions should work. Alembic has some support for branching and merging schema, but I need to do a bit more reading before I can decide what I think the right thing to do is there.\r\n\r\nI also need to write some developer docs describing how to do database migrations.\r\n\r\n@SahilTikale, @henn, let me know what you think."},"comment":{"url":"https://api.github.com/repos/CCI-MOC/haas/issues/comments/199775087","html_url":"https://github.com/CCI-MOC/haas/pull/556#issuecomment-199775087","issue_url":"https://api.github.com/repos/CCI-MOC/haas/issues/556","id":199775087,"user":{"login":"zenhack","id":883774,"avatar_url":"https://avatars.githubusercontent.com/u/883774?v=3","gravatar_id":"","url":"https://api.github.com/users/zenhack","html_url":"https://github.com/zenhack","followers_url":"https://api.github.com/users/zenhack/followers","following_url":"https://api.github.com/users/zenhack/following{/other_user}","gists_url":"https://api.github.com/users/zenhack/gists{/gist_id}","starred_url":"https://api.github.com/users/zenhack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenhack/subscriptions","organizations_url":"https://api.github.com/users/zenhack/orgs","repos_url":"https://api.github.com/users/zenhack/repos","events_url":"https://api.github.com/users/zenhack/events{/privacy}","received_events_url":"https://api.github.com/users/zenhack/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T11:41:35Z","updated_at":"2016-03-22T11:41:35Z","body":"I'm pretty sure I understand the nature of the test failure. basically, pytest is loading env.py at an inappropriate time (when collecting tests). env.py should never be executed outside of a specific context set up by alembic, and so it's freaking out. I need to figure out how to get pytest to not do that, but I don't think there's anything else wrong."}}