about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-08-18 21:35:14 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-08-18 21:35:14 +0200
commitcfe3ce7b78095ada79a45ef3f4ee603b410c5497 (patch)
tree51e1000e9e939c4bf37b2906ca50bfd4f9961330
parentMisc: Log to stdout (diff)
downloadfs-tracer-backend-cfe3ce7b78095ada79a45ef3f4ee603b410c5497.tar.gz
fs-tracer-backend-cfe3ce7b78095ada79a45ef3f4ee603b410c5497.tar.bz2
fs-tracer-backend-cfe3ce7b78095ada79a45ef3f4ee603b410c5497.zip
Migrations: Add new restored_file table migration
-rw-r--r--supabase/migrations/20240818192021_create_restored_file_table.sql21
1 files changed, 21 insertions, 0 deletions
diff --git a/supabase/migrations/20240818192021_create_restored_file_table.sql b/supabase/migrations/20240818192021_create_restored_file_table.sql
new file mode 100644
index 0000000..5654b33
--- /dev/null
+++ b/supabase/migrations/20240818192021_create_restored_file_table.sql
@@ -0,0 +1,21 @@
+CREATE TABLE IF NOT EXISTS public."restored_file" (
+	id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
+	user_id UUID NOT NULL,
+	absolute_path VARCHAR(4096) NOT NULL,
+	contents TEXT,
+	original_timestamp TIMESTAMPTZ NOT NULL
+);
+
+ALTER TABLE public."restored_file" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Restrict access to user files to their own files"
+	ON public."restored_file"
+	FOR SELECT
+	TO authenticated
+	USING (user_id = auth.uid());
+
+CREATE POLICY "Users can create a profile."
+	ON public."restored_file"
+	FOR INSERT
+	TO authenticated
+	WITH CHECK (auth.uid() = user_id);