mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-03-26 05:50:05 +01:00
- dockerManager: add 0001_initial migration (CREATE TABLE IF NOT EXISTS), migrate-and-retry on DB errors, safe error response, fix logging.CyberCPLogFileWriter.writeToFile - dockerManager/views: listContainersPage fallback HTML with error message if template fails - dockerManager/viewContainer: improve container log readability (font-size 1rem, color #f1f5f9, line-height 1.6) - baseTemplate: blockIPAddress also adds ban to firewall BannedIP model so Firewall > Banned IPs shows all - firewall: getBannedIPs migrate-and-retry on OperationalError/ProgrammingError; install runs migrate firewall - plogical/upgrade: syncBannedIPsJsonToDb() to sync JSON bans to firewall_bannedips; firewallMigrations() calls it; CyberPanelUpgrade runs firewallMigrations(); someDirectories creates /usr/local/CyberCP/data - install: explicit migrate firewall after global migrate
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Docker Manager initial migration.
|
|
# Creates dockerManager_containers table if not exists (safe when upgrade.dockerMigrations() already ran).
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def create_table_if_not_exists(apps, schema_editor):
|
|
"""Create dockerManager_containers with full schema. Idempotent via IF NOT EXISTS."""
|
|
if schema_editor.connection.vendor != 'mysql':
|
|
return
|
|
# Use raw SQL so we can do IF NOT EXISTS; matches upgrade.dockerMigrations() final schema
|
|
sql = """
|
|
CREATE TABLE IF NOT EXISTS dockerManager_containers (
|
|
id int(11) NOT NULL AUTO_INCREMENT,
|
|
name varchar(150) NOT NULL,
|
|
cid varchar(64) NOT NULL DEFAULT '',
|
|
admin_id int(11) NOT NULL,
|
|
image varchar(50) NOT NULL DEFAULT 'unknown',
|
|
tag varchar(50) NOT NULL DEFAULT 'unknown',
|
|
memory int(11) NOT NULL DEFAULT 0,
|
|
ports longtext NOT NULL,
|
|
volumes longtext NOT NULL,
|
|
env longtext NOT NULL,
|
|
startOnReboot int(11) NOT NULL DEFAULT 0,
|
|
network varchar(100) NOT NULL DEFAULT 'bridge',
|
|
network_mode varchar(50) NOT NULL DEFAULT 'bridge',
|
|
extra_options longtext NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY name (name),
|
|
KEY dockerManager_contai_admin_id_58fb62b7_fk_loginSyst (admin_id),
|
|
CONSTRAINT dockerManager_contai_admin_id_58fb62b7_fk_loginSyst
|
|
FOREIGN KEY (admin_id) REFERENCES loginSystem_administrator (id)
|
|
)
|
|
"""
|
|
schema_editor.execute(sql)
|
|
|
|
|
|
def noop_reverse(apps, schema_editor):
|
|
pass
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
('loginSystem', '__first__'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(create_table_if_not_exists, noop_reverse),
|
|
]
|