Skip to content

Commit

Permalink
Merge pull request #64 from eMBee/mysql-cleanup
Browse files Browse the repository at this point in the history
fixup: remove mysql dependency in migration
  • Loading branch information
mariobehling authored Mar 26, 2024
2 parents 3d306c5 + a633419 commit 31de233
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions src/pretix/base/migrations/0102_auto_20181017_0024.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from django.core.exceptions import ImproperlyConfigured
from django.db import migrations, models
from django_mysql.checks import mysql_connections
from django_mysql.utils import connection_is_mariadb


def set_attendee_name_parts(apps, schema_editor):
Expand All @@ -24,39 +22,14 @@ def set_attendee_name_parts(apps, schema_editor):
ia.save(update_fields=['name_parts'])


def check_mysqlversion(apps, schema_editor):
errors = []
any_conn_works = False
conns = list(mysql_connections())
found = 'Unknown version'
for alias, conn in conns:
if connection_is_mariadb(conn) and hasattr(conn, 'mysql_version'):
if conn.mysql_version >= (10, 2, 7):
any_conn_works = True
else:
found = 'MariaDB ' + '.'.join(str(v) for v in conn.mysql_version)
elif hasattr(conn, 'mysql_version'):
if conn.mysql_version >= (5, 7):
any_conn_works = True
else:
found = 'MySQL ' + '.'.join(str(v) for v in conn.mysql_version)

if conns and not any_conn_works:
raise ImproperlyConfigured(
'As of pretix 2.2, you need MySQL 5.7+ or MariaDB 10.2.7+ to run pretix. However, we detected a '
'database connection to {}'.format(found)
)
return errors


class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0101_auto_20181025_2255'),
]

operations = [
migrations.RunPython(
check_mysqlversion, migrations.RunPython.noop
migrations.RunPython.noop
),
migrations.RenameField(
model_name='cartposition',
Expand Down

0 comments on commit 31de233

Please sign in to comment.