Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 27fe8c24ec | |||
| eef1e4e8c6 |
@@ -20,7 +20,7 @@ depends_on: Sequence[str] | None = None
|
|||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
conn = op.get_bind()
|
conn = op.get_bind()
|
||||||
|
|
||||||
# Find code-server tool types with broken command overrides
|
# Fix tool_types templates in DB
|
||||||
result = conn.execute(
|
result = conn.execute(
|
||||||
sa.text("""
|
sa.text("""
|
||||||
SELECT id, compose_template
|
SELECT id, compose_template
|
||||||
@@ -64,45 +64,56 @@ def upgrade() -> None:
|
|||||||
)
|
)
|
||||||
print(f"Removed broken command override from LSIO template ({tool_id})")
|
print(f"Removed broken command override from LSIO template ({tool_id})")
|
||||||
|
|
||||||
# Also clean up existing instance compose files on disk
|
# Fix existing instance compose files on disk
|
||||||
result = conn.execute(
|
# Use information_schema to check if compose_path column exists
|
||||||
|
col_result = conn.execute(
|
||||||
sa.text("""
|
sa.text("""
|
||||||
SELECT id, compose_file_path
|
SELECT column_name
|
||||||
FROM tool_instances
|
FROM information_schema.columns
|
||||||
WHERE compose_file_path IS NOT NULL
|
WHERE table_name = 'tool_instances'
|
||||||
|
AND column_name = 'compose_path'
|
||||||
""")
|
""")
|
||||||
).fetchall()
|
).fetchone()
|
||||||
|
|
||||||
for instance_id, compose_path in result:
|
if col_result:
|
||||||
path = Path(compose_path)
|
result = conn.execute(
|
||||||
if not path.exists():
|
sa.text("""
|
||||||
continue
|
SELECT id, compose_path
|
||||||
try:
|
FROM tool_instances
|
||||||
content = path.read_text()
|
WHERE compose_path IS NOT NULL
|
||||||
data = yaml.safe_load(content)
|
""")
|
||||||
except Exception:
|
).fetchall()
|
||||||
continue
|
|
||||||
|
|
||||||
if not data or "services" not in data:
|
for instance_id, compose_path in result:
|
||||||
continue
|
path = Path(compose_path)
|
||||||
|
if not path.exists():
|
||||||
modified = False
|
continue
|
||||||
for svc in data["services"].values():
|
try:
|
||||||
image = svc.get("image", "")
|
content = path.read_text()
|
||||||
if not image or "linuxserver" not in image:
|
data = yaml.safe_load(content)
|
||||||
|
except Exception:
|
||||||
continue
|
continue
|
||||||
if "command" in svc:
|
|
||||||
cmd = svc["command"]
|
|
||||||
if "--bind-addr" in cmd or "--host" in cmd:
|
|
||||||
del svc["command"]
|
|
||||||
modified = True
|
|
||||||
|
|
||||||
if modified:
|
if not data or "services" not in data:
|
||||||
path.write_text(yaml.dump(data, default_flow_style=False))
|
continue
|
||||||
print(
|
|
||||||
f"Removed broken command override from instance compose "
|
modified = False
|
||||||
f"({instance_id})"
|
for svc in data["services"].values():
|
||||||
)
|
image = svc.get("image", "")
|
||||||
|
if not image or "linuxserver" not in image:
|
||||||
|
continue
|
||||||
|
if "command" in svc:
|
||||||
|
cmd = svc["command"]
|
||||||
|
if "--bind-addr" in cmd or "--host" in cmd:
|
||||||
|
del svc["command"]
|
||||||
|
modified = True
|
||||||
|
|
||||||
|
if modified:
|
||||||
|
path.write_text(yaml.dump(data, default_flow_style=False))
|
||||||
|
print(
|
||||||
|
f"Removed broken command override from instance compose "
|
||||||
|
f"({instance_id})"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user