|
@@ -432,7 +432,14 @@ async def create_model(
|
|
|
|
|
|
|
|
if any_existing:
|
|
if any_existing:
|
|
|
if any_existing.deleted_at is not None:
|
|
if any_existing.deleted_at is not None:
|
|
|
- # Soft-deleted record found - permanently delete it to free up the name
|
|
|
|
|
|
|
+ # Soft-deleted record found
|
|
|
|
|
+ if not model_in.overwrite_deleted:
|
|
|
|
|
+ # Prompt user to confirm overwrite
|
|
|
|
|
+ raise AlreadyExistsException(
|
|
|
|
|
+ message=f"Model '{model_in.name}' was previously deleted. "
|
|
|
|
|
+ "Do you want to overwrite it? Set 'overwrite_deleted=true' to confirm."
|
|
|
|
|
+ )
|
|
|
|
|
+ # User confirmed overwrite - permanently delete the soft-deleted record
|
|
|
await session.delete(any_existing)
|
|
await session.delete(any_existing)
|
|
|
await session.flush()
|
|
await session.flush()
|
|
|
else:
|
|
else:
|
|
@@ -473,7 +480,7 @@ async def create_model(
|
|
|
"Please choose a different name or check the existing model route."
|
|
"Please choose a different name or check the existing model route."
|
|
|
)
|
|
)
|
|
|
await validate_model_in(session, model_in)
|
|
await validate_model_in(session, model_in)
|
|
|
- model_in_dict = model_in.model_dump(exclude={"enable_model_route"})
|
|
|
|
|
|
|
+ model_in_dict = model_in.model_dump(exclude={"enable_model_route", "overwrite_deleted"})
|
|
|
|
|
|
|
|
# Stamp tenant scope. ModelBase has owner_principal_id defaulted to
|
|
# Stamp tenant scope. ModelBase has owner_principal_id defaulted to
|
|
|
# PLATFORM_PRINCIPAL_ID, so `model_dump()` always emits the key —
|
|
# PLATFORM_PRINCIPAL_ID, so `model_dump()` always emits the key —
|