зеркало из https://github.com/mozilla/kitsune.git
[bug 617464] Move remaining MyISAM tables to InnoDB and add a test that keeps them that way.
Also make sure all newly created tables are UTF-8.
This commit is contained in:
Родитель
4ee4764cdd
Коммит
af6c15d572
|
@ -53,14 +53,20 @@ def get_user(username='jsocol'):
|
|||
' users fixture.' % username)
|
||||
|
||||
|
||||
class MigrationNumberTests(TestCase):
|
||||
class MigrationTests(TestCase):
|
||||
"""Sanity checks for the SQL migration scripts"""
|
||||
|
||||
@staticmethod
|
||||
def _migrations_path():
|
||||
"""Return the absolute path to the migration script folder."""
|
||||
return join(dirname(dirname(dirname(sumo.__file__))), 'migrations')
|
||||
|
||||
def test_unique(self):
|
||||
"""Assert that the numeric prefixes of the DB migrations are unique."""
|
||||
leading_digits = re.compile(r'^\d+')
|
||||
path = join(dirname(dirname(dirname(sumo.__file__))), 'migrations')
|
||||
seen_numbers = set()
|
||||
for node in listdir(path):
|
||||
match = leading_digits.match(node)
|
||||
for filename in listdir(self._migrations_path()):
|
||||
match = leading_digits.match(filename)
|
||||
if match:
|
||||
number = match.group()
|
||||
if number in seen_numbers:
|
||||
|
@ -68,3 +74,23 @@ class MigrationNumberTests(TestCase):
|
|||
(number, path))
|
||||
seen_numbers.add(number)
|
||||
|
||||
def test_innodb_and_utf8(self):
|
||||
"""Make sure each created table uses the InnoDB engine and UTF-8."""
|
||||
# Heuristic: make sure there are at least as many "ENGINE=InnoDB"s as
|
||||
# "CREATE TABLE"s. (There might be additional "InnoDB"s in ALTER TABLE
|
||||
# statements, which are fine.)
|
||||
path = self._migrations_path()
|
||||
# The ones before 66 have known failures.
|
||||
for filename in listdir(path)[66:]:
|
||||
with open(join(path, filename)) as f:
|
||||
contents = f.read()
|
||||
creates = contents.count('CREATE TABLE')
|
||||
engines = contents.count('ENGINE=InnoDB')
|
||||
encodings = (contents.count('CHARSET=utf8') +
|
||||
contents.count('CHARACTER SET utf8'))
|
||||
assert engines >= creates, ("There weren't as many "
|
||||
'occurrences of "ENGINE=InnoDB" as of "CREATE TABLE" in '
|
||||
'migration %s.' % filename)
|
||||
assert encodings >= creates, ("There weren't as many "
|
||||
'UTF-8 declarations as "CREATE TABLE" occurrences in '
|
||||
'migration %s.' % filename)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
ALTER TABLE customercare_cannedcategory ENGINE=InnoDB;
|
||||
ALTER TABLE customercare_cannedresponse ENGINE=InnoDB;
|
||||
ALTER TABLE customercare_categorymembership ENGINE=InnoDB;
|
||||
ALTER TABLE customercare_tweet ENGINE=InnoDB;
|
||||
ALTER TABLE flagit_flaggedobject ENGINE=InnoDB;
|
||||
ALTER TABLE schema_version ENGINE=InnoDB;
|
||||
ALTER TABLE upload_imageattachment ENGINE=InnoDB;
|
Загрузка…
Ссылка в новой задаче