Update fix-mariadb.py

This commit is contained in:
tcely 2025-05-04 03:58:56 -04:00 committed by GitHub
parent 5235c53dad
commit ba87e39e3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -63,9 +63,9 @@ class Command(BaseCommand):
fields = self._get_fields(table_str)
return 'uuid' in [ f.name for f in fields if 'char(32)' == f.type_code ]
def _uuid_column_type(self, table_str, /):
def _column_type(self, table_str, column_str='uuid', /):
fields = self._get_fields(table_str)
return [ f.type_code for f in fields if 'uuid' == f.name ][0]
return [ f.type_code for f in fields if column_str.lower() == f.name.lower() ][0]
def handle(self, *args, **options):
if 'mysql' != db.connection.vendor:
@ -96,9 +96,11 @@ class Command(BaseCommand):
self._using_char_for_uuid('sync_media')
)
if not both_tables:
if 'uuid' == self._uuid_column_type('sync_source').lower():
if 'uuid' == self._column_type('sync_source', 'uuid').lower():
log.notice('The source table is already using a native UUID column.')
elif 'uuid' == self._uuid_column_type('sync_media').lower():
elif 'uuid' == self._column_type('sync_media', 'uuid').lower():
log.notice('The media table is already using a native UUID column.')
elif 'uuid' == self._column_type('sync_media', 'source_id').lower():
log.notice('The media table is already using a native UUID column.')
else:
raise CommandError(_(