Fix check_003 method.

This commit fixes the check on migration 003 in test_migrations.
Previously, when this method was added it didn't check that the
data in the type column previously in the images table was moved
correctly into the image_properties table. This commit adds these
data checks.

Change-Id: Ia3906c8497218c8a3d2a13b0c99a6aa566977ed4
Fix circular import in glance/db/sqlalchemy

Fix running test_migration solely.

api.py depends on models.py that depends on api.py.
Import statements in these files are such that api.py
must be imported before models.py. That's why usually
test_migrations doesn't fail when all tests are launched.
However, thus test_migration depends on test running order
making testing procedure unreliable, including parallel testing.

Move glance.db.sqlalchemy.api import to the only place
where it's required in models.py

Change-Id: Ib20dde8edd3473595aac1ca8bbaa5a0d3116a697
Fixes: bug #1154058
Declare index on ImageMember model

This index was added in migration 008. However, it was not on the model,
which meant any autocreated db would not have it.

Fixes bug 1154777

Change-Id: I34590ffebaf547be9a12e5a85216cda145d9e8db
Merge "Fix circular import in glance/db/sqlalchemy"
Merge "Fix check_003 method."
Merge "Declare index on ImageMember model"
Fix uniqueness constraint on image_members table.

Fixes bug #1098700.

Previously, deleting then re-creating an image member failed with
500 ServerError due to the registry service failing to commit
the update to the image_members table.

The problem arose because the declared uniqueness constraint on that
table only spanned the image_id and member columns, but did not take
into account that deleted rows are left in situ with the deleted_at
and deleted columns set as appropriate. Hence the unique constraint
was violated by the addition of the new row.

We modify the uniqueness constraint via a migration script to take
account of the deleted_at column also (NULL for live memberships).

Note that the new ability to recreate an image membership cannot be
be asserted in a functional test, as these tests are based on sqlite
which does not support 'ALTER TABLE DROP CONSTRAINT'.

Change-Id: I175801ba95ecd9295791bb12e9096f59efa19c02
Merge remote-tracking branch 'm_src_repo/webob-issue' into build-temp