Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Python 3.6-3.7, Django 3.2-4.1 #69

Merged
merged 9 commits into from
Feb 15, 2025
64 changes: 21 additions & 43 deletions django_zero_downtime_migrations/backends/postgres/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,49 +955,27 @@ def _patched_iter_column_sql(
):
yield self.connection.ops.tablespace_sql(tablespace, inline=True)

if django.VERSION >= (4, 1):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was automatable with django-upgrade, unlike the other branches where the version is specified as django.VERSION[:2]

probably one to keep in mind for the future where adding these kind of branches: https://github.com/adamchainz/django-upgrade?tab=readme-ov-file#versioned-blocks

def _iter_column_sql(
self, column_db_type, params, model, field, field_db_params, include_default
):
if not include_default:
yield from super()._iter_column_sql(
column_db_type,
params,
model,
field,
field_db_params,
include_default,
)
else:
yield from self._patched_iter_column_sql(
column_db_type,
params,
model,
field,
field_db_params,
include_default,
)
else:
def _iter_column_sql(
self, column_db_type, params, model, field, include_default
):
if not include_default:
yield from super()._iter_column_sql(
column_db_type,
params,
model,
field,
include_default,
)
else:
yield from self._patched_iter_column_sql(
column_db_type,
params,
model,
field,
{},
include_default,
)
def _iter_column_sql(
self, column_db_type, params, model, field, field_db_params, include_default
):
if not include_default:
yield from super()._iter_column_sql(
column_db_type,
params,
model,
field,
field_db_params,
include_default,
)
else:
yield from self._patched_iter_column_sql(
column_db_type,
params,
model,
field,
field_db_params,
include_default,
)

def _alter_column_set_not_null(self, model, new_field):
self.deferred_sql.append(self._sql_column_not_null % {
Expand Down