mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 19:24:23 +00:00
New features on branch v6.2.5:
- New capability in base.py to patch the database
- Some minor updates on installation.py.
- Translation feature:
- New library requirement (pyyaml)
- New translation systeme implemented.
- New class translation.py added.
- Module folder updated by adding new folder language.
- Core module updated as well with new language folder.
This commit is contained in:
22
core/base.py
22
core/base.py
@@ -564,6 +564,9 @@ class Base:
|
||||
self.db_execute_query(table_core_channel)
|
||||
self.db_execute_query(table_core_config)
|
||||
|
||||
# Patch database
|
||||
self.db_patch(self.Config.TABLE_ADMIN, "language", "TEXT")
|
||||
|
||||
if self.install:
|
||||
self.Loader.ModuleUtils.db_register_module('mod_command', 'sys', True)
|
||||
self.Loader.ModuleUtils.db_register_module('mod_defender', 'sys', True)
|
||||
@@ -584,6 +587,25 @@ class Base:
|
||||
|
||||
return response
|
||||
|
||||
def db_is_column_exist(self, table_name: str, column_name: str) -> bool:
|
||||
q = self.db_execute_query(f"PRAGMA table_info({table_name})")
|
||||
existing_columns = [col[1] for col in q.fetchall()]
|
||||
|
||||
if column_name in existing_columns:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def db_patch(self, table_name: str, column_name: str, column_type: str) -> bool:
|
||||
if not self.db_is_column_exist(table_name, column_name):
|
||||
patch = f"ALTER TABLE {self.Config.TABLE_ADMIN} ADD COLUMN {column_name} {column_type}"
|
||||
self.db_execute_query(patch)
|
||||
self.logs.debug(f"The patch has been applied")
|
||||
self.logs.debug(f"Table name: {table_name}, Column name: {column_name}, Column type: {column_type}")
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def db_close(self) -> None:
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user