mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
refactor(db): rename searchspaces table to workspaces
Phase 1 (rename DB) commit 1i: rename the SearchSpace table to workspaces and flip all 24 inbound FK target strings (20 in db.py + the 4 satellite models), plus the raw-SQL searchspaces references in the obsidian and google-unification integration fixtures. This completes the ORM half of Phase 1. The SearchSpace class name, relationship/back_populates attribute names, and the /searchspaces API route URLs are intentionally left for Phase 2. Verified: unit 2375 passed/1 skip, integration 346 passed (baseline parity); create_all builds every table with the workspaces name and all FKs resolving to workspaces.id.
This commit is contained in:
parent
35f80268df
commit
c6d4e5df7c
7 changed files with 28 additions and 28 deletions
|
|
@ -27,7 +27,7 @@ class Automation(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ class NewChatThread(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
|
|
@ -791,7 +791,7 @@ class ExternalChatAccount(Base, TimestampMixin):
|
|||
owner_search_space_id = Column(
|
||||
"owner_workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=True,
|
||||
)
|
||||
is_system_account = Column(
|
||||
|
|
@ -906,7 +906,7 @@ class ExternalChatBinding(Base, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
state = Column(
|
||||
|
|
@ -1125,7 +1125,7 @@ class TokenUsage(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
@ -1331,7 +1331,7 @@ class Folder(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
@ -1396,7 +1396,7 @@ class Document(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
|
|
@ -1523,7 +1523,7 @@ class VideoPresentation(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
search_space = relationship("SearchSpace", back_populates="video_presentations")
|
||||
|
|
@ -1553,7 +1553,7 @@ class Report(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
search_space = relationship("SearchSpace", back_populates="reports")
|
||||
|
|
@ -1584,7 +1584,7 @@ class Connection(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=True,
|
||||
)
|
||||
user_id = Column(
|
||||
|
|
@ -1698,7 +1698,7 @@ class ImageGeneration(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
created_by_id = Column(
|
||||
|
|
@ -1714,7 +1714,7 @@ class ImageGeneration(BaseModel, TimestampMixin):
|
|||
|
||||
|
||||
class SearchSpace(BaseModel, TimestampMixin):
|
||||
__tablename__ = "searchspaces"
|
||||
__tablename__ = "workspaces"
|
||||
|
||||
name = Column(String(100), nullable=False, index=True)
|
||||
description = Column(String(500), nullable=True)
|
||||
|
|
@ -1910,7 +1910,7 @@ class SearchSourceConnector(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
search_space = relationship(
|
||||
|
|
@ -1940,7 +1940,7 @@ class Log(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
search_space = relationship("SearchSpace", back_populates="logs")
|
||||
|
|
@ -2083,7 +2083,7 @@ class SearchSpaceRole(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
search_space = relationship("SearchSpace", back_populates="roles")
|
||||
|
|
@ -2117,7 +2117,7 @@ class SearchSpaceMembership(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
role_id = Column(
|
||||
|
|
@ -2162,7 +2162,7 @@ class SearchSpaceInvite(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
# Role to assign when invite is used (null means use default role)
|
||||
|
|
@ -2223,7 +2223,7 @@ class Prompt(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
|
|
@ -2553,7 +2553,7 @@ class AgentActionLog(BaseModel):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
@ -2625,7 +2625,7 @@ class DocumentRevision(BaseModel):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
@ -2667,7 +2667,7 @@ class FolderRevision(BaseModel):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
@ -2704,7 +2704,7 @@ class AgentPermissionRule(BaseModel):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class DocumentFile(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class Notification(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Podcast(BaseModel, TimestampMixin):
|
|||
search_space_id = Column(
|
||||
"workspace_id",
|
||||
Integer,
|
||||
ForeignKey("searchspaces.id", ondelete="CASCADE"),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
search_space = relationship("SearchSpace", back_populates="podcasts")
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ async def committed_google_data(async_engine):
|
|||
|
||||
async with async_engine.begin() as conn:
|
||||
await conn.execute(
|
||||
text("DELETE FROM searchspaces WHERE id = :sid"), {"sid": space_id}
|
||||
text("DELETE FROM workspaces WHERE id = :sid"), {"sid": space_id}
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -306,5 +306,5 @@ async def cleanup_space(async_engine, space_id: int):
|
|||
"""Delete a search space (cascades to connectors/documents)."""
|
||||
async with async_engine.begin() as conn:
|
||||
await conn.execute(
|
||||
text("DELETE FROM searchspaces WHERE id = :sid"), {"sid": space_id}
|
||||
text("DELETE FROM workspaces WHERE id = :sid"), {"sid": space_id}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ async def race_user_and_space(async_engine):
|
|||
{"id": space_id},
|
||||
)
|
||||
await cleanup.execute(
|
||||
text("DELETE FROM searchspaces WHERE id = :id"),
|
||||
text("DELETE FROM workspaces WHERE id = :id"),
|
||||
{"id": space_id},
|
||||
)
|
||||
await cleanup.execute(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue