-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(memory-store): Change association structure of files and docs #973
Conversation
Signed-off-by: Diwank Singh Tomer <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to 30b5763 in 1 minute and 48 seconds
More details
- Looked at
233
lines of code in4
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. memory-store/migrations/000005_files.up.sql:65
- Draft comment:
The primary key constraintpk_file_owners
should includeowner_type
andowner_id
to ensure uniqueness for each owner of a file. Consider changing it to:
CONSTRAINT pk_file_owners PRIMARY KEY (developer_id, file_id, owner_type, owner_id),
- Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The current PK means each file can only have one owner total, which seems to be the intended design since we're moving from separate tables to a unified ownership table. If multiple owners were intended, they would have kept separate tables or included owner_type/id in the PK. The trigger validates owner references but doesn't prevent multiple owners because the PK blocks it already.
I could be wrong about the intended design - maybe files should be able to have both a user owner and an agent owner. The comment might be identifying a real limitation.
The deliberate schema change from separate tables to a unified table with a restrictive PK strongly suggests single ownership is intended. If multiple owners were needed, the original separate tables design would have been better.
The comment should be deleted as it appears to misunderstand the intended design of single ownership per file. The current PK correctly enforces this constraint.
2. memory-store/migrations/000006_docs.up.sql:72
- Draft comment:
The primary key constraintpk_doc_owners
should includeowner_type
andowner_id
to ensure uniqueness for each owner of a document. Consider changing it to:
CONSTRAINT pk_doc_owners PRIMARY KEY (developer_id, doc_id, owner_type, owner_id),
- Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The current PK implies a doc can only have one owner, which seems intentional given the table name is doc_owners not doc_owner_relations. The trigger validate_doc_owner ensures referential integrity to users/agents tables. If multiple owners per doc was intended, the comment would be correct, but the table name and structure suggest single ownership is the design goal.
I could be wrong about the intention - maybe the table name is misleading and it should support multiple owners per document. The index on (developer_id, owner_type, owner_id) suggests querying by owner is important.
While multiple owners might be useful, the current schema clearly enforces single ownership through the PK. This appears to be an intentional design choice, not an oversight. The index on owner fields is for efficient lookups, not uniqueness.
The comment should be deleted as it appears to contradict the intentional design of single ownership per document. If multiple owners are needed, that would be a feature request, not a bug fix.
Workflow ID: wflow_CnNWPZx7B1Lr1mGi
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
User description
Signed-off-by: Diwank Singh Tomer [email protected]
PR Type
Enhancement
Description
file_owners
anddoc_owners
)Changes walkthrough 📝
000005_files.down.sql
Restructure file ownership tables cleanup
memory-store/migrations/000005_files.down.sql
agent_files
anduser_files
tables withdropping of unified
file_owners
table000005_files.up.sql
Implement unified file ownership structure
memory-store/migrations/000005_files.up.sql
user_files
andagent_files
tables with unifiedfile_owners
table000006_docs.down.sql
Update document ownership cleanup migration
memory-store/migrations/000006_docs.down.sql
doc_owners
table and its dependenciesagent_docs
anduser_docs
tables000006_docs.up.sql
Implement unified document ownership structure
memory-store/migrations/000006_docs.up.sql
user_docs
andagent_docs
tables with unifieddoc_owners
table