Created
May 21, 2021 20:59
-
-
Save yuekui/f1277283b7470800c99a0d582817e8ed to your computer and use it in GitHub Desktop.
Monkey-patch Django mysql schema to skip setting default value when altering BLOB/TEXT fields
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
from django.db.backends.mysql import schema | |
class DatabaseSchemaEditor(schema.DatabaseSchemaEditor): | |
@property | |
def _supports_limited_data_type_defaults(self): | |
# MariaDB >= 10.2.1 supports defaults for BLOB and TEXT. | |
if self.connection.mysql_is_mariadb: | |
return self.connection.mysql_version >= (10, 2, 1) | |
return False | |
schema.DatabaseSchemaEditor = DatabaseSchemaEditor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment