about summary refs log tree commit diff
path: root/supabase/migrations/20240605214222_create_api_key_table.sql
diff options
context:
space:
mode:
Diffstat (limited to 'supabase/migrations/20240605214222_create_api_key_table.sql')
-rw-r--r--supabase/migrations/20240605214222_create_api_key_table.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/supabase/migrations/20240605214222_create_api_key_table.sql b/supabase/migrations/20240605214222_create_api_key_table.sql
new file mode 100644
index 0000000..ece2226
--- /dev/null
+++ b/supabase/migrations/20240605214222_create_api_key_table.sql
@@ -0,0 +1,12 @@
+CREATE TABLE IF NOT EXISTS public."api_key" (
+  user_id UUID NOT NULL REFERENCES auth.users,
+  api_key CHAR(44) NOT NULL
+);
+
+ALTER TABLE public."api_key" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Restrict access to user api keys to their own api keys"
+	ON public."api_key"
+	FOR SELECT
+	TO authenticated
+	USING (user_id = auth.uid());