Added SQLA 0.9 patch.
[openstack-build/ceilometer-build.git] / trusty / debian / patches / Make_ceilometer_work_with_sqla_0.9.x.patch
1 Description: Make ceilometer work with sqla 0.9.x
2  Ceilometer's migration 028 makes some very specific assumptions about sqla
3  data structures and exception paths, which are not true in sqla 0.9.x. In 0.8
4  you were shielded from errors on drop by sqla, but in 0.9 you get raw
5  exceptions from the db layer thrown all the way up, which causes a failure
6  condition when trying to delete the non existent alembic table.
7  .
8  We can get basically the same behavior as before by using the checkfirst=True
9  parameter on table definitions. This will actually ensure that we get the
10  table in question, and get the NoSuchTableError when we expect it.
11 Author: Sean Dague <sean.dague@samsung.com>
12 Date: Mon, 10 Mar 2014 22:06:32 +0000 (-0400)
13 X-Git-Url: https://review.openstack.org/gitweb?p=openstack%2Fceilometer.git;a=commitdiff_plain;h=63f6d6af77d5fe7227b074ddc3e1594a424873e6
14 Origin: upstream, https://review.openstack.org/#/c/79482/
15 Change-Id: Ida33a3030fb03c2f3eeed9f129fcc0063a7b7c4b
16
17 diff --git a/ceilometer/storage/sqlalchemy/migrate_repo/versions/028_alembic_migrations.py b/ceilometer/storage/sqlalchemy/migrate_repo/versions/028_alembic_migrations.py
18 index b527692..567620c 100644
19 --- a/ceilometer/storage/sqlalchemy/migrate_repo/versions/028_alembic_migrations.py
20 +++ b/ceilometer/storage/sqlalchemy/migrate_repo/versions/028_alembic_migrations.py
21 @@ -21,7 +21,10 @@ import sqlalchemy as sa
22  def get_alembic_version(meta):
23      """Return Alembic version or None if no Alembic table exists."""
24      try:
25 -        a_ver = sa.Table('alembic_version', meta, autoload=True)
26 +        a_ver = sa.Table(
27 +            'alembic_version',
28 +            meta,
29 +            autoload=True)
30          return sa.select([a_ver.c.version_num]).scalar()
31      except sa.exc.NoSuchTableError:
32          return None
33 @@ -29,7 +32,10 @@ def get_alembic_version(meta):
34  
35  def delete_alembic(meta):
36      try:
37 -        sa.Table('alembic_version', meta, autoload=True).drop()
38 +        sa.Table(
39 +            'alembic_version',
40 +            meta,
41 +            autoload=True).drop(checkfirst=True)
42      except sa.exc.NoSuchTableError:
43          pass
44