Skip to content

Commit

Permalink
Suppress unneeded mysql warning on tracking table creation.
Browse files Browse the repository at this point in the history
The call to create the __schema_migrations table prints a Warning,
even though the sql is wrapped in a 'create if not exists.'  This
warning is useless, omit.

Patch version bump.
  • Loading branch information
jzohrab committed May 7, 2016
1 parent d854c7b commit 182fac3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dbMigrator/mysqldatabasehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def user_defined_tables_exist(self, connection_hash):

def create_tracking_table(self, connection_hash):
"""Creates table if needed."""
# Mysql raising a 'table already exists' warning,
# regardless of the use of 'create table if not exists'.
# This can be ignored.
filterwarnings('ignore', category = MySQLdb.Warning)
# Using lowercase table name, as MySql is case-sensitive.
sql = """create table if not exists __schema_migrations
(
Expand All @@ -72,6 +76,7 @@ def create_tracking_table(self, connection_hash):
date_applied timestamp not null default CURRENT_TIMESTAMP
)"""
self.__execute(connection_hash, sql)
resetwarnings()


def is_in_tracking_table(self, connection_hash, script_name):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
setup(name='DbMigrator',
maintainer='Jeff Zohrab',
maintainer_email='[email protected]',
version='0.1',
version='0.1.1',
url='https://github.com/jzohrab/DbMigrator',
license='MIT',
packages=['DbMigrator'])

0 comments on commit 182fac3

Please sign in to comment.