From 0d537fd9ecde2d51073c6e55a724dac8da2ecac7 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sun, 21 Sep 2025 13:04:51 +0500 Subject: [PATCH] bug fix: installation issues --- install/install.py | 23 +++++++++++++++++------ test.sh | 0 2 files changed, 17 insertions(+), 6 deletions(-) delete mode 100755 test.sh diff --git a/install/install.py b/install/install.py index dabdfbec4..d48f602a2 100644 --- a/install/install.py +++ b/install/install.py @@ -695,16 +695,27 @@ password="%s" logging.InstallLog.writeToFile("Running Django migrations...") preFlightsChecks.stdOut("Running Django migrations...") - # Reset migration history in database (in case of re-installation) - command = "/usr/local/CyberPanel-venv/bin/python manage.py migrate --fake-initial" + # Clean any existing migration files first (except __init__.py) + logging.InstallLog.writeToFile("Cleaning existing migration files...") + command = "find /usr/local/CyberCP -path '*/migrations/0*.py' -delete 2>/dev/null || true" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - # Create fresh migrations for all apps - command = "/usr/local/CyberPanel-venv/bin/python manage.py makemigrations" + # Clean any existing migration pyc files + command = "find /usr/local/CyberCP -path '*/migrations/*.pyc' -delete 2>/dev/null || true" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + + # Clean __pycache__ directories in migrations folders + command = "find /usr/local/CyberCP -path '*/migrations/__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + + # Create all migrations at once - Django will handle dependencies + logging.InstallLog.writeToFile("Creating fresh migrations for all apps...") + command = "/usr/local/CyberPanel-venv/bin/python manage.py makemigrations --noinput" preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - # Apply all migrations with --fake-initial to handle existing tables - command = "/usr/local/CyberPanel-venv/bin/python manage.py migrate --fake-initial" + # Apply all migrations + logging.InstallLog.writeToFile("Applying all migrations...") + command = "/usr/local/CyberPanel-venv/bin/python manage.py migrate --noinput" preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) logging.InstallLog.writeToFile("Django migrations completed successfully!") diff --git a/test.sh b/test.sh deleted file mode 100755 index e69de29bb..000000000