-
Notifications
You must be signed in to change notification settings - Fork 12
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
WIP: Extend DB for controls table and a mapper table to map controls… #42
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
# primary keys | ||
control_id: int = Field( | ||
primary_key=True, | ||
index=True, |
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.
no need to build an index on a PK
) | ||
op.drop_column("workflow_controls_results", "control_id") |
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.
Why is this here? I can't see any removal in the diff
# foreign keys | ||
user_id: str = Field(sa_type=TEXT(), index=True) |
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.
Lets make user_id
part of the primary key, so we can easily swap it with an org_id
/workspace_id
later
), | ||
sa.PrimaryKeyConstraint("control_id", "user_id", "workflow_id"), | ||
) | ||
op.drop_column("workflow_controls_results", "control_id") |
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.
Why do we need this? The workflow_controls_results
table does not contain a control_id
column (see here)
from sqlalchemy import text | ||
|
||
# Use SQLite for testing | ||
DATABASE_URL = "sqlite:///:memory:" |
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.
The unit tests already expects that our postgres DB is running. I would suggest to use the postgres instead of sqlite. We should then also generalize the session fixture to use the same one across tests. See tests/workers/conftest.py
for the fixture used by the other tests.
# Create a control | ||
control = ControlSchema( | ||
control_name="Test Control", | ||
control_description="A test control", | ||
user_id="user123", | ||
) | ||
session.add(control) | ||
|
||
# Create a workflow | ||
workflow = WorkflowSchema( | ||
workflow_id="workflow123", | ||
workflow_name="Test Workflow", | ||
user_id="user123", | ||
workflow_dag={}, | ||
is_active=True, | ||
) | ||
session.add(workflow) | ||
session.commit() | ||
|
||
# Create the mapping | ||
mapping = ControlsWorkflowsMappingSchema( | ||
control_id=control.control_id, workflow_id=workflow.workflow_id | ||
) | ||
session.add(mapping) |
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.
Maybe lets combine the test_create_control_workflow_mapping
and test_cascade_delete_workflow
test because this here is code duplication and there's no need to test it twice imo.
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.
As an alternative, we could factor this out in a helper function for setting up the scenario.
f5eb776
to
bd8f26d
Compare
WIP