Change services.id to a UUID

Ideally all the primary keys in the db would be UUID in order to guarantee unique ids across distributed dbs.
This updates the services.id to a UUID. All the tables with a foreign key to the services.id are also updated.
The endpoints no longer state a data type of the <service_id> path param.
All the tests are updated to reflect this update.

The thing to pay attention to is the 0011_uuid_service_id.py migration script.
This commit must go with a commit on the notifications_admin app to keep things working.
There will be a small outage until both deploys have happened.
This commit is contained in:
Rebecca Law
2016-02-02 14:16:08 +00:00
parent 1277837e00
commit b5c662eca8
15 changed files with 195 additions and 63 deletions

View File

@@ -315,7 +315,7 @@ def test_get_user_service(notify_api, notify_db, notify_db_session, sample_servi
assert resp.status_code == 200
json_resp = json.loads(resp.get_data(as_text=True))
assert json_resp['data']['name'] == another_name
assert json_resp['data']['id'] == another_service.id
assert json_resp['data']['id'] == str(another_service.id)
def test_get_user_service_user_not_exists(notify_api, notify_db, notify_db_session, sample_service,
@@ -348,12 +348,14 @@ def test_get_user_service_service_not_exists(notify_api, notify_db, notify_db_se
with notify_api.test_client() as client:
user = User.query.first()
assert Service.query.count() == 2
import uuid
missing_service_id = uuid.uuid4()
auth_header = create_authorization_header(service_id=sample_admin_service_id,
path=url_for('user.get_service_by_user_id', user_id=user.id,
service_id="12323423"),
service_id=missing_service_id),
method='GET')
resp = client.get(
url_for('user.get_service_by_user_id', user_id=user.id, service_id="12323423"),
url_for('user.get_service_by_user_id', user_id=user.id, service_id=missing_service_id),
headers=[('Content-Type', 'application/json'), auth_header])
assert resp.status_code == 404
json_resp = json.loads(resp.get_data(as_text=True))