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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions server/data/supabaseTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,81 @@ export type Database = {
}
public: {
Tables: {
helper_parties: {
Row: {
created_at: string
display_name: string
modified_at: string
uuid: string
}
Insert: {
created_at?: string
display_name: string
modified_at?: string
uuid?: string
}
Update: {
created_at?: string
display_name?: string
modified_at?: string
uuid?: string
}
Relationships: []
}
helper_party_network_members: {
Row: {
created_at: string
helper_party_network_uuid: string
helper_party_uuid: string
}
Insert: {
created_at?: string
helper_party_network_uuid: string
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

helper_party_network_uuid?: string
helper_party_uuid?: string
}
Relationships: [
{
foreignKeyName: "helper_party_network_members_helper_party_network_uuid_fkey"
columns: ["helper_party_network_uuid"]
isOneToOne: false
referencedRelation: "helper_party_networks"
referencedColumns: ["uuid"]
},
{
foreignKeyName: "helper_party_network_members_helper_party_uuid_fkey"
columns: ["helper_party_uuid"]
isOneToOne: false
referencedRelation: "helper_parties"
referencedColumns: ["uuid"]
},
]
}
helper_party_networks: {
Row: {
created_at: string
display_name: string
modified_at: string
uuid: string
}
Insert: {
created_at?: string
display_name: string
modified_at?: string
uuid?: string
}
Update: {
created_at?: string
display_name?: string
modified_at?: string
uuid?: string
}
Relationships: []
}
queries: {
Row: {
created_at: string
Expand Down
77 changes: 77 additions & 0 deletions server/supabase/migrations/20240608204813_helper_party.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
create table
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,
modified_at timestamp default current_timestamp not null
);

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 );
Comment on lines +9 to +25
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.


create table
helper_party_networks (
uuid uuid default gen_random_uuid() primary key,
display_name varchar(255) unique not null,
created_at timestamp default current_timestamp not null,
modified_at timestamp default current_timestamp not null
);

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 );
Comment on lines +35 to +51
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.


create table
helper_party_network_members (
helper_party_uuid uuid references helper_parties not null,
helper_party_network_uuid uuid references helper_party_networks not null,
created_at timestamp default current_timestamp not null,
primary key (helper_party_uuid, helper_party_network_uuid)
);

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 );
Comment on lines +61 to +77
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.

22 changes: 22 additions & 0 deletions server/supabase/seed.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--
-- Data for Name: helper_parties; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.helper_parties (uuid, display_name) VALUES ('de218b52-1ec7-4a4d-9bf9-f9070b2c3a93', 'Local test helper 1');
INSERT INTO public.helper_parties (uuid, display_name) VALUES ('b8848f0f-65c4-499f-82b4-1e3a119ba31e', 'Local test helper 2');
INSERT INTO public.helper_parties (uuid, display_name) VALUES ('91993b4a-4131-4b9f-a132-d4a5839e3c6c', 'Local test helper 3');


--
-- Data for Name: helper_party_networks; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.helper_party_networks (uuid, display_name) VALUES ('a8c892ae-8cee-472f-95f0-e25b1fec9759', 'Local test network');

--
-- Data for Name: helper_party_network_members; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.helper_party_network_members (helper_party_uuid, helper_party_network_uuid) VALUES ('de218b52-1ec7-4a4d-9bf9-f9070b2c3a93', 'a8c892ae-8cee-472f-95f0-e25b1fec9759');
INSERT INTO public.helper_party_network_members (helper_party_uuid, helper_party_network_uuid) VALUES ('b8848f0f-65c4-499f-82b4-1e3a119ba31e', 'a8c892ae-8cee-472f-95f0-e25b1fec9759');
INSERT INTO public.helper_party_network_members (helper_party_uuid, helper_party_network_uuid) VALUES ('91993b4a-4131-4b9f-a132-d4a5839e3c6c', 'a8c892ae-8cee-472f-95f0-e25b1fec9759');
Loading