Skip to content

Commit

Permalink
fix(db): update models for boards w/ nullable deleted_at
Browse files Browse the repository at this point in the history
  • Loading branch information
psychedelicious committed Jun 22, 2023
1 parent 19a6e5d commit 6779f1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions invokeai/app/services/board_image_record_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def _create_tables(self) -> None:
created_at DATETIME NOT NULL DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')),
-- updated via trigger
updated_at DATETIME NOT NULL DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')),
-- enforce one-to-many relationship between boards and images using PK
-- (we can extend this to many-to-many later)
-- Soft delete, currently unused
deleted_at DATETIME,
-- enforce one-to-many relationship between boards and images using PK
-- (we can extend this to many-to-many later)
PRIMARY KEY (image_name),
FOREIGN KEY (board_id) REFERENCES boards (board_id) ON DELETE CASCADE,
FOREIGN KEY (image_name) REFERENCES images (image_name) ON DELETE CASCADE
Expand Down
8 changes: 6 additions & 2 deletions invokeai/app/services/models/board_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class BoardRecord(BaseModel):
description="The updated timestamp of the board."
)
"""The updated timestamp of the image."""
deleted_at: Union[datetime, str, None] = Field(
description="The deleted timestamp of the board."
)
"""The updated timestamp of the image."""
cover_image_name: Optional[str] = Field(
description="The name of the cover image of the board."
)
Expand Down Expand Up @@ -46,13 +50,13 @@ def deserialize_board_record(board_dict: dict) -> BoardRecord:
cover_image_name = board_dict.get("cover_image_name", "unknown")
created_at = board_dict.get("created_at", get_iso_timestamp())
updated_at = board_dict.get("updated_at", get_iso_timestamp())
# deleted_at = board_dict.get("deleted_at", get_iso_timestamp())
deleted_at = board_dict.get("deleted_at", get_iso_timestamp())

return BoardRecord(
board_id=board_id,
board_name=board_name,
cover_image_name=cover_image_name,
created_at=created_at,
updated_at=updated_at,
# deleted_at=deleted_at,
deleted_at=deleted_at,
)

0 comments on commit 6779f1a

Please sign in to comment.