-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from jazzband/fix/django-migrartions
bug fixes and support several features for django migrations
- Loading branch information
Showing
10 changed files
with
894 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
from __future__ import absolute_import | ||
|
||
from django.db.models import Index | ||
|
||
|
||
class DistKey(Index): | ||
"""A single-field index denoting the distkey for a model. | ||
Use as follows: | ||
class MyModel(models.Model): | ||
... | ||
class Meta: | ||
indexes = [DistKey(fields=['customer_id'])] | ||
""" | ||
pass | ||
# flake8: noqa | ||
# for backward compatibility before 3.0.0 | ||
from .meta import DistKey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.db.models import Index | ||
|
||
|
||
class DistKey(Index): | ||
"""A single-field index denoting the distkey for a model. | ||
Use as follows: | ||
class MyModel(models.Model): | ||
... | ||
class Meta: | ||
indexes = [DistKey(fields=['customer_id'])] | ||
""" | ||
def deconstruct(self): | ||
path, expressions, kwargs = super().deconstruct() | ||
path = path.replace('django_redshift_backend.meta', 'django_redshift_backend') | ||
return (path, expressions, kwargs) | ||
|
||
|
||
class SortKey(str): | ||
"""A SORTKEY in Redshift, also valid as ordering in Django. | ||
https://docs.djangoproject.com/en/dev/ref/models/options/#django.db.models.Options.ordering | ||
Use as follows: | ||
class MyModel(models.Model): | ||
... | ||
class Meta: | ||
ordering = [SortKey('created_at'), SortKey('-id')] | ||
""" | ||
def __hash__(self): | ||
return hash(str(self)) | ||
|
||
def deconstruct(self): | ||
path = '%s.%s' % (self.__class__.__module__, self.__class__.__name__) | ||
path = path.replace('django_redshift_backend.meta', 'django_redshift_backend') | ||
return (path, [str(self)], {}) | ||
|
||
def __eq__(self, other): | ||
if self.__class__ == other.__class__: | ||
return self.deconstruct() == other.deconstruct() | ||
return NotImplemented |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.