Skip to content
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

add helper_parties and helper_party_network tables #36

Merged
merged 3 commits into from
Jun 10, 2024
Merged

Conversation

eriktaubeneck
Copy link
Member

@eriktaubeneck eriktaubeneck commented Jun 9, 2024

this creates 3 new tables:

  1. helper_parties
  2. helper_party_networks
  3. helper_party_network_members (a join table for 1 and 2)

changes to server/data/supabaseTypes.ts are autogenerated, and the seed data is just for testing.

Summary by CodeRabbit

  • New Features
    • Introduced new tables for managing helper parties, networks, and their members.
    • Implemented row-level security and access policies for these new tables to ensure data protection and controlled access by authenticated users.

Copy link

vercel bot commented Jun 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
draft ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 10, 2024 10:36pm

Copy link
Contributor

coderabbitai bot commented Jun 9, 2024

Walkthrough

The changes introduce new tables for managing helper parties, networks, and their members in the Supabase backend. These modifications include defining row structures, insert and update types, and establishing relationships with foreign key constraints. Additionally, row-level security policies are implemented to control access to these tables, ensuring only authenticated users can perform select, insert, and update operations.

Changes

Files/Paths Change Summary
server/data/supabaseTypes.ts Added helper_parties, helper_party_network_members, and helper_party_networks with their respective row structures, insert/update types, and relationships.
server/supabase/migrations/20240608204813...sql Created tables for helper_parties, helper_party_networks, and helper_party_network_members with row-level security policies for authenticated user access.
server/supabase/seed.sql Inserted initial data into helper_parties, helper_party_networks, and helper_party_network_members tables.

Poem

In fields of code where rabbits play,
New parties form, networks sway,
With secure gates and keys in hand,
Authenticated users can command.
Data flows like rivers clear,
In Supabase, we hold it dear.
🎉🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@eriktaubeneck eriktaubeneck requested a review from akoshelev June 9, 2024 02:48
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9ca2f1f and 82305e1.

Files selected for processing (3)
  • server/data/supabaseTypes.ts (1 hunks)
  • server/supabase/migrations/20240608204813_helper_party.sql (1 hunks)
  • server/supabase/seed.sql (1 hunks)
Files skipped from review due to trivial changes (1)
  • server/supabase/seed.sql
Additional comments not posted (6)
server/supabase/migrations/20240608204813_helper_party.sql (3)

1-24: The table creation and policies for helper_parties are well-defined, ensuring proper access control and data integrity.


26-50: The table creation and policies for helper_party_networks are correctly implemented, ensuring data integrity and secure access.


52-76: The creation of helper_party_network_members and its policies are correctly set up, ensuring relational integrity and secure data access.

server/data/supabaseTypes.ts (3)

37-54: The TypeScript definitions for helper_parties are comprehensive and align well with the SQL table structure.


55-87: The TypeScript definitions for helper_party_network_members are detailed and correctly reflect the relationships and data structure.


88-108: The TypeScript definitions for helper_party_networks are well-structured and ensure type safety and consistency with the database schema.

helper_party_networks (
uuid uuid default gen_random_uuid() primary key,
display_name varchar(255) unique not null,
size smallint not null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels to me that an enum will be more appropriate here - you may want to support semi-honest/malicious 2 party, TEE, etc.. Size will require a migration in the future

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, that makes sense. at this point, I don't think this is used so maybe it makes sense to just drop it until we need it.

helper_parties (
uuid uuid default gen_random_uuid() primary key,
display_name varchar(255) unique not null,
created_at timestamp default current_timestamp not null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the standard way is to define both created_at, modified_at and modified_by

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding modified_at. I'll figure out modified_by (and I suppose created_by) later.

helper_party_uuid: string
}
Update: {
created_at?: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this mean for an update operation if someone specifies created_at?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an autogenerated file, generating types for the tables. I don't believe there is a way at the DB level to assure that created_at isn't modified.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea unless this generates a JS API for DB, it is not possible to prevent that

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 82305e1 and 2e77616.

Files selected for processing (3)
  • server/data/supabaseTypes.ts (1 hunks)
  • server/supabase/migrations/20240608204813_helper_party.sql (1 hunks)
  • server/supabase/seed.sql (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • server/data/supabaseTypes.ts
  • server/supabase/seed.sql

Comment on lines +9 to +25
alter table helper_parties enable row level security;

create policy "Helper Parties are visible to authenticated users"
on helper_parties for select
to authenticated
using ( true );

create policy "Helper Parties are only created by authenticated users"
on helper_parties for insert
to authenticated
with check ( true );

create policy "Helper Parties are only updated by authenticated users"
on helper_parties for update
to authenticated
using ( true )
with check ( true );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refining the policy conditions for better security.

The policies for helper_parties use a simple true condition for select, insert, and update operations. This might not be secure enough as it allows any authenticated user to perform these operations. Consider adding more specific conditions based on user roles or attributes.

Comment on lines +35 to +51
alter table helper_party_networks enable row level security;

create policy "Helper Party Networks are visible to authenticated users"
on helper_party_networks for select
to authenticated
using ( true );

create policy "Helper Party Networks are only created by authenticated users"
on helper_party_networks for insert
to authenticated
with check ( true );

create policy "Helper Party Networks are only updated by authenticated users"
on helper_party_networks for update
to authenticated
using ( true )
with check ( true );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refining the policy conditions for better security.

The policies for helper_party_networks also use a simple true condition for select, insert, and update operations. This might expose sensitive network data to any authenticated user. Consider adding more specific conditions based on user roles or attributes.

Comment on lines +61 to +77
alter table helper_party_network_members enable row level security;

create policy "Helper Party Network Members are visible to authenticated users"
on helper_party_network_members for select
to authenticated
using ( true );

create policy "Helper Party Network Members are only created by authenticated users"
on helper_party_network_members for insert
to authenticated
with check ( true );

create policy "Helper Party Network Members are only updated by authenticated users"
on helper_party_network_members for update
to authenticated
using ( true )
with check ( true );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refining the policy conditions for better security.

The policies for helper_party_network_members use a simple true condition for select, insert, and update operations. This might not be secure enough as it allows any authenticated user to perform these operations on sensitive linkage data. Consider adding more specific conditions based on user roles or attributes.

@eriktaubeneck eriktaubeneck merged commit 2ffdd75 into main Jun 10, 2024
3 checks passed
@eriktaubeneck eriktaubeneck deleted the helper-party branch June 10, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants