diff options
author | Joe Gordon <joe.gordon0@gmail.com> | 2014-05-20 16:24:29 +0900 |
---|---|---|
committer | Nikhil Manchanda <SlickNik@gmail.com> | 2014-05-20 02:58:49 -0700 |
commit | f9d015c29109a5b3a0b148df4127e4f35d76d72d (patch) | |
tree | 07ff43dcea4a5cb35c491046e1d31096c8ed4c59 /trove/db/sqlalchemy/migrate_repo/versions | |
parent | d4f26144ec1242114fef284a26697c0f40d99b12 (diff) | |
download | trove-f9d015c29109a5b3a0b148df4127e4f35d76d72d.tar.gz |
Specify correct constraint name for postgresql
The UniqueConstraint is not named 'name,' this causes postgres to fail
with the following error:
UTC ERROR: constraint "name" of relation "datastore_versions" does not
exist
The constraint name should be 'datastore_versions_name_key' in the case
of postgresql.
Since postgres isn't tested in trove's gate yet (Fix:
I53e7fa2729542b88b43cd3de51e15118adaeec57) this has been tested locally
to make sure it stack.sh (which runs trove-manage db_sync) works.
Co-Authored-By: Nikhil Manchanda <SlickNik@gmail.com>
Change-Id: I265925566b8e84d92c838cb3b39ad1f8502cd052
Related-Bug: #1321093
Diffstat (limited to 'trove/db/sqlalchemy/migrate_repo/versions')
-rw-r--r-- | trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py b/trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py index ea9070b9..3a04f13c 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py @@ -29,8 +29,13 @@ def upgrade(migrate_engine): # drop the unique index on the name column - unless we are # using sqlite - it doesn't support dropping unique constraints - if migrate_engine.name != "sqlite": + uc = None + if migrate_engine.name == "mysql": uc = UniqueConstraint('name', table=datastore_versions, name='name') + elif migrate_engine.name == "postgresql": + uc = UniqueConstraint('name', table=datastore_versions, + name='datastore_versions_name_key') + if uc: try: uc.drop() except OperationalError as e: |