mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 13:36:35 +00:00
Update fix-mariadb.py
This commit is contained in:
parent
919ba49e28
commit
960c07a846
@ -11,7 +11,12 @@ def _(arg_str):
|
||||
def SQLTable(arg_table):
|
||||
if not isinstance(arg_table, str):
|
||||
raise TypeError(type(arg_table))
|
||||
if not arg_table.startswith('sync_'):
|
||||
tables = db.connection.introspection.table_names(include_views=False)
|
||||
valid_table_name = (
|
||||
arg_table.startswith('sync_') and
|
||||
arg_table in tables
|
||||
)
|
||||
if not valid_table_name:
|
||||
raise ValueError(_('Invalid table name'))
|
||||
return str(arg_table)
|
||||
|
||||
@ -43,20 +48,27 @@ class Command(BaseCommand):
|
||||
_('An invalid database vendor is configured')
|
||||
+ f': {db.connection.vendor}'
|
||||
)
|
||||
|
||||
db_is_mariadb = (
|
||||
hasattr(db.connection, 'mysql_is_mariadb') and
|
||||
db.connection.is_usable() and
|
||||
db.connection.mysql_is_mariadb()
|
||||
)
|
||||
if not db_is_mariadb:
|
||||
raise CommandError(_('Not conbected to a MariaDB database server.'))
|
||||
|
||||
display_name = db.connection.display_name
|
||||
table_names = options.get('delete_table')
|
||||
|
||||
log.info('Start')
|
||||
if options['uuid_columns']:
|
||||
if 'uuid' != db.connection.data_types.get('UUIDField', ''):
|
||||
raise CommandError(_(
|
||||
f'The {display_name} database server does not support UUID columns.'
|
||||
))
|
||||
self.stdout.write('Time to update the columns!')
|
||||
|
||||
self.stdout.write('Tables to drop:')
|
||||
self.stdout.write('Tables to delete:')
|
||||
pp( table_names )
|
||||
|
||||
# All done
|
||||
|
Loading…
Reference in New Issue
Block a user