IntegrityError running sql tests on MySQL/Postgres

Bug #1169381 reported by Jamie Lennox on 2013-04-16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Jamie Lennox

Bug Description

When running tests/ against a MySQL or Postgres database the tests fail with an IntegrityError.


It appears that this is because migration 020 imposes a foreign key restraint in downgrade that wasn't initially present.

Printing the table structure of 'metadata' before migration 020 gives:

Table('metadata', MetaData(bind=Engine(mysql://root:test@localhost/keystonetest?charset=utf8)),
Column(u'user_id', VARCHAR(length=64), table=<metadata>, primary_key=True, nullable=False),
Column(u'tenant_id', VARCHAR(length=64), table=<metadata>, primary_key=True, nullable=False),
Column(u'data', MEDIUMTEXT(), table=<metadata>), schema=None)

Printing the table structure of 'metadata' after migration 020 downgrade gives:

Table('metadata', MetaData(bind=Engine(mysql://root:test@localhost/keystonetest?charset=utf8)),
Column('user_id', String(length=64), ForeignKey(''), table=<metadata>, primary_key=True, nullable=False),
Column('tenant_id', String(length=64), table=<metadata>, primary_key=True, nullable=False),
Column('data', Text(), table=<metadata>), schema=None)

This is not relevant to whether user_id should be a foreign key, simply that the downgrade does not match the upgrade.

Fix proposed to branch: master

Changed in keystone:
assignee: nobody → Jamie Lennox (jamielennox)
status: New → In Progress

Submitter: Jenkins
Branch: master

commit 2eab5fd2b7f980d355caa53be582aa07dc65a8e2
Author: Jamie Lennox <email address hidden>
Date: Tue Apr 16 13:14:21 2013 +1000

    Remove new constraint from migration downgrade.

    Remove the foreign key constraint for user_id. Whilst it is a foreign
    key the constraint was not set in the previous schema. Also sets the
    columns names to unicode as they were in previous schema.

    Fixes: bug 1169381
    Change-Id: I9b1ac5305622d68a7e124ba8100a4b8166b43af0

Changed in keystone:
status: In Progress → Fix Committed
Dolph Mathews (dolph) on 2013-04-24
tags: added: grizzly-backport-potential
Brant Knudson (blk-u) wrote :

This introduced or exposed a problem with sqlite testing:

Thierry Carrez (ttx) on 2013-05-29
Changed in keystone:
milestone: none → havana-1
status: Fix Committed → Fix Released
Dolph Mathews (dolph) on 2013-09-19
Changed in keystone:
importance: Undecided → Medium
Thierry Carrez (ttx) on 2013-10-17
Changed in keystone:
milestone: havana-1 → 2013.2
Alan Pevec (apevec) on 2014-03-30
tags: removed: grizzly-backport-potential
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers