Skip to content

Commit 441f4e4

Browse files
authored
Merge pull request #14 from singleplatform-eng/SPROD-7696_db_agnostic_migrations
SPROD-7696 add check for database vendor when creating partial length index
2 parents 3e34f66 + 2355bbc commit 441f4e4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

django_celery_beat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from collections import namedtuple
1212

13-
__version__ = '1.4.0+singleplatform.3'
13+
__version__ = '1.4.0+singleplatform.4'
1414
__author__ = 'Ask Solem'
1515
__contact__ = '[email protected]'
1616
__homepage__ = 'https://github.com/celery/django-celery-beat'

django_celery_beat/models.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ def cronexp(field):
4343

4444

4545
class CeleryMySQLIndex(Index):
46-
def create_sql(self, model, schema_editor, using=''):
46+
47+
def _is_mysql_backend(self, connection):
48+
return connection.vendor.startswith('mysql')
49+
50+
def _create_sql(self, model, schema_editor, using=''):
4751
sql_create_index = 'CREATE INDEX %(name)s ON %(table)s (%(columns)s(%(size)d))%(extra)s'
4852
sql_parameters = self.get_sql_create_template_values(
4953
model,
@@ -58,6 +62,12 @@ def create_sql(self, model, schema_editor, using=''):
5862
sql = sql_create_index % sql_parameters
5963
return sql
6064

65+
def create_sql(self, model, schema_editor, using=''):
66+
if self._is_mysql_backend(schema_editor.connection):
67+
return self._create_sql(model, schema_editor, using=using)
68+
else:
69+
return super(CeleryMySQLIndex, self).create_sql(model, schema_editor, using=using)
70+
6171

6272
@python_2_unicode_compatible
6373
class SolarSchedule(models.Model):

0 commit comments

Comments
 (0)