bug fix: remove migrations commands

This commit is contained in:
usmannasir
2025-10-01 00:20:05 +05:00
parent 0e59310810
commit 6cbcc2862f
3 changed files with 44 additions and 25 deletions

4
.idea/workspace.xml generated
View File

@@ -4,7 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="5251c5c9-f2a1-41f2-bc76-10b517091df1" name="Changes" comment="" />
<list default="true" id="5251c5c9-f2a1-41f2-bc76-10b517091df1" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/install/install.py" beforeDir="false" afterPath="$PROJECT_DIR$/install/install.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />

View File

@@ -36,36 +36,48 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'baseTemplate',
# Core apps (no dependencies on other custom apps)
'loginSystem', # Base app - many apps depend on Administrator model
'packages', # websiteFunctions depends on this
# Apps with single dependency
'websiteFunctions', # Depends on packages and loginSystem
'baseTemplate', # Depends on loginSystem
'userManagment', # Depends on loginSystem
'dns', # Depends on loginSystem
# Apps depending on websiteFunctions
'databases', # Depends on websiteFunctions
'ftp', # Depends on websiteFunctions
'filemanager', # Depends on websiteFunctions
'mailServer', # Depends on websiteFunctions, ChildDomains
# Apps with multiple or complex dependencies
'emailPremium', # Depends on mailServer
'emailMarketing', # Depends on websiteFunctions and loginSystem
'cloudAPI', # Depends on websiteFunctions
'containerization', # Depends on websiteFunctions
'IncBackups', # Depends on websiteFunctions and loginSystem
'CLManager', # Depends on packages
# Apps with dependencies on loginSystem only
's3Backups', # Depends on loginSystem
'dockerManager', # Depends on loginSystem
'aiScanner', # Depends on loginSystem
# Independent apps (no model dependencies found)
'firewall',
'loginSystem',
'packages',
'websiteFunctions',
'tuning',
'serverStatus',
'dns',
'ftp',
'userManagment',
'databases',
'mailServer',
'serverLogs',
'backup',
'managePHP',
'manageSSL',
'api',
'filemanager',
'manageServices',
'pluginHolder',
'emailPremium',
'emailMarketing',
'cloudAPI',
'highAvailability',
's3Backups',
'dockerManager',
'containerization',
'CLManager',
'IncBackups',
'aiScanner',
# 'WebTerminal'
]

View File

@@ -2149,15 +2149,15 @@ password="%s"
# Clean any existing migration files first (except __init__.py and excluding virtual environment)
logging.InstallLog.writeToFile("Cleaning existing migration files...")
# Only delete migration files from app directories, not from lib/lib64/bin directories
command = "find /usr/local/CyberCP -type f -path '*/migrations/0*.py' ! -path '*/lib/*' ! -path '*/lib64/*' ! -path '*/bin/*' -delete 2>/dev/null || true"
command = "bash -c \"find /usr/local/CyberCP -type f -path '*/migrations/0*.py' ! -path '*/lib/*' ! -path '*/lib64/*' ! -path '*/bin/*' -delete 2>/dev/null || true\""
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
# Clean any existing migration pyc files (excluding virtual environment)
command = "find /usr/local/CyberCP -type f -path '*/migrations/*.pyc' ! -path '*/lib/*' ! -path '*/lib64/*' ! -path '*/bin/*' -delete 2>/dev/null || true"
command = "bash -c \"find /usr/local/CyberCP -type f -path '*/migrations/*.pyc' ! -path '*/lib/*' ! -path '*/lib64/*' ! -path '*/bin/*' -delete 2>/dev/null || true\""
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
# Clean __pycache__ directories in migrations folders (excluding virtual environment)
command = "find /usr/local/CyberCP -type d -path '*/migrations/__pycache__' ! -path '*/lib/*' ! -path '*/lib64/*' ! -path '*/bin/*' -exec rm -rf {} + 2>/dev/null || true"
command = "bash -c \"find /usr/local/CyberCP -type d -path '*/migrations/__pycache__' ! -path '*/lib/*' ! -path '*/lib64/*' ! -path '*/bin/*' -exec rm -rf {} + 2>/dev/null || true\""
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
# Fix baseTemplate migrations - ensure required migration files exist
@@ -2190,8 +2190,13 @@ password="%s"
preFlightsChecks.stdOut("ERROR: No Python virtual environment found!", 0)
return False
# Create all migrations at once - Django will handle dependencies
logging.InstallLog.writeToFile("Creating fresh migrations for all apps...")
# Create migrations in dependency order - loginSystem first since other apps depend on it
logging.InstallLog.writeToFile("Creating migrations for loginSystem first...")
command = f"{python_path} manage.py makemigrations loginSystem --noinput"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
# Now create migrations for all other apps
logging.InstallLog.writeToFile("Creating migrations for all other apps...")
command = f"{python_path} manage.py makemigrations --noinput"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)