Search code examples
pythondjangotransactionsdjango-south

Stuck in a django south migration - TransactionManagement error


I am having a trouble when applying a django south migration:

As always, I executed the migrate command after a successful schemamigration

python manage.py migrate webapp

The log console:

Running migrations for webapp:
 - Migrating forwards to 0020_auto__add_example.
 > webapp:0020_auto__add_example
TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK

The error is not related with the specific migration as if I move backwards and try another it shows the same message.

Edit. This is the log of the query:

(0.005) SELECT `south_migrationhistory`.`id`, `south_migrationhistory`.`app_name`, `south_migrationhistory`.`migration`, `south_migrationhistory`.`applied` FROM `south_migrationhistory` WHERE `south_migrationhistory`.`applied` IS NOT NULL ORDER BY `south_migrationhistory`.`applied` ASC; args=()
Running migrations for webapp:
 - Migrating forwards to 0020_auto__add_example.
 > webapp:0020_auto__add_example
(0.002) CREATE TABLE ROLLBACK_TEST (X INT); args=()
TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK

Solution

  • I am writing the answer to the problem I had as it can be useful for somebody.

    After some time of debugging I found that the problem was not related with django. It was an issue with the database and the virtual machine that hosts it.

    I restarted the database machine and the migrations are now working.