refactor: remove all backward compatibility code across 70 files
Some checks failed
CI / ruff (push) Successful in 11s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has started running

Clean up 28 backward compatibility instances identified in the codebase.
The app is not live, so all shims are replaced with the target architecture:

- Remove legacy Inventory.location column (use bin_location exclusively)
- Remove dashboard _extract_metric_value helper (use flat metrics dict)
- Remove legacy stat field duplicates (total_stores, total_imports, etc.)
- Remove 13 re-export shims and class aliases across modules
- Remove module-enabling JSON fallback (use PlatformModule junction table)
- Remove menu_to_legacy_format() conversion (return dataclasses directly)
- Remove title/description from MarketplaceProductBase schema
- Clean billing convenience method docstrings
- Clean test fixtures and backward-compat comments
- Add PlatformModule seeding to init_production.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 13:20:29 +01:00
parent b0db8133a0
commit aad18c27ab
70 changed files with 501 additions and 841 deletions

View File

@@ -37,7 +37,7 @@ from app.core.config import (
from app.core.database import SessionLocal
from app.core.environment import is_production
from app.modules.billing.models.subscription import SubscriptionTier
from app.modules.tenancy.models import AdminSetting, Platform, User
from app.modules.tenancy.models import AdminSetting, Platform, PlatformModule, User
from app.modules.tenancy.services.permission_discovery_service import (
permission_discovery_service,
)
@@ -140,7 +140,7 @@ def create_default_platforms(db: Session) -> list[Platform]:
"code": "oms",
"name": "Orion OMS",
"description": "Order Management System for multi-store e-commerce",
"domain": "oms.lu",
"domain": "omsflow.lu",
"path_prefix": "oms",
"default_language": "fr",
"supported_languages": ["fr", "de", "en"],
@@ -447,6 +447,50 @@ def create_subscription_tiers(db: Session, platform: Platform) -> int:
return tiers_created
def create_platform_modules(db: Session, platforms: list[Platform]) -> int:
"""Create PlatformModule records for all platforms.
Enables all discovered modules for each platform so the app works
out of the box. Admins can disable optional modules later via the API.
"""
from app.modules.registry import MODULES
now = datetime.now(UTC)
records_created = 0
for platform in platforms:
for code in MODULES:
# Check if record already exists
existing = db.execute(
select(PlatformModule).where(
PlatformModule.platform_id == platform.id,
PlatformModule.module_code == code,
)
).scalar_one_or_none()
if existing:
continue
pm = PlatformModule(
platform_id=platform.id,
module_code=code,
is_enabled=True,
enabled_at=now,
config={},
)
db.add(pm)
records_created += 1
db.flush()
if records_created > 0:
print_success(f"Created {records_created} platform module records")
else:
print_warning("Platform module records already exist")
return records_created
def verify_rbac_schema(db: Session) -> bool:
"""Verify that RBAC schema is in place."""
@@ -531,6 +575,10 @@ def initialize_production(db: Session, auth_manager: AuthManager):
else:
print_warning("OMS platform not found, skipping tier seeding")
# Step 7: Create platform module records
print_step(7, "Creating platform module records...")
create_platform_modules(db, platforms)
# Commit all changes
db.commit()
print_success("All changes committed")
@@ -546,10 +594,12 @@ def print_summary(db: Session):
setting_count = db.query(AdminSetting).count()
platform_count = db.query(Platform).count()
tier_count = db.query(SubscriptionTier).filter(SubscriptionTier.is_active.is_(True)).count()
module_count = db.query(PlatformModule).count()
print("\n📊 Database Status:")
print(f" Admin users: {user_count}")
print(f" Platforms: {platform_count}")
print(f" Platform mods: {module_count}")
print(f" Admin settings: {setting_count}")
print(f" Sub. tiers: {tier_count}")