mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 02:41:35 +01:00
Add user id field to article table
This commit is contained in:
@@ -7,6 +7,7 @@ ALTER TABLE internal.header ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.home ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.article ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.footer ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.collab ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY view_user ON internal.user
|
||||
FOR SELECT
|
||||
@@ -178,6 +179,51 @@ USING (
|
||||
);
|
||||
|
||||
|
||||
CREATE POLICY view_collaborations ON internal.collab
|
||||
FOR SELECT
|
||||
USING (
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM internal.website
|
||||
WHERE internal.website.id = internal.collab.website_id
|
||||
AND internal.website.owner_id = (current_setting('request.jwt.claims', true)::json->>'user_id')::UUID
|
||||
)
|
||||
);
|
||||
|
||||
CREATE POLICY insert_collaborations ON internal.collab
|
||||
FOR INSERT
|
||||
WITH CHECK (
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM internal.website
|
||||
WHERE internal.website.id = internal.collab.website_id
|
||||
AND internal.website.owner_id = (current_setting('request.jwt.claims', true)::json->>'user_id')::UUID
|
||||
)
|
||||
);
|
||||
|
||||
CREATE POLICY update_collaborations ON internal.collab
|
||||
FOR UPDATE
|
||||
USING (
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM internal.website
|
||||
WHERE internal.website.id = internal.collab.website_id
|
||||
AND internal.website.owner_id = (current_setting('request.jwt.claims', true)::json->>'user_id')::UUID
|
||||
)
|
||||
);
|
||||
|
||||
CREATE POLICY delete_collaborations ON internal.collab
|
||||
FOR DELETE
|
||||
USING (
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM internal.website
|
||||
WHERE internal.website.id = internal.collab.website_id
|
||||
AND internal.website.owner_id = (current_setting('request.jwt.claims', true)::json->>'user_id')::UUID
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
-- migrate:down
|
||||
DROP POLICY view_user ON internal.user;
|
||||
DROP POLICY view_own_websites ON internal.website;
|
||||
@@ -197,6 +243,10 @@ DROP POLICY delete_own_article ON internal.article;
|
||||
DROP POLICY insert_own_article ON internal.article;
|
||||
DROP POLICY view_own_footer ON internal.footer;
|
||||
DROP POLICY update_own_footer ON internal.footer;
|
||||
DROP POLICY view_collaborations ON internal.collab;
|
||||
DROP POLICY insert_collaborations ON internal.collab;
|
||||
DROP POLICY update_collaborations ON internal.collab;
|
||||
DROP POLICY delete_collaborations ON internal.collab;
|
||||
|
||||
ALTER TABLE internal.user DISABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.website DISABLE ROW LEVEL SECURITY;
|
||||
@@ -205,4 +255,5 @@ ALTER TABLE internal.settings DISABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.header DISABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.home DISABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.article DISABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.footer DISABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.footer DISABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE internal.collab DISABLE ROW LEVEL SECURITY;
|
||||
Reference in New Issue
Block a user