Skip to content

Commit

Permalink
fixed when migration was running two times; fixed bug when rsm tried …
Browse files Browse the repository at this point in the history
…to close already closed connection
  • Loading branch information
Vadim Tsander committed Aug 29, 2015
1 parent 906e760 commit 2aa2508
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion raw_sql_migrate/engines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def commit(self):
self._connection.commit()

def execute(self, sql, params=None, return_result=None):

if not params:
params = {}

Expand Down
7 changes: 4 additions & 3 deletions raw_sql_migrate/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ def migrate(self, migration_direction):
:param migration_direction: Direction towards which to migrate. Can be forward or backward.
:return:
"""

assert self.module is not None

if hasattr(self.module, migration_direction):
handler = getattr(self.module, migration_direction)
stdout.write('Migrating %s to migration %s in package %s\n' % (
migration_direction, self.py_module_name, self.py_package,
))
handler(database_api)
else:
raise IncorrectMigrationFile('Module %s has no %s function' % (
self.module, migration_direction,
Expand All @@ -76,7 +75,9 @@ def migrate(self, migration_direction):
self.delete_migration_history()
database_api.commit()
except Exception as e:
database_api.rollback()
if not database_api._connection.closed:
database_api.rollback()
database_api._connection.close()
raise e

def write_migration_history(self):
Expand Down

0 comments on commit 2aa2508

Please sign in to comment.