mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 03:10:46 +08:00
Fix topology sync failing when ume_topo_link ifname columns are missing.
Ensure startup safety-net adds a_ifname/z_ifname on brownfield DBs, and normalize ADD COLUMN IF NOT EXISTS for SQLite tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
9ba4d051dc
commit
527472976a
2 changed files with 59 additions and 2 deletions
|
|
@ -10,7 +10,11 @@ from sqlalchemy.orm import sessionmaker
|
|||
|
||||
from netx_api.db import Base
|
||||
import netx_api.models # noqa: F401
|
||||
from netx_api.schema_patches import apply_auth_schema_patches, apply_domain_schema_patches
|
||||
from netx_api.schema_patches import (
|
||||
apply_auth_schema_patches,
|
||||
apply_domain_schema_patches,
|
||||
apply_topology_schema_safety_net,
|
||||
)
|
||||
|
||||
|
||||
class SchemaPatchesTests(unittest.TestCase):
|
||||
|
|
@ -34,6 +38,28 @@ class SchemaPatchesTests(unittest.TestCase):
|
|||
self.assertIn("expires_at", token_cols)
|
||||
self.assertIn("auth_session", insp.get_table_names())
|
||||
|
||||
def test_topology_safety_net_adds_ume_link_ifnames(self) -> None:
|
||||
"""Brownfield: table without ifnames; safety-net must add them (sync depends on it)."""
|
||||
with self.engine.begin() as conn:
|
||||
conn.execute(text("DROP TABLE IF EXISTS ume_topo_link"))
|
||||
conn.execute(
|
||||
text(
|
||||
"""
|
||||
CREATE TABLE ume_topo_link (
|
||||
link_id VARCHAR(128) PRIMARY KEY,
|
||||
name VARCHAR(1024) DEFAULT '',
|
||||
a_ptp VARCHAR(256) DEFAULT '',
|
||||
z_ptp VARCHAR(256) DEFAULT ''
|
||||
)
|
||||
"""
|
||||
)
|
||||
)
|
||||
apply_topology_schema_safety_net(conn)
|
||||
apply_topology_schema_safety_net(conn)
|
||||
cols = {c["name"] for c in inspect(self.engine).get_columns("ume_topo_link")}
|
||||
self.assertIn("a_ifname", cols)
|
||||
self.assertIn("z_ifname", cols)
|
||||
|
||||
def test_domain_patches_do_not_raise(self) -> None:
|
||||
with self.engine.begin() as conn:
|
||||
apply_domain_schema_patches(conn)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue